/* ============================================================
   Home Core — Camada AI-first (2026-09-05).
   Sobrescreve variaveis + adiciona atmosfera espacial + glassmorphism.
   Nao mexe em markup nem em class names existentes.
   ============================================================ */

:root {
  /* Palette AI: deep space + neon cyan/violet + subtle mint */
  --bg: #05070d;
  --bg-top: #080b17;
  --bg-deep: #030410;
  --panel: rgba(14, 20, 36, 0.75);
  --panel-2: rgba(20, 28, 48, 0.6);
  --panel-glass: rgba(18, 25, 44, 0.55);
  --panel-solid: #0e1424;
  --line: rgba(140, 200, 255, 0.08);
  --line-strong: rgba(140, 200, 255, 0.18);
  --text: #e8eefc;
  --text-bright: #ffffff;
  --muted: #7d8ba8;
  --muted-2: #5c6a86;

  --neon-cyan: #22d3ee;
  --neon-cyan-soft: rgba(34, 211, 238, 0.16);
  --neon-violet: #a78bfa;
  --neon-violet-soft: rgba(167, 139, 250, 0.18);
  --neon-pink: #f472b6;
  --neon-mint: #6ee7b7;
  --neon-amber: #fbbf24;

  --blue: var(--neon-cyan);
  --blue-dark: #06b6d4;
  --green: var(--neon-mint);
  --ok: var(--neon-mint);
  --ok-text: #a7f3d0;
  --tint-ok: rgba(110, 231, 183, 0.1);
  --warn-text: var(--neon-amber);
  --tint-warn: rgba(251, 191, 36, 0.1);
  --danger-text: #fca5a5;
  --danger-line: rgba(252, 165, 165, 0.4);
  --tint-danger: rgba(252, 165, 165, 0.08);
  --info-text: var(--neon-cyan);
  --tint-info: rgba(34, 211, 238, 0.08);
  --tint-info-strong: rgba(34, 211, 238, 0.16);
  --shell-text: var(--text);
  --shell-bright: var(--text-bright);
  --shell-muted: var(--muted);
  --shell-muted-2: var(--muted-2);

  --card-bg: var(--panel);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--line);
  --shadow-glow: 0 0 40px var(--neon-cyan-soft), 0 24px 60px rgba(0, 0, 0, 0.5);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  color-scheme: dark;
}

/* --- BACKGROUND: fundo calmo, escuro e uniforme com micro-brilho ---- */

body {
  background:
    radial-gradient(1400px 900px at 50% -10%, rgba(34, 211, 238, 0.05), transparent 65%),
    linear-gradient(180deg, #060812 0%, #04060f 60%, #030510 100%);
  background-attachment: fixed;
  color: var(--text);
  font-feature-settings: "ss01", "cv11";
  position: relative;
}

/* Ambos os pseudo-elementos removidos — sem dot grid, sem aurora. Apenas
   uma vinheta muito subtil nas beiras para dar profundidade ao vidro. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
  z-index: 0;
}

#root { position: relative; z-index: 1; }

/* --- TYPOGRAPHY ---------------------------------------------------- */

body, input, button, textarea, select {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.005em;
}

h1, h2, h3, .brand, strong.brand, .alex-brand strong {
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -0.02em;
  color: var(--text-bright);
}

h1 { font-weight: 600; }
h2 { font-weight: 600; letter-spacing: -0.03em; }

.muted, small.muted { color: var(--muted); }

/* --- GLASS 3D: cards de vidro grosso, com refracção, altura e brilho de aresta */

.hub-card, .card, .panel, .alex-panel, .alex-chat-panel, .alex-side-panel,
.hero-panel, .device-card, .camera-card, .event-card, .document-card,
.folder-card, .stat-card, .automation-panel, .files-panel, .devices-panel,
.cameras-panel, .agenda-panel, .access-panel, .boot-card,
.alex-summary-card, .alex-orb-panel, .alex-status-strip, .person-card {
  /* Vidro grosso: base semi-transparente + blur pesado + saturação para
     apanhar cor de fundo (ainda que fundo seja quase preto, dá vida). */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.015) 100%),
    rgba(14, 20, 36, 0.35);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-lg);
  color: var(--text);
  position: relative;
  /* Sombra dupla: near shadow (contacto) + far shadow (levitação) + ring escuro */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 20px 40px rgba(0, 0, 0, 0.45),
    0 40px 80px rgba(0, 0, 0, 0.35);
  transition: transform 320ms cubic-bezier(0.2, 0.7, 0.2, 1),
              box-shadow 320ms cubic-bezier(0.2, 0.7, 0.2, 1),
              border-color 240ms;
  overflow: hidden;
}

/* Reflexo/highlight superior tipo aresta de vidro */
.hub-card::after, .card::after, .panel::after, .alex-panel::after,
.hero-panel::after, .device-card::after, .camera-card::after,
.event-card::after, .document-card::after, .folder-card::after,
.stat-card::after, .automation-panel::after, .person-card::after,
.alex-summary-card::after, .alex-orb-panel::after, .alex-chat-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 120% 50% at 50% -20%, rgba(255, 255, 255, 0.09), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* Todo o conteúdo do card fica acima do reflexo */
.hub-card > *, .card > *, .panel > *, .alex-panel > *, .hero-panel > *,
.device-card > *, .camera-card > *, .event-card > *, .document-card > *,
.folder-card > *, .stat-card > *, .automation-panel > *, .person-card > *,
.alex-summary-card > *, .alex-orb-panel > *, .alex-chat-panel > * {
  position: relative;
  z-index: 1;
}

.hub-card:hover, .device-card:hover, .camera-card:hover, .event-card:hover,
.document-card:hover, .folder-card:hover, .stat-card:hover, .person-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.4),
    0 30px 60px rgba(0, 0, 0, 0.55),
    0 60px 100px rgba(0, 0, 0, 0.4);
}

/* Painéis grandes (hero, alex chat, orb) ganham aresta gradiente cyan/violeta subtil */
.hero-panel, .alex-orb-panel, .alex-chat-panel {
  border-color: transparent;
}
.hero-panel::before, .alex-orb-panel::before, .alex-chat-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg,
    rgba(34, 211, 238, 0.35) 0%,
    rgba(255, 255, 255, 0.08) 40%,
    rgba(167, 139, 250, 0.35) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}

/* --- BUTTONS ------------------------------------------------------- */

button, .button, [role="button"] {
  font-family: inherit;
  transition: transform 160ms, box-shadow 240ms, background 240ms, border-color 240ms, color 240ms;
}

button:not(.alex-orb):not(.hero-orb):not(.top-mic):not(.sidebar-user):not(.mobile-alerts):not(.intent-chip):not(.user-pill) {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.12), rgba(34, 211, 238, 0.03));
  color: var(--text-bright);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

button:not(.alex-orb):not(.hero-orb):not(.top-mic):not(.sidebar-user):not(.mobile-alerts):not(.intent-chip):not(.user-pill):hover {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.22), rgba(34, 211, 238, 0.08));
  border-color: var(--neon-cyan);
  box-shadow: 0 0 18px var(--neon-cyan-soft), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

button:disabled, button[disabled] {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Botao primary (submit) - realca */
button[type="submit"] {
  background: linear-gradient(180deg, var(--neon-cyan), var(--blue-dark)) !important;
  color: #001018 !important;
  font-weight: 600 !important;
  border: 0 !important;
  box-shadow: 0 6px 20px rgba(34, 211, 238, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}
button[type="submit"]:hover {
  box-shadow: 0 8px 28px rgba(34, 211, 238, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  filter: brightness(1.08);
}

/* Intent chips (perguntas sugeridas) */
.intent-chip {
  background: rgba(167, 139, 250, 0.08) !important;
  border: 1px solid rgba(167, 139, 250, 0.25) !important;
  color: var(--text-bright) !important;
  border-radius: 999px !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
}
.intent-chip:hover {
  background: rgba(167, 139, 250, 0.18) !important;
  border-color: var(--neon-violet) !important;
  box-shadow: 0 0 16px var(--neon-violet-soft);
}

/* --- INPUTS -------------------------------------------------------- */

input:not([type="checkbox"]):not([type="radio"]), textarea, select {
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: var(--radius-md) !important;
  color: var(--text-bright) !important;
  padding: 10px 14px !important;
  font-family: inherit !important;
  transition: border-color 200ms, box-shadow 200ms, background 200ms;
}
input:not([type="checkbox"]):not([type="radio"]):focus, textarea:focus, select:focus {
  outline: none !important;
  border-color: var(--neon-cyan) !important;
  box-shadow: 0 0 0 3px var(--neon-cyan-soft) !important;
  background: rgba(34, 211, 238, 0.03) !important;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }

/* --- SHELL / NAVIGATION -------------------------------------------- */

.app-shell {
  background: transparent !important;
}
.sidebar, .alex-desktop-shell aside, .alex-desktop-shell nav {
  background: var(--panel) !important;
  backdrop-filter: blur(24px) saturate(150%);
  border-right: 1px solid var(--line);
}

.bottom-nav {
  background: rgba(5, 7, 13, 0.85) !important;
  backdrop-filter: blur(24px) saturate(150%);
  border-top: 1px solid var(--line);
}
.bottom-nav button.active, .bottom-nav .active {
  color: var(--neon-cyan) !important;
  text-shadow: 0 0 12px var(--neon-cyan-soft);
}

/* --- ALEX ORB (icone principal do assistente) ---------------------- */

.alex-orb, .hero-orb, .auth-orb, .boot-orb {
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.4), transparent 40%),
    radial-gradient(circle at 50% 50%, var(--neon-cyan) 0%, var(--neon-violet) 60%, #1a1a3a 100%) !important;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
    0 0 30px var(--neon-cyan-soft),
    0 0 60px var(--neon-violet-soft),
    0 20px 40px rgba(0, 0, 0, 0.5) !important;
  position: relative;
  overflow: visible !important;
  animation: orbBreath 4s ease-in-out infinite;
}
.alex-orb::before, .hero-orb::before, .auth-orb::before, .boot-orb::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--neon-cyan-soft) 0%, transparent 70%);
  filter: blur(20px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.7;
  animation: orbHalo 4s ease-in-out infinite;
}
.alex-orb.listening, .hero-orb.listening {
  animation: orbBreath 1.2s ease-in-out infinite !important;
  box-shadow:
    0 0 0 2px var(--neon-cyan) inset,
    0 0 40px var(--neon-cyan),
    0 0 80px var(--neon-violet-soft),
    0 20px 40px rgba(0, 0, 0, 0.5) !important;
}
.alex-orb.convo {
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.5), transparent 40%),
    radial-gradient(circle at 50% 50%, var(--neon-pink) 0%, var(--neon-violet) 60%, #1a1a3a 100%) !important;
}

@keyframes orbBreath {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.04); filter: brightness(1.15); }
}
@keyframes orbHalo {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.15); }
}

/* --- BOOT SCREEN --------------------------------------------------- */

.boot-screen {
  background:
    radial-gradient(1200px 800px at 50% 50%, rgba(34, 211, 238, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-top), var(--bg-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.boot-stage {
  text-align: center;
  color: var(--text-bright);
}
.boot-stage strong {
  display: block;
  margin: 24px 0 8px;
  font-family: "Space Grotesk";
  font-size: 28px;
  letter-spacing: 0.16em;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.boot-stage small {
  color: var(--muted);
  letter-spacing: 0.08em;
  font-size: 12px;
  text-transform: uppercase;
}

/* --- TRANSCRIPT (conversa Alex) ----------------------------------- */

.alex-transcript {
  background: rgba(0, 0, 0, 0.2) !important;
  border-radius: var(--radius-lg);
  padding: 16px !important;
}
.alex-message {
  background: rgba(255, 255, 255, 0.03) !important;
  border-radius: var(--radius-md) !important;
  padding: 12px 14px !important;
  margin-bottom: 8px !important;
  border: 1px solid var(--line);
}
.alex-message.user {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.08), rgba(34, 211, 238, 0.02)) !important;
  border-color: rgba(34, 211, 238, 0.2);
}
.alex-message.alex, .alex-message.assistant {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.08), rgba(167, 139, 250, 0.02)) !important;
  border-color: rgba(167, 139, 250, 0.2);
}
.alex-message strong {
  color: var(--neon-cyan);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.12em;
  display: block;
  margin-bottom: 4px;
}
.alex-message.alex strong, .alex-message.assistant strong {
  color: var(--neon-violet);
}
.alex-message p { color: var(--text-bright); margin: 0; }

/* --- STATUS INDICATORS / BADGES ------------------------------------ */

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--neon-mint);
  box-shadow: 0 0 8px var(--neon-mint);
  animation: pulseGreen 2s ease-in-out infinite;
}
.status-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
  animation: none;
}
@keyframes pulseGreen {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Chip generico (badges de estado) */
.chip, .badge, .tag {
  padding: 3px 10px !important;
  border-radius: 999px !important;
  font-size: 11px !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--line-strong) !important;
  color: var(--text) !important;
}

/* --- STAT CARDS (dashboard mini KPIs) ------------------------------ */

.stat-card {
  padding: 16px !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat-card strong {
  font-family: "Space Grotesk";
  font-size: 28px;
  font-weight: 600;
  background: linear-gradient(180deg, var(--text-bright), var(--neon-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --- MODIFICADORES DE COR (semanticos) ----------------------------- */

.text-ok, .ok-text { color: var(--ok-text) !important; }
.text-warn, .warn-text { color: var(--warn-text) !important; }
.text-danger, .danger-text { color: var(--danger-text) !important; }
.text-info, .info-text { color: var(--info-text) !important; }

/* --- SECTION HEADINGS --------------------------------------------- */

.section-head h2 {
  font-size: 24px;
  margin: 0;
}
.section-head .muted {
  font-size: 13px;
}

/* --- SCROLLBARS ---------------------------------------------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(140, 200, 255, 0.2) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(140, 200, 255, 0.15);
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(140, 200, 255, 0.3); }

/* --- MINI-PLAYER YOUTUBE (Alex musica) ---------------------------- */

#alex-music-player {
  border: 1px solid var(--line-strong) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 30px var(--neon-violet-soft) !important;
  animation: fadeSlideUp 300ms ease;
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- ALEX ADMIN PANELS (memoria + conversas) ----------------------- */

.alex-admin {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  backdrop-filter: blur(20px) saturate(140%);
}
.alex-admin h3 {
  font-family: "Space Grotesk";
  color: var(--text-bright);
}
.alex-admin textarea {
  background: rgba(0, 0, 0, 0.35) !important;
  color: #a5f3fc !important;
  font-family: "JetBrains Mono", "Fira Code", monospace !important;
  border-color: var(--line-strong) !important;
}
.alex-admin details {
  background: rgba(255, 255, 255, 0.02) !important;
  border-color: var(--line) !important;
}
.alex-admin summary { color: var(--text-bright); }

/* --- PERSON CARDS (familia): estilos exclusivos alem do glass base */
.person-card strong { color: var(--text-bright); font-family: "Space Grotesk"; }
.person-card small { color: var(--muted); }

/* --- LINKS --------------------------------------------------------- */

a {
  color: var(--neon-cyan);
  text-decoration: none;
  transition: color 160ms, text-shadow 200ms;
}
a:hover { color: #67e8f9; text-shadow: 0 0 8px var(--neon-cyan-soft); }

/* --- CODE / MONO --------------------------------------------------- */

code, kbd, pre {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 6px;
  border-radius: 4px;
  color: #a5f3fc;
  font-size: 0.9em;
}
pre { padding: 12px; border-radius: var(--radius-md); overflow-x: auto; }

/* --- HUB GRID ------------------------------------------------------ */

.hub-grid, .alex-summary-grid {
  gap: 14px !important;
}

/* --- SEPARADORES SUBTIS -------------------------------------------- */

hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
  margin: 20px 0;
}

/* --- FOCUS RING GLOBAL (acessibilidade) ---------------------------- */

*:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- REDUZIR MOTION quando pedido ---------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   RESPONSIVIDADE — smartphone, tablet, desktop, TV
   Breakpoints:
     ≤480px  small phone
     ≤768px  large phone / small tablet portrait
     ≤1024px tablet landscape / netbook
     ≤1440px desktop normal
     >1440px large desktop / TV 4K
   ============================================================ */

/* --- Tipografia fluida (escala com o viewport) -------------------- */

h1 { font-size: clamp(20px, 2.4vw + 8px, 32px); }
h2 { font-size: clamp(18px, 1.8vw + 8px, 24px); }
h3 { font-size: clamp(15px, 1vw + 8px, 18px); }
body { font-size: clamp(14px, 0.3vw + 12px, 16px); }
.muted, small { font-size: clamp(11px, 0.2vw + 10px, 13px); }

.stat-card strong { font-size: clamp(20px, 2vw + 12px, 32px); }
.stat-card small { font-size: clamp(10px, 0.15vw + 9px, 12px); }

.section-head h2 { font-size: clamp(18px, 1.5vw + 10px, 26px); }

/* --- Boot screen escala --------------------------------------------- */
.boot-stage strong { font-size: clamp(20px, 2vw + 12px, 32px); }

/* --- Touch targets em mobile (min 44px como o Apple recomenda) ---- */

@media (hover: none) and (pointer: coarse) {
  button:not(.alex-orb):not(.hero-orb):not(.intent-chip):not(.user-pill),
  a.button, [role="button"] {
    min-height: 44px;
    padding: 12px 16px !important;
    font-size: 15px !important;
  }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    min-height: 44px !important;
    padding: 12px 14px !important;
    font-size: 16px !important; /* iOS não faz zoom se >=16px */
  }
  .intent-chip {
    min-height: 36px;
    padding: 8px 16px !important;
  }
}

/* --- SMALL PHONE (≤480px): 1 coluna, padding compacto, blur leve --- */

@media (max-width: 480px) {
  .hub-card, .card, .panel, .alex-panel, .alex-chat-panel, .alex-side-panel,
  .hero-panel, .device-card, .camera-card, .event-card, .document-card,
  .folder-card, .stat-card, .person-card, .alex-admin {
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-radius: 14px;
  }
  .hub-card, .card, .panel, .alex-panel, .alex-admin {
    padding: 12px !important;
  }
  .hub-grid, .alex-summary-grid,
  [style*="grid-template-columns:repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .section-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .alex-voice-actions {
    flex-wrap: wrap;
    gap: 6px !important;
  }
  .alex-voice-actions button { flex: 1 1 45%; }
  #alex-music-player {
    right: 8px !important;
    bottom: 8px !important;
    width: calc(100vw - 16px) !important;
    max-width: 380px !important;
  }
  #alex-music-player iframe,
  #alex-music-player > div:last-child {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    height: auto !important;
  }
  .alex-transcript { padding: 10px !important; max-height: 50vh; overflow-y: auto; }
  .boot-stage .auth-orb { transform: scale(0.85); }
}

/* --- LARGE PHONE / SMALL TABLET (481-768px): 2 cols em cartoes --- */

@media (min-width: 481px) and (max-width: 768px) {
  .hub-card, .card, .panel, .alex-panel {
    padding: 14px !important;
    backdrop-filter: blur(22px) saturate(170%);
    -webkit-backdrop-filter: blur(22px) saturate(170%);
  }
  .hub-grid, .alex-summary-grid,
  [style*="grid-template-columns:repeat(auto-fit,minmax(180px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  #alex-music-player {
    width: 320px !important;
  }
  #alex-music-player iframe,
  #alex-music-player > div:last-child {
    width: 320px !important;
    height: 180px !important;
  }
}

/* --- TABLET LANDSCAPE (769-1024px): 3 cols em cartoes ------------ */

@media (min-width: 769px) and (max-width: 1024px) {
  .hub-grid, .alex-summary-grid,
  [style*="grid-template-columns:repeat(auto-fit,minmax(180px"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .alex-page {
    display: block !important;
  }
}

/* --- DESKTOP NORMAL (1025-1440px): 4 cols em cartoes ------------- */

@media (min-width: 1025px) and (max-width: 1440px) {
  .hub-grid, .alex-summary-grid,
  [style*="grid-template-columns:repeat(auto-fit,minmax(180px"] {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* --- LARGE DESKTOP / TV (>1440px): limitar largura para nao esticar */

@media (min-width: 1441px) {
  .app-shell > main, .alex-page, .alex-dashboard,
  .section-head, .hub-grid, .alex-transcript {
    max-width: 1500px;
    margin-left: auto;
    margin-right: auto;
  }
  .hub-grid, .alex-summary-grid {
    grid-template-columns: repeat(5, 1fr) !important;
  }
  /* Cards ganham mais respiro em ecrãs enormes */
  .hub-card, .card, .panel, .alex-panel {
    padding: 20px !important;
  }
}

/* --- ULTRAWIDE / 4K TV (>2000px): tipografia sobe -------------- */

@media (min-width: 2000px) {
  body { font-size: 18px; }
  h1 { font-size: 40px; }
  h2 { font-size: 32px; }
  .stat-card strong { font-size: 42px; }
  .alex-orb, .hero-orb { transform: scale(1.2); }
}

/* --- Landscape em telemovel (barra baixa): cortar sombras enormes */

@media (max-height: 500px) and (orientation: landscape) {
  .alex-transcript { max-height: 40vh; }
  .boot-stage strong { font-size: 20px; margin: 12px 0 4px; }
  #alex-music-player { max-height: 200px; }
  #alex-music-player iframe {
    max-height: 130px;
  }
}

/* --- Textarea e editor da memoria em qualquer ecrã ------------- */

.alex-admin textarea {
  min-height: 200px !important;
  max-height: 60vh;
  width: 100%;
  box-sizing: border-box;
}

/* --- Impedir overflow horizontal geral ----------------------------- */

html, body { overflow-x: hidden; max-width: 100vw; }
.hub-grid, .alex-summary-grid, .section-head { min-width: 0; }
img, video, iframe { max-width: 100%; height: auto; }

/* --- MONITOR MODE em ecrã portrait (telemóvel/tablet) ---------------
   O modo monitor foi desenhado para ecrã grande de parede: em portrait
   tudo estava a ficar encostado à direita e a cortar texto.              */

@media (max-width: 900px) and (orientation: portrait) {
  /* A grelha do monitor-scene tinha padding 44px lateral e 3 rows.
     Em portrait: 1 coluna, padding pequeno, tudo centrado. */
  .monitor-shell { overflow-x: hidden !important; }
  .monitor-scene {
    padding: 16px 12px !important;
    grid-template-rows: auto 1fr auto !important;
    gap: 12px !important;
    min-height: 100vh !important;
    width: 100vw !important;
    box-sizing: border-box !important;
  }
  /* Top row: relógio + botões ambient empilhados em coluna */
  .monitor-top {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: center !important;
    gap: 8px !important;
  }
  .monitor-clock strong { font-size: clamp(48px, 15vw, 88px) !important; text-align: center; }
  .monitor-clock span { text-align: center; }
  .monitor-ambient {
    flex-wrap: wrap;
    justify-content: center !important;
  }
  /* Center row: orb centrada + texto que quebra dentro da viewport */
  .monitor-center {
    justify-items: center !important;
    text-align: center !important;
    padding: 0 4px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  #hubOrb, .monitor-orb {
    width: clamp(160px, 50vw, 240px) !important;
    height: clamp(160px, 50vw, 240px) !important;
    margin: 8px auto !important;
    position: static !important;
    transform: none !important;
    flex-shrink: 0 !important;
  }
  .monitor-reply, .monitor-hint {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 8px !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-wrap: break-word !important;
    text-align: center !important;
    box-sizing: border-box !important;
    font-size: clamp(13px, 3.2vw, 16px) !important;
    line-height: 1.45 !important;
  }
  /* Dock inferior: 4 ou 5 tiles em grid fixa que cabe no ecrã */
  .monitor-dock {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 0 !important;
  }
  .monitor-dock button {
    padding: 12px 6px !important;
    font-size: 12px !important;
    flex-direction: column !important;
    min-height: 64px !important;
  }
  .monitor-dock button svg { width: 22px; height: 22px; }
  /* Panel aberto (câmara, agenda, meteo, fotos) ocupa toda a largura */
  .monitor-panel {
    padding: 16px 12px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
}

/* --- MONITOR MODE em ecrã landscape pequeno (telemóvel deitado) ---- */

@media (max-width: 900px) and (orientation: landscape) {
  #hubOrb, .monitor-orb {
    width: clamp(120px, 30vh, 200px) !important;
    height: clamp(120px, 30vh, 200px) !important;
    margin: 12px auto !important;
  }
  .monitor-clock, .monitor-time {
    font-size: clamp(32px, 8vw, 64px) !important;
  }
}

/* --- Density mode: quando o utilizador tem "espaço apertado" -------- */

@media (max-width: 380px) {
  .app-shell { padding: 8px !important; }
  .alex-message { padding: 8px 10px !important; }
  .alex-message p { font-size: 14px; }
  #alex-music-player > div:first-child button { padding: 0 3px !important; font-size: 16px !important; }
}
