/* ═══════════════════════════════════════════════════════════
   INTELLIGENCE CENTER — Custom Alerts + AI Patterns
   ═══════════════════════════════════════════════════════════ */

/* ── Routines header (styled after Claude's Routines panel) ── */
.routines-header {
  padding: 20px 0 14px;
}
.routines-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.routines-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.routines-icon {
  color: var(--text);
  flex-shrink: 0;
}
.routines-title {
  font-family: var(--heading);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
  line-height: 1.1;
}
.routines-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.routines-new-btn:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.12);
}
.routines-subtitle {
  font-size: 13.5px;
  color: var(--text-tertiary);
  margin: 8px 0 0;
  line-height: 1.4;
}

/* ── Empty state ── */
.routines-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 0;
  gap: 12px;
  color: var(--text-tertiary);
}
.routines-empty-icon { color: var(--text-tertiary); opacity: 0.5; }
.routines-empty-title {
  font-size: 14px;
  color: var(--text-tertiary);
}

.routines-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.alerts-header {
  padding: 8px 0 12px;
}
.ca-disclaimer {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  opacity: 0.55;
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 0 10px;
}
.alerts-title {
  font-family: var(--heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
.alerts-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ── AI Toggle Row ── */
.ca-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-radius: var(--radius-14);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  cursor: pointer;
  transition: background 0.2s;
}
.ca-toggle-row:active { background: rgba(255, 255, 255, 0.05); }
.ca-toggle-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
}
.ca-toggle-desc {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ── Tabs ── */
.ca-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 16px;
}
.ca-tab {
  flex: 1;
  padding: 10px 0;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.ca-tab:active { transform: scale(0.97); }
.ca-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* ── Section ── */
.ca-section {
  padding-bottom: 100px;
}
.ca-section-label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ── Add Button ── */
.ca-add-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-pill);
  background: rgba(0, 255, 136, 0.06);
  border: 1px dashed rgba(0, 255, 136, 0.2);
  color: #00ff88;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  transition: all 0.2s var(--ease);
}
.ca-add-btn:active {
  transform: scale(0.98);
  background: rgba(0, 255, 136, 0.1);
}

/* ── Empty State ── */
.ca-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px;
  text-align: center;
}
.ca-empty svg { margin-bottom: 16px; opacity: 0.4; }
.ca-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.ca-empty-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 250px;
}

/* ── Alert Card ── */
.ca-alert-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-14);
  padding: 16px;
  margin-bottom: 10px;
  animation: caCardIn 0.3s var(--ease);
  transition: opacity 0.2s;
}
.ca-alert-card.disabled { opacity: 0.45; }
.ca-alert-card.triggered {
  border-color: rgba(0, 255, 136, 0.2);
  background: rgba(0, 255, 136, 0.03);
}

@keyframes caCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ca-alert-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.ca-alert-ticker {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}
.ca-alert-condition {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ca-cond-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.ca-cond-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ca-alert-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Mini toggle */
.ca-toggle-btn {
  width: 36px;
  height: 20px;
  border-radius: var(--radius-10);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}
.ca-toggle-btn.on { background: rgba(0, 255, 136, 0.3); }
.ca-toggle-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-tertiary);
  position: absolute;
  top: 3px;
  left: 3px;
  transition: all 0.2s var(--ease);
}
.ca-toggle-btn.on .ca-toggle-dot {
  left: 19px;
  background: #00ff88;
}

.ca-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: rgba(255, 59, 48, 0.06);
  border: none;
  color: var(--loss);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.ca-delete-btn:active { opacity: 1; }

.ca-alert-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-left: 2px;
}

.ca-alert-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ca-alert-status {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ca-alert-status.active { color: #00ff88; }
.ca-alert-status.paused { color: var(--text-tertiary); }
.ca-alert-status.triggered { color: var(--gain); }
.ca-alert-created {
  font-size: 10px;
  color: var(--text-tertiary);
}

/* ── History ── */
.ca-history-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.ca-history-item:last-child { border-bottom: none; }
.ca-history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--text-tertiary);
}
.ca-history-dot.bullish { background: var(--gain); }
.ca-history-dot.bearish { background: var(--loss); }
.ca-history-body { flex: 1; }
.ca-history-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
}
.ca-history-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── Create Alert Form (overlay sheet) ── */
.ca-form-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: background 0.3s;
  pointer-events: none;
}
.ca-form-overlay.open {
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}
.ca-form-sheet {
  width: 100%;
  max-width: 420px;
  background: #1a1a1a;
  border-radius: 32px 32px 0 0;
  padding: 16px 24px 32px;
  transform: translateY(100%);
  transition: transform 0.35s var(--ease);
}
.ca-form-overlay.open .ca-form-sheet {
  transform: translateY(0);
}
.ca-form-handle {
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -8px 0 12px;
  cursor: grab;
  touch-action: none;
}
.ca-form-handle::before {
  content: '';
  width: 36px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.15);
}
.ca-form-title {
  font-family: var(--heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}
.ca-form-subtitle {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-secondary);
  margin: 0 0 20px;
}
.ca-form-field {
  margin-bottom: 18px;
}
.ca-form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.ca-form-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-12);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.ca-form-input::placeholder { color: var(--text-tertiary); }
.ca-form-input:focus { border-color: rgba(255, 255, 255, 0.2); }

/* Condition grid */
.ca-cond-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ca-cond-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.ca-cond-btn:active { transform: scale(0.97); }
.ca-cond-btn.active {
  background: rgba(0, 255, 136, 0.06);
  border-color: rgba(0, 255, 136, 0.2);
  color: #00ff88;
}

.ca-form-submit {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-pill);
  background: rgba(0, 255, 136, 0.12);
  border: 1px solid rgba(0, 255, 136, 0.2);
  color: #00ff88;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.2s var(--ease);
}
.ca-form-submit:active { transform: scale(0.98); background: rgba(0, 255, 136, 0.18); }

.ca-form-cancel {
  width: 100%;
  padding: 14px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}
.ca-form-cancel:active { color: var(--text-secondary); }

/* ── Gated (free tier) ── */
.alerts-gated {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}
.alerts-upgrade-btn {
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
  max-width: 240px;
}
.alerts-upgrade-btn:active { opacity: 0.7; }

[data-theme="light"] .ca-form-sheet {
  background: var(--surface-elevated);
}
[data-theme="light"] .ca-form-input {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
  color: var(--text);
}
[data-theme="light"] .ca-form-input:focus {
  border-color: rgba(0,0,0,0.2);
}
[data-theme="light"] .ca-cond-btn {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
  color: var(--text-secondary);
}
[data-theme="light"] .ca-cond-btn.active {
  background: rgba(0,0,0,0.1);
  color: var(--text);
}

/* ── Light mode overrides ── */
[data-theme="light"] .routines-new-btn {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text);
}
[data-theme="light"] .routines-new-btn:active {
  background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .ca-toggle-row {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .ca-toggle-row:active {
  background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .ca-tabs {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .ca-tab {
  color: var(--text-tertiary);
}
[data-theme="light"] .ca-tab.active {
  background: #ffffff;
  color: var(--text);
}
[data-theme="light"] .ca-alert-card {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .ca-alert-card.triggered {
  background: rgba(0, 255, 136, 0.06);
  border-color: rgba(0, 255, 136, 0.2);
}
[data-theme="light"] .ca-alert-ticker,
[data-theme="light"] .ca-toggle-btn {
  background: #ffffff;
}
[data-theme="light"] .ca-cond-label,
[data-theme="light"] .ca-alert-note {
  color: var(--text-secondary);
}
[data-theme="light"] .ca-alert-created,
[data-theme="light"] .ca-history-time {
  color: var(--text-tertiary);
}
[data-theme="light"] .ca-history-item {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .ca-form-overlay.open {
  background: rgba(0, 0, 0, 0.22);
}
[data-theme="light"] .ca-form-sheet {
  background: var(--surface-elevated);
}
[data-theme="light"] .ca-form-handle::before {
  background: rgba(0, 0, 0, 0.14);
}
[data-theme="light"] .ca-form-input,
[data-theme="light"] .ca-cond-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text);
}
[data-theme="light"] .ca-form-input:focus {
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .ca-cond-btn {
  color: var(--text-secondary);
}
[data-theme="light"] .ca-cond-btn.active {
  background: rgba(0, 255, 136, 0.08);
  border-color: rgba(0, 255, 136, 0.2);
  color: var(--gain);
}
[data-theme="light"] .ca-form-submit {
  background: rgba(0, 255, 136, 0.12);
  border-color: rgba(0, 255, 136, 0.2);
  color: var(--gain);
}
[data-theme="light"] .ca-form-submit:active {
  background: rgba(0, 255, 136, 0.18);
}
[data-theme="light"] .alerts-upgrade-btn {
  background: #ffffff;
  color: var(--text);
}
