/* PutSignals — global stylesheet.
   ------------------------------------------------------------------ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  /* Brand palette (per the PutSignals brand book). */
  --navy:      #0B2540;   /* primary brand */
  --navy-2:    #0E2A4A;   /* gradient companion */
  --navy-deep: #081B30;   /* darkest, for sidebar bottom edge */
  --green:     #15A66E;   /* "Verde Prima" — premium / positive accent */
  --green-2:   #34D399;   /* "Verde Señal" — signal / highlight */
  --red:       #E0533D;   /* error / negative */
  --fog:       #F4F7FA;   /* page background */
  --line:      #E3E8EF;   /* hairline borders */
  --muted:     #5C6B7A;   /* secondary text */
  --tint:      #E6F6EF;   /* success tint background (chips) */

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing scale (4px base) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* Radii / shadows */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(11,37,64,.06);
  --shadow-md: 0 4px 12px rgba(11,37,64,.08);
  --shadow-lg: 0 12px 40px rgba(11,37,64,.14);

  /* Layout */
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--fog);
  color: var(--navy);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; font-weight: 700; letter-spacing: -.2px; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
p  { margin: 0 0 12px; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }


/* ── App shell ─────────────────────────────────────────────────── */
/* Desktop: sidebar fija a la izquierda + main area que ocupa el resto.
   Móvil: la sidebar se transforma en un topbar horizontal compacto.   */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  color: #cdd9e5;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  text-decoration: none;
}
.sidebar-brand img { width: 34px; height: 34px; }
.sidebar-brand .wordmark {
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .2px;
}
.sidebar-brand .wordmark span { color: var(--green-2); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: #aebece;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-md);
  text-decoration: none;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.05);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav a.active {
  background: rgba(52,211,153,.14);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: #8298ad;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-foot .user-email { color: #cdd9e5; word-break: break-all; }

/* Sidebar form controls.
   ------------------------------------------------------------------
   The <select> and <button> live inside the navy sidebar, so they
   must keep a dark base AND override the browser's native :hover /
   :focus chrome (without explicit backgrounds, browsers paint white
   on hover and the light text disappears against it). Both `appearance:
   none` calls strip the native chrome so we get a consistent look
   across Chrome / Firefox / Safari. */
.sidebar-foot select,
.sidebar-foot button {
  font: inherit;
  font-weight: 500;
  color: #ffffff;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: background .12s ease, border-color .12s ease;
}
.sidebar-foot select:hover,
.sidebar-foot button:hover {
  background: rgba(52,211,153,.16);   /* green-2 tint, on-brand hover */
  border-color: rgba(52,211,153,.45);
  color: #ffffff;
}
.sidebar-foot select:focus,
.sidebar-foot button:focus {
  outline: 0;
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(52,211,153,.18);
}

/* The <select> arrow is part of the native chrome we just stripped —
   paint a small chevron SVG via background-image instead. */
.sidebar-foot select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 7px;
}

/* The dropdown <option> list is rendered by the OS / browser and
   barely respects CSS — but Firefox + recent Chromium honor these,
   so set them anyway. Worst case the native styling kicks in (white
   bg, dark text), which is also legible. */
.sidebar-foot select option {
  background: var(--navy);
  color: #ffffff;
}

.main {
  flex: 1;
  padding: 28px 34px;
  overflow: auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header .lede { color: var(--muted); font-size: 13px; margin: 0; }


/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}


/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  padding: 11px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease;
  text-align: center;
}
.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--green);
}
.btn-block { display: block; width: 100%; }


/* ── Forms ──────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.form label { font-size: 13px; font-weight: 600; color: var(--navy); }
.form input[type="email"],
.form input[type="text"],
.form input[type="number"] {
  font: inherit;
  padding: 11px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--navy);
}
.form input:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21,166,110,.15);
}


/* ── Flash messages ─────────────────────────────────────────────── */
.flashes { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 6px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  border: 1px solid transparent;
}
.flash-info    { background: #EFF4FB; color: #234C82; border-color: #DBE6F4; }
.flash-success { background: var(--tint); color: #0c7a52; border-color: #C9EBD9; }
.flash-error   { background: #FCE6E0; color: #B23A26; border-color: #F5C7BD; }


/* ── Auth pages (login / sent / expired) ────────────────────────── */
/* Auth views render WITHOUT the app shell — they get their own
   centered card layout against a soft navy → fog vertical wash. */

.auth-bg {
  min-height: 100vh;
  background:
    linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 280px, var(--fog) 280px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
}
.auth-shell {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
}
.auth-brand img { width: 44px; height: 44px; }
.auth-brand .wordmark span { color: var(--green-2); }

.auth-card {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 22px; margin-bottom: 8px; }
.auth-card p  { color: var(--muted); font-size: 14px; }
.auth-card .form { max-width: none; }
.auth-card .form button { margin-top: 8px; }


/* ── Alerts list (#15) ──────────────────────────────────────────── */

.alerts-filters {
  padding: 16px 18px;
  margin-bottom: 16px;
}
.alerts-filters .filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.filter-field > span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
}
.filter-field input,
.filter-field select {
  font: inherit;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--navy);
  min-width: 0;
}
.filter-field input:focus,
.filter-field select:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21,166,110,.15);
}

.alerts-table-card { padding: 0; overflow: hidden; }

.alerts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.alerts-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  white-space: nowrap;
}
.alerts-table thead th a {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}
.alerts-table thead th a:hover { color: var(--navy); }
.alerts-table thead th.sorted { color: var(--navy); }
.alerts-table thead th .sort-caret {
  display: inline-block;
  margin-left: 4px;
  font-size: 9px;
  color: var(--green);
}

.alerts-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.alerts-table tbody tr:last-child td { border-bottom: 0; }
.alerts-table .tkr { font-weight: 700; color: var(--navy); }
.alerts-table .mono { font-family: var(--font-mono); }

.alert-row { cursor: pointer; transition: background .08s ease; }
.alert-row:hover  { background: var(--fog); }
.alert-row:focus  { outline: 2px solid var(--green-2); outline-offset: -2px; }

.alerts-table.compact thead th,
.alerts-table.compact tbody td { padding: 10px 12px; }

/* Outcome chips */
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: .3px;
  white-space: nowrap;
}
.chip-lg { font-size: 13px; padding: 7px 14px; }
.c-win     { background: var(--tint); color: #0c7a52; }
.c-loss    { background: #FCE6E0;     color: #B23A26; }
.c-open    { background: #E7EDF4;     color: #22507E; }
.c-neutral { background: #F4F7FA;     color: var(--muted); }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red);   font-weight: 600; }

.paginator {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  font-size: 13px;
}
.paginator-stats { color: var(--muted); margin-right: auto; }
.paginator-buttons { display: flex; gap: 8px; }
.paginator .btn { padding: 6px 14px; font-size: 13px; }
.paginator-summary {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

.alerts-empty {
  padding: 64px 18px;
  text-align: center;
  color: var(--muted);
}

/* ── Alert detail (#15) ─────────────────────────────────────────── */

.detail-header { align-items: flex-start; }
.detail-header .tkr  { color: var(--green); }
.detail-outcome      { margin-left: auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi .k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}
.kpi .v {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.kpi .v.green { color: var(--green); }

.detail-card { margin-bottom: 18px; }
.detail-card h2 { margin-bottom: 14px; }

.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
  margin: 0;
  font-size: 13px;
}
.detail-grid dt {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .3px;
}
.detail-grid dd {
  margin: 0;
  font-family: var(--font-mono);
  color: var(--navy);
}

/* ── Mobile: collapse sidebar into a topbar ─────────────────────── */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    /* Replace vertical gradient with the navy header tone alone. */
    background: var(--navy);
  }
  .sidebar-brand { margin-bottom: 0; }
  .sidebar-brand img { width: 28px; height: 28px; }
  .sidebar-brand .wordmark { font-size: 15px; }

  /* Hide the nav links on mobile for now (Sprint 2 #15 will wire up
     a proper hamburger drawer). The user reaches pages via the
     in-content links / breadcrumbs in the meantime. */
  .sidebar-nav { display: none; }

  .sidebar-foot {
    margin-top: 0;
    margin-left: auto;
    padding-top: 0;
    border-top: 0;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .sidebar-foot .user-email { display: none; }
  .sidebar-foot select,
  .sidebar-foot button { padding: 4px 8px; font-size: 12px; }

  .main { padding: 18px 16px; }

  /* Tables: let them scroll horizontally rather than crush columns. */
  .alerts-table-card { overflow-x: auto; }
  .alerts-table { min-width: 720px; }

  /* KPI grid: stack tighter on mobile. */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 18px; }

  /* Detail grid: stack dt/dd vertically so long values don't overflow. */
  .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-grid dt { margin-top: 10px; }
}
