/* EmailAuto portal — Gmail-inspired light theme. See STYLE_GUIDE.md. */
:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --hover: #f1f3f4;
  --ink: #202124;
  --muted: #5f6368;
  --line: #e8eaed;
  --line-strong: #dadce0;
  --accent: #0b57d0;
  --accent-hover: #0a4bb8;
  --accent-soft: #d3e3fd;
  --accent-ink: #041e49;
  --danger: #d93025;
  --danger-soft: #fce8e6;
  --success: #1e8e3e;
  --success-soft: #e6f4ea;
  --warn: #e37400;
  --warn-soft: #fef7e0;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-hover: 0 1px 3px rgba(60, 64, 67, .12), 0 4px 8px rgba(60, 64, 67, .08);

  --sidebar-w: 256px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  overflow-wrap: break-word;   /* long tokens/URLs wrap instead of overflowing */
}

a { color: var(--accent); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.wordmark { font-size: 20px; font-weight: 500; letter-spacing: -.2px; color: var(--ink); }
.wordmark::first-letter { color: var(--accent); }
/* Logo is an SVG wordmark (ratio ~4.5:1). Constrain height, let width follow the
   aspect ratio, and never crop or shrink it. */
.brand { display: inline-flex; align-items: center; text-decoration: none; flex: 0 0 auto; }
.brand-logo { height: 28px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.guest-logo { height: 52px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.topbar-right { flex: 0 1 auto; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { color: var(--muted); font-size: 13px; }
.avatar {
  width: 32px; height: 32px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 600; font-size: 14px;
}
.logout { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500; }
.logout:hover { color: var(--ink); }

/* ---------- Shell + sidebar ---------- */
.shell { display: flex; align-items: flex-start; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  padding: 18px 12px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.compose-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 22px 12px 16px;
  font-weight: 500; text-decoration: none;
  box-shadow: 0 1px 3px rgba(60, 64, 67, .12);
  margin: 0 4px 16px;
}
.compose-btn:hover { box-shadow: var(--shadow-hover); background: #fafbff; }
.compose-btn svg { color: var(--accent); }

.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav-link {
  display: flex; align-items: center; gap: 16px;
  padding: 9px 16px;
  border-radius: 0 999px 999px 0;
  color: var(--ink); text-decoration: none;
  font-weight: 500; font-size: 14px;
}
.sidenav-link svg { color: var(--muted); flex: 0 0 auto; }
.sidenav-link:hover { background: var(--hover); }
.sidenav-link.active { background: var(--accent-soft); color: var(--accent-ink); }
.sidenav-link.active svg { color: var(--accent-ink); }

/* ---------- Content ---------- */
.content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 960px;
  padding: 24px 28px 48px;
  display: flex; flex-direction: column; gap: 16px;
}
/* Tablet / mobile: the left rail becomes a horizontal, scrollable nav bar so
   navigation stays reachable (instead of disappearing). */
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: auto; flex: none;
    position: sticky; top: var(--topbar-h); z-index: 9;
    height: auto;
    padding: 8px 12px;
    display: flex; align-items: center; gap: 8px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .compose-btn { margin: 0; flex: 0 0 auto; white-space: nowrap; padding: 9px 16px; }
  .sidenav { flex-direction: row; gap: 6px; }
  .sidenav-link { border-radius: 999px; white-space: nowrap; flex: 0 0 auto; padding: 8px 14px; }
  .content { padding: 18px; max-width: none; }
}

.guest-main {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
}
.guest-wordmark { font-size: 26px; font-weight: 500; letter-spacing: -.3px; }
.guest-wordmark::first-letter { color: var(--accent); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 24px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.card h3 { font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.narrow-card { max-width: 400px; width: 100%; }

.hint { color: var(--muted); font-size: 12.5px; margin: -4px 0 12px; overflow-wrap: anywhere; }

.step {
  background: var(--accent-soft); color: var(--accent-ink);
  width: 24px; height: 24px; border-radius: 999px;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
label { display: block; font-size: 13px; font-weight: 500; color: #3c4043; margin-bottom: 12px; }
label.narrow { max-width: 320px; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, .15);
}
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

details { margin: 4px 0 12px; }
summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 500; }

/* category rows */
.cat-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr 150px 36px;
  gap: 10px; align-items: center; margin-bottom: 10px;
}
.cat-row input, .cat-row select { margin-top: 0; }
.cat-del {
  border: none; background: var(--danger-soft); color: var(--danger);
  width: 36px; height: 40px; border-radius: var(--r-sm); cursor: pointer; font-size: 18px;
}
@media (max-width: 560px) { .cat-row { grid-template-columns: 1fr; } }

.kb label.good { border-left: 3px solid var(--success); padding-left: 12px; }
.kb label.bad { border-left: 3px solid var(--danger); padding-left: 12px; }
.kb label.warn { border-left: 3px solid var(--warn); padding-left: 12px; }

/* ---------- Buttons ---------- */
button { cursor: pointer; font: inherit; font-weight: 500; border-radius: var(--r-sm); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.primary {
  background: var(--accent); color: #fff; border: none;
  padding: 11px 22px; font-size: 14px; border-radius: 999px;
  box-shadow: 0 1px 2px rgba(60, 64, 67, .2);
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-hover); }
.secondary {
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--line-strong); padding: 10px 18px; border-radius: 999px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.secondary:hover { background: #f3f7ff; border-color: var(--accent); }
.ghost {
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--line-strong); padding: 8px 14px; border-radius: var(--r-sm);
}
.ghost:hover { background: var(--hover); }

/* ---------- Output / code blocks ---------- */
.output-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.out-actions { display: flex; gap: 8px; }
.envbox { margin-top: 14px; }
.envbox pre, .yaml {
  background: var(--hover); color: var(--ink);
  padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  overflow: auto; margin: 0; white-space: pre-wrap;
}
code { background: var(--hover); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; overflow-wrap: anywhere; word-break: break-word; }

/* ---------- Flash ---------- */
.flash { padding: 11px 14px; border-radius: var(--r-sm); font-size: 14px; font-weight: 500; }
.flash.ok { background: var(--success-soft); color: var(--success); }
.flash.error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
@media (max-width: 560px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  display: block; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px;
  background: var(--surface); transition: box-shadow .12s, transform .1s;
}
.tile:hover { box-shadow: var(--shadow-hover); }
.tile h3 { margin: 0 0 6px; color: var(--accent); font-size: 14px; }
.tile p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: var(--bg); }
.table a { color: var(--accent); text-decoration: none; font-weight: 500; }

.badge-status { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-status.processing { background: var(--warn-soft); color: var(--warn); }
.badge-status.ready { background: var(--success-soft); color: var(--success); }
.badge-status.failed { background: var(--danger-soft); color: var(--danger); }

.upload-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.upload-row input[type=file] { width: auto; margin-top: 0; }
.danger-link { background: none; border: none; color: var(--danger); font-weight: 500; padding: 0; }

/* ---------- Orientation: page subtitle ---------- */
.content-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.content-sub:empty { display: none; }

/* ================================================================
   Motion & polish — applying emilkowalski/skills (emil-design-eng).
   Strong custom ease-out; entrances <300ms from translateY (never
   scale(0)); transform/opacity only; press feedback; reduced-motion
   keeps content but drops movement. A professional dashboard: crisp.
   ================================================================ */
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);   /* strong ease-out for UI */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);          /* hover / color changes */
}

.primary, .secondary, .ghost, .compose-btn, .sidenav-link, .tile,
.out-actions button, .cat-del {
  transition: transform 160ms var(--ease-out),
              background-color 160ms var(--ease),
              box-shadow 200ms var(--ease-out),
              border-color 160ms var(--ease);
}

/* Press feedback — buttons must feel like they heard the click (scale 0.95–0.98) */
.primary:active, .secondary:active, .ghost:active, .compose-btn:active,
.out-actions button:active, .cat-del:active { transform: scale(0.97); }
.tile:active { transform: scale(0.985); }

/* Transform-based hover only on real pointers (touch fires false hovers on tap) */
@media (hover: hover) and (pointer: fine) {
  .tile:hover { transform: translateY(-2px); }
}

/* Entrance: staggered rise (ease-out, <300ms, transform+opacity only) */
@media (prefers-reduced-motion: no-preference) {
  .content > *, .guest-main > .card {
    animation: ea-rise 260ms var(--ease-out) both;
  }
  .content > *:nth-child(2) { animation-delay: 40ms; }
  .content > *:nth-child(3) { animation-delay: 80ms; }
  .content > *:nth-child(4) { animation-delay: 120ms; }
  .content > *:nth-child(5) { animation-delay: 160ms; }
  .content > *:nth-child(n+6) { animation-delay: 200ms; }
  .flash { animation: ea-rise 200ms var(--ease-out) both; }
}

@keyframes ea-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Checkbox row + help tooltip + test result ---------- */
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 14px; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.help {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12px; font-weight: 700; cursor: help;
}
.result-grid { display: grid; gap: 14px; }
.result-grid > div { display: flex; flex-direction: column; gap: 3px; }
.rk { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }

/* ---------- Admin testing ---------- */
.profile-switcher {
  display: flex; align-items: end; gap: 10px; flex-wrap: wrap;
}
.profile-switcher label { min-width: 260px; margin-bottom: 0; }
.profile-switcher select { margin-top: 6px; }
.profile-form { margin-top: 14px; }
.testing-prompt {
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  white-space: pre;
}

/* ================================================================
   Phone layout (<= 560px): tighten chrome, keep wide tables usable,
   and let stacked headers wrap instead of squeezing.
   ================================================================ */
@media (max-width: 560px) {
  .topbar { padding: 0 14px; }
  .topbar-right { gap: 10px; }
  .who { display: none; }                 /* email crowds the bar on phones */
  .brand-logo { height: 26px; }
  .guest-logo { height: 44px; }

  .content { padding: 14px; }
  .card { padding: 18px 16px; }

  /* h2 + action button (e.g. "Copy prompt") stack/wrap instead of colliding */
  .output-head { flex-wrap: wrap; }
  .out-actions { flex-wrap: wrap; }

  .profile-switcher label { min-width: 0; width: 100%; }

  /* Wide tables scroll horizontally rather than breaking the layout. */
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .table .hint { white-space: normal; }   /* error rows still wrap */
}
