/* ── phone-tv/frontend/styles.css — HuddleDrive brand tokens ─────────────── */

/* Premium UI contract: white/navy/yellow palette, 390px phone target */

:root {
  --color-white:        #FFF;
  --color-soft-white:   #F5F6F7;
  --color-navy:         #142134;
  --color-slate:        #253142;
  --color-secondary:    #566171;
  --color-yellow:       #D7FF3F;
  --color-muted:        #566171;
  --color-error:        #B00020;

  --radius:             8px;
  --maxw:               460px;
  --focus-ring:         3px solid var(--color-navy);
  --focus-ring-light:   3px solid var(--color-yellow);
  --font-sans:          system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--color-soft-white);
  color: var(--color-navy);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--color-soft-white); }
::-webkit-scrollbar-thumb { background: var(--color-secondary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-slate); }
* { scrollbar-width: thin; scrollbar-color: var(--color-secondary) var(--color-soft-white); }

/* Skip link */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  color: var(--color-white); background: var(--color-navy);
  padding: 0.5rem 1rem; border-radius: var(--radius); z-index: 100;
}
.skip-link:focus { left: 0; top: 0; outline: var(--focus-ring-light); }

/* ── Nav ──────────────────────────────────────────────────────────────────── */

nav {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
}

#brand-link {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-navy);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#brand-link img {
  width: 24px; height: 24px;
}

/* ── Panel ────────────────────────────────────────────────────────────────── */

.panel {
  width: 100%;
  max-width: var(--maxw);
  background: var(--color-white);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: 0 2px 8px rgba(20, 33, 52, 0.08);
}

.panel h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 0.5rem;
}

.panel h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 0.5rem;
}

.panel > p {
  font-size: 0.9375rem;
  color: var(--color-secondary);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: 0.35rem;
}

input {
  display: block;
  width: 100%;
  padding: 0.75rem 0.875rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  color: var(--color-navy);
  background: var(--color-white);
  border: 1px solid #D0D5DB;
  border-radius: var(--radius);
  margin-bottom: 0.35rem;
  min-height: 44px;
}

input::placeholder { color: var(--color-secondary); opacity: 0.7; }

input:focus {
  outline: none;
  border-color: var(--color-navy);
  box-shadow: 0 0 0 3px rgba(215, 255, 63, 0.35);
}

input[aria-invalid="true"] {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(176, 0, 32, 0.12);
}

input[type="tel"], input[inputmode="numeric"] {
  text-align: center;
  letter-spacing: 0.1em;
}

.hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-secondary);
  margin-bottom: 1rem;
  margin-top: -0.5rem;
}

.error {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-error);
  margin-bottom: 0.5rem;
  min-height: 1.2em;
}

#form-errors {
  font-size: 0.875rem;
  color: var(--color-error);
  margin-bottom: 1rem;
  min-height: 1.2em;
  font-weight: 600;
}

/* ── Buttons (44px min) ──────────────────────────────────────────────────── */

button, .btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  border: none;
  gap: 0.5rem;
}

.btn-primary {
  width: 100%;
  background: var(--color-navy);
  color: var(--color-white);
}

.btn-primary:hover { background: var(--color-slate); }

.btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-light);
}

.btn-primary:disabled, .btn-ghost:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-ghost {
  background: transparent;
  color: var(--color-navy);
  border: 1px solid #D0D5DB;
  flex: 1;
}

.btn-ghost:hover { background: var(--color-soft-white); }

.btn-ghost:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-light);
}

#phone-alt-actions, #settings-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ── Status messages ──────────────────────────────────────────────────────── */

#status-message, #status-message-tv, .tv-status {
  font-size: 0.875rem;
  color: var(--color-navy);
  margin-top: 1rem;
  min-height: 1.5em;
}

.tv-status {
  color: var(--color-secondary);
  font-style: normal;
  margin-top: 0.5rem;
}

/* ── Settings area ────────────────────────────────────────────────────────── */

#settings-area {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

#settings-area button, #settings-actions button {
  flex: 1;
}

/* ── Devices list ─────────────────────────────────────────────────────────── */

#devices-area {
  margin: 1rem 0;
  min-height: 2em;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border: 1px solid #D0D5DB;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.device-item .device-info { flex: 1; }
.device-item .device-name { font-weight: 600; color: var(--color-navy); }
.device-item .device-meta { color: var(--color-secondary); font-size: 0.75rem; margin-top: 2px; }

.device-item .btn-revoke {
  background: transparent;
  color: var(--color-error);
  border: 1px solid var(--color-error);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  min-height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  white-space: nowrap;
}

.device-item .btn-revoke:hover { background: var(--color-error); color: var(--color-white); }

.devices-empty {
  font-size: 0.875rem;
  color: var(--color-secondary);
  padding: 0.75rem;
  text-align: center;
}

.devices-error {
  font-size: 0.875rem;
  color: var(--color-error);
  padding: 0.75rem;
  text-align: center;
}

/* ── Activate TV code ─────────────────────────────────────────────────────── */

#user-code-input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.25em;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--color-white);
  border: 2px solid var(--color-navy);
  border-radius: var(--radius);
  padding: 1rem;
}

/* ── [hidden] ─────────────────────────────────────────────────────────────── */

[hidden] { display: none !important; }

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--color-navy);
  color: var(--color-white);
  border-radius: var(--radius);
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(20, 33, 52, 0.2);
  white-space: nowrap;
}

.toast.error { background: var(--color-error); }

/* ── Loading spinner ──────────────────────────────────────────────────────── */

.btn-primary[disabled]::after, .btn-ghost[disabled]::after {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 0.5rem;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }
