/* frontend/css/alerts.css — Phase C
 *
 * Alerts settings panel (inside the Settings overlay) + inline
 * mini-subscribe form on the ticker page. Consumes only existing
 * theme tokens — no hardcoded hex values, no new tokens.
 *
 * Layout follows design § 8.1.1 (FR-A3 / ISSUE-010):
 *   ≥ 1024 px : two-column form (master toggles | subscription list)
 *   640–1023  : single column; per-ticker list collapses with View all
 *   < 640 px  : single column; sticky CTA on mobile
 *
 * Tap-target floor at < 640 px is 44 × 44 (WCAG 2.5.5) — mirrors the
 * calendar chip rule. Reused from app.css buttons where possible.
 */

/* ── Settings overlay's Alerts section ──────────────────────────── */

.alerts-settings-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alerts-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alerts-settings-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alerts-settings-info .alerts-name {
  font-weight: 600;
  color: var(--text);
}

.alerts-settings-info .alerts-desc {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.4;
}

/* ── Subscribe form ─────────────────────────────────────────────── */

.alerts-subscribe-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface2);
  border-radius: 8px;
}

.alerts-subscribe-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.alerts-subscribe-row label {
  font-size: 13px;
  color: var(--text2);
  min-width: 60px;
}

.alerts-subscribe-row input[type="text"],
.alerts-subscribe-row select {
  flex: 1 1 120px;
  min-width: 80px;
  min-height: 36px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--text2);
  border-radius: 4px;
  font-size: 14px;
}

.alerts-subscribe-row .alerts-submit-btn {
  flex: 0 0 auto;
  padding: 8px 16px;
  min-height: 36px;
  background: var(--accent);
  color: var(--on-accent, #fff);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

@media (hover: hover) {
  .alerts-subscribe-row .alerts-submit-btn:hover { filter: brightness(1.1); }
}
.alerts-subscribe-row .alerts-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.alerts-form-msg {
  font-size: 13px;
  padding: 4px 0;
  min-height: 16px;
}

/* R1-10 — reference the project's pos/neg palette tokens (themes.css)
   so theme overrides apply uniformly; inline hex fallbacks track the
   default theme's --pos / --neg values for the rare case where no
   theme has loaded yet. */
.alerts-form-msg.is-ok    { color: var(--pos, #7dba8a); }
.alerts-form-msg.is-error { color: var(--neg, #e85a5a); }

/* ── Subscription list ─────────────────────────────────────────── */

.alerts-sub-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
}

.alerts-sub-list-empty {
  color: var(--text2);
  font-size: 14px;
  font-style: italic;
  padding: 12px 0;
}

.alerts-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 4px;
}

.alerts-sub-row .alerts-sub-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alerts-sub-row .alerts-sub-ticker {
  font-weight: 600;
  color: var(--text);
}

.alerts-sub-row .alerts-sub-kind {
  font-size: 12px;
  color: var(--text2);
}

.alerts-sub-row .alerts-remove-btn {
  flex: 0 0 auto;
  padding: 6px 12px;
  min-height: 32px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--text2);
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

@media (hover: hover) {
  .alerts-sub-row .alerts-remove-btn:hover {
    color: var(--neg, #e85a5a);
    border-color: var(--neg, #e85a5a);
  }
}

/* ── How alerts work — collapsible explainer ───────────────────── */

.alerts-howto {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 6px;
}

.alerts-howto summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  list-style: none;
}

.alerts-howto summary::-webkit-details-marker { display: none; }
.alerts-howto summary::before { content: '▸ '; color: var(--text2); }
.alerts-howto[open] summary::before { content: '▾ '; }

.alerts-howto-body {
  margin-top: 10px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.5;
}

.alerts-howto-body p { margin: 6px 0; }

/* ── Inline mini-form on ticker page (Module 11 CTA) ───────────── */

.tk-alerts-inline {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface2);
  border-radius: 6px;
  display: none;
}

.tk-alerts-inline.is-open { display: block; }

.tk-alerts-inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tk-alerts-inline-row select,
.tk-alerts-inline-row .btn {
  min-height: 36px;
}

.tk-alerts-inline-label {
  font-size: 13px;
  color: var(--text2);
}

.tk-alerts-msg {
  font-size: 13px;
  margin-top: 6px;
  min-height: 16px;
}

.tk-alerts-msg.is-ok    { color: var(--pos, #7dba8a); }
.tk-alerts-msg.is-error { color: var(--neg, #e85a5a); }

/* ── Delisted banner (UC-T10, Phase B carry #5) ────────────────── */

.tk-delisted-banner {
  margin-bottom: 12px;
  padding: 12px 16px;
  background: var(--surface2);
  border-left: 4px solid var(--neg, #e85a5a);
  border-radius: 4px;
  color: var(--text);
}

.tk-delisted-banner-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.tk-delisted-banner-body {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.4;
}

/* ── Responsive: ≥ 1024 px two-column ──────────────────────────── */

@media (min-width: 1024px) {
  .alerts-settings-root.has-two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

/* ── Responsive: < 640 px stacked + 44 px tap floor ───────────── */

@media (max-width: 640px) {
  .alerts-subscribe-row { flex-direction: column; align-items: stretch; }
  .alerts-subscribe-row label { min-width: auto; }
  /* When the row flips to flex-direction: column, the row-mode
     `flex: 1 1 120px` on input/select now applies to the vertical main
     axis (flex-basis 120 px height + grow 1) — which is what stretched
     the Ticker / Type fields into oversized boxes on iOS Safari
     screenshots. Reset flex to 0-0-auto here so column children take
     their natural height; width: 100% still gives full row width,
     min-height: 44px keeps the WCAG 2.5.5 tap-target floor. */
  .alerts-subscribe-row input[type="text"],
  .alerts-subscribe-row select,
  .alerts-subscribe-row .alerts-submit-btn {
    flex: 0 0 auto;
    width: 100%;
    min-height: 44px;
  }
  .alerts-sub-row .alerts-remove-btn { min-height: 44px; min-width: 44px; }
}
