/* shared.css — loaded by both index.html and admin.html.

   Visual design: the StoryBox / TaleLight design system (night-navy
   gradient, translucent "glass" panels with hairline borders, warm-gold
   accent with navy text on filled buttons, parchment body text, blue-grey
   secondary text, Poppins). Dark only, like the siblings.

   The first token block is a VERBATIM copy of exmachina-storybox's
   firebase/public/shared.css :root (same names, same values) so the three
   products stay in sync -- change it there and here together.
   TalkieClockie's own additions come after it, in a separate block. */
:root {
  color-scheme: dark;              /* native controls (audio, select, date, scrollbars) render dark */

  /* TaleLight palette */
  --night-1: #0f1b2d;
  --night-2: #1a2a4a;
  --night-3: #0d1f35;
  --modal-bg: #16263f;
  --gold: #f4c97a;
  --gold-soft: rgba(244,201,122,0.14);
  --gold-line: rgba(244,201,122,0.4);
  --ink-1: #e8e0d0;                /* body text */
  --ink-soft: #b0c4de;             /* secondary text / outline button text */
  --ink-2: #8da8c8;                /* labels, meta */
  --ink-3: #6a84a0;                /* faint meta */
  --danger: #e07070;
  --danger-fill: #c0392b;          /* TaleLight record button */
  --success: #5cb87a;

  /* Semantic tokens used throughout the StoryBox CSS/JS */
  --accent: var(--gold);
  --accent-ink: var(--night-2);    /* text on gold */
  --accent-2: #a8c8f0;
  --card: rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.08);
  --bg-1: rgba(255,255,255,0.04);  /* inset panel */
  --bg-2: rgba(255,255,255,0.08);  /* hover / track */
  --item: rgba(255,255,255,0.05);  /* list rows */
  --item-border: rgba(255,255,255,0.1);
  --border: rgba(255,255,255,0.15);
  --field: rgba(255,255,255,0.07);
}

/* TalkieClockie additions (not in StoryBox). Measured WCAG contrast on the
   lightest surfaces used here (a field or row inside a card on --night-2):
   --ink-2 drops to 4.2:1 and --ink-3 to 2.6:1 there, and --danger to 3.3:1,
   so small text on nested surfaces uses these instead. --ink-3 is never
   used for text in this app (decorative only). */
:root {
  --ink-hint: #9ab4d2;             /* meta/placeholder text on nested surfaces: >= 4.8:1 */
  --danger-text: #f29b9b;          /* danger-coloured text on any surface: >= 4.8:1 */
  --success-soft: rgba(92,184,122,0.14);
  --focus-ring: var(--gold);       /* 2px ring: >= 6.5:1 against every surface */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--night-3); }   /* overscroll / below-the-fold canvas */
body {
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: linear-gradient(160deg, var(--night-1) 0%, var(--night-2) 50%, var(--night-3) 100%);
  min-height: 100vh;
  color: var(--ink-1);
}
h1, h2, h3 { font-weight: 600; }
button, input, select, textarea { font-family: 'Poppins', sans-serif; }
select option { background: var(--night-2); color: var(--ink-1); }

/* Visible keyboard focus everywhere (mouse clicks don't trigger it). */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; }

/* ── Header (TaleLight #app-header) ─────── */
#app-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;               /* StoryBox .topbar: 14px 20px, 64px logo */
  /* Opaque-ish so content scrolling under the sticky bar stays legible. */
  background: rgba(15,27,45,0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo { height: 64px; width: auto; flex-shrink: 0; display: block; }   /* was 40px; StoryBox topbar-logo is 64px */
.header-title {
  flex: 1;
  min-width: 0;                    /* allow it to shrink (ellipsis) instead of pushing the bar wider */
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gold);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-bar { display: flex; align-items: center; gap: 10px; flex-shrink: 1; min-width: 0; }
#user-avatar { width: 30px; height: 30px; border-radius: 50%; display: none; flex-shrink: 0; border: 1px solid var(--border); }
#user-name {
  font-size: 0.85rem; color: var(--ink-soft);
  min-width: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#signout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--ink-soft);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
#signout-btn:hover { background: var(--bg-2); color: var(--ink-1); }
/* Phones: the 390 px bar used to be 499 px wide (title + full name +
   avatar + Sign out, all nowrap). Drop the name (the avatar still shows
   who is signed in) and let the title ellipsize. */
@media (max-width: 560px) {
  #app-header { padding: 8px 12px; gap: 8px; }
  .header-logo { height: 48px; width: auto; }
  .header-title { font-size: 0.95rem; text-align: left; }
  #user-name { display: none; }
}

/* ── Login (TaleLight #login-screen) ───── */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 40px 20px;
}
#login-screen img { width: 150px; margin-bottom: 20px; }
#login-screen h1  { font-size: 2rem; color: var(--gold); margin-bottom: 8px; }
#login-screen p   { font-size: 1rem; color: var(--ink-2); margin-bottom: 32px; max-width: 320px; }
#login-spinner {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#login-spinner p { margin: 0; font-size: 0.95rem; color: var(--ink-2); }
/* TaleLight #google-signin-btn: white, soft shadow */
#google-signin-btn {
  display: flex; align-items: center; gap: 12px;
  background: #fff; color: #333;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem; font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  transition: opacity 0.2s, box-shadow 0.2s;
}
#google-signin-btn:hover { opacity: 0.92; box-shadow: 0 4px 18px rgba(0,0,0,0.4); }
#google-signin-btn img { width: 20px; height: 20px; margin: 0; }   /* margin: undo #login-screen img's logo spacing */
#login-error { color: var(--danger-text); margin-top: 14px; font-size: 0.9rem; }

/* ── Modal (TaleLight .modal-overlay / .modal-box) ── */
/* Markup is injected by showModal() in shared.js; the owner app's export
   overlay and the admin's Edit device / Edit recordings modals reuse it. */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 380px; width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  color: var(--ink-1);
}
.modal-box h3 { font-size: 1.05rem; color: var(--gold); margin-bottom: 10px; font-weight: 600; }
.modal-box p  { font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 20px; line-height: 1.45; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions button {
  padding: 9px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}
.modal-ok { background: var(--gold); color: var(--accent-ink); border: 1px solid transparent; font-weight: 600; transition: opacity 0.2s; }
.modal-ok:hover:not(:disabled) { opacity: 0.9; }
.modal-cancel {
  background: transparent; color: var(--ink-soft); border: 1px solid rgba(255,255,255,0.2);
  transition: background 0.2s;
}
.modal-cancel:hover { background: var(--bg-2); }
/* Destructive confirmations (language change wipes recordings): TaleLight red. */
.modal-ok.danger { background: var(--danger-fill); color: #fff; }

/* ── Spinner ────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Transient toast (TaleLight #toast) ── */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #16233f; border: 1px solid var(--border); color: var(--ink-1);
  padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px);
  font-size: 0.85rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; z-index: 300;
  /* t_671ae4b7: same feel as the activation status line: ease-out in, a
     quicker ease-in out; reduced motion = fade only */
  transition: opacity 0.24s ease-in, transform 0.24s ease-in;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); transition: opacity 0.3s cubic-bezier(.2,.7,.3,1), transform 0.3s cubic-bezier(.2,.7,.3,1); }
@media (prefers-reduced-motion: reduce) {
  #toast, #toast.show { transform: translateX(-50%); }
}

/* "Last synced: 3 h ago" (owner device summary + admin rows/edit panel) */
.last-synced-when { border-bottom: 1px dotted var(--ink-2); cursor: help; }
.last-synced-never { color: var(--ink-2); }
