/* ═══════════════════════════════════════════════════════════════════════════
 * AYA Command Center — Mobile-First Foundation v1.0
 * Sprint 3 (30-Abr-2026)
 *
 * PARADIGMA: Mobile-first com breakpoints crescentes (min-width).
 * Substitui (no longo prazo) aya-mobile.css que era desktop-first.
 *
 * BREAKPOINTS:
 *   Base (mobile)   → 0-479px
 *   @small          → ≥480px   (phones landscape)
 *   @tablet         → ≥768px   (iPad portrait)
 *   @desktop        → ≥1024px  (iPad landscape, laptops 13")
 *   @wide           → ≥1440px  (desktop wide)
 *
 * CARREGAR DEPOIS de aya-typography.css.
 * Não altera aya-mobile.css (mantida como deprecated layer).
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────────────────
 * 1. DESIGN TOKENS (CSS custom properties)
 * ─────────────────────────────────────────────────────────────────────────── */
:root {
  /* Spacing scale (4px base) */
  --aya-space-1: 4px;
  --aya-space-2: 8px;
  --aya-space-3: 12px;
  --aya-space-4: 16px;
  --aya-space-5: 24px;
  --aya-space-6: 32px;
  --aya-space-7: 48px;
  --aya-space-8: 64px;

  /* Touch (Apple HIG + Material) */
  --aya-touch-min: 44px;

  /* Layout — mobile defaults */
  --aya-sidebar-w: 0px;              /* hidden, drawer mode */
  --aya-content-pad: 12px;
  --aya-content-max: 100%;

  /* Radii */
  --aya-radius-sm: 6px;
  --aya-radius-md: 10px;
  --aya-radius-lg: 14px;
  --aya-radius-xl: 18px;

  /* Z-index escalonado */
  --aya-z-sidebar: 100;
  --aya-z-backdrop: 90;
  --aya-z-modal: 200;
  --aya-z-toast: 300;

  /* Transição base */
  --aya-transition: 0.25s ease;

  /* Drawer */
  --aya-drawer-w: 280px;
}

/* @small */
@media (min-width: 480px) {
  :root {
    --aya-content-pad: 16px;
  }
}

/* @tablet — sidebar volta a aparecer (collapsed) */
@media (min-width: 768px) {
  :root {
    --aya-sidebar-w: 64px;
    --aya-content-pad: 20px;
    --aya-content-max: 100%;
  }
}

/* @desktop — sidebar full */
@media (min-width: 1024px) {
  :root {
    --aya-sidebar-w: 220px;
    --aya-content-pad: 24px;
  }
}

/* @wide — content centrado */
@media (min-width: 1440px) {
  :root {
    --aya-content-max: 1500px;
  }
}

/* ───────────────────────────────────────────────────────────────────────────
 * 2. RESET MOBILE-FIRST (additive — não destrói existente)
 * ─────────────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* iOS notch */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Imagens fluidas (nunca rebentam containers) */
img, svg, video, canvas, iframe {
  max-width: 100%;
  height: auto;
}

/* ───────────────────────────────────────────────────────────────────────────
 * 3. APP SHELL (mobile-first)
 * ─────────────────────────────────────────────────────────────────────────── */

/* App container — sem sidebar em mobile */
.aya-app {
  min-height: 100vh;
  min-height: 100dvh;             /* dynamic viewport p/ Safari iOS */
  display: flex;
  flex-direction: column;
}

/* Header mobile (com hamburger) */
.aya-topbar {
  position: sticky;
  top: 0;
  z-index: var(--aya-z-sidebar);
  display: flex;
  align-items: center;
  gap: var(--aya-space-3);
  padding: var(--aya-space-3) var(--aya-content-pad);
  background: var(--surface, #0f1119);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  min-height: 56px;
}
.aya-topbar__brand {
  font-weight: 700;
  font-size: 1rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aya-topbar__hamburger {
  width: var(--aya-touch-min);
  height: var(--aya-touch-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: var(--aya-radius-sm);
  color: inherit;
  cursor: pointer;
}

/* Esconde topbar (incl. hamburger) em desktop — sidebar é fixa */
@media (min-width: 1024px) {
  .aya-topbar { display: none; }
}

/* ───────────────────────────────────────────────────────────────────────────
 * 4. SIDEBAR / DRAWER
 *    Mobile: drawer overlay (escondido por default)
 *    Tablet: sidebar 64px (icon-only)
 *    Desktop: sidebar 220px (full)
 * ─────────────────────────────────────────────────────────────────────────── */
.aya-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--aya-drawer-w);
  max-width: 85vw;
  background: var(--surface, #0f1119);
  border-right: 1px solid var(--border, rgba(255,255,255,0.08));
  transform: translateX(-100%);
  transition: transform var(--aya-transition);
  z-index: var(--aya-z-sidebar);
  overflow-y: auto;
  padding: var(--aya-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--aya-space-2);
}

/* Sidebar aberta (controlada por JS via .is-open) */
.aya-sidebar.is-open {
  transform: translateX(0);
}

/* Backdrop — só visível em mobile/tablet quando drawer open */
.aya-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--aya-z-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--aya-transition);
}
.aya-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Tablet: sidebar fixa colapsada (64px icons) */
@media (min-width: 768px) {
  .aya-sidebar {
    transform: translateX(0);
    width: var(--aya-sidebar-w);
    max-width: var(--aya-sidebar-w);
    transition: width var(--aya-transition);
  }
  .aya-sidebar.is-expanded {
    width: var(--aya-drawer-w);
  }
  .aya-backdrop { display: none; }
  .aya-sidebar__label {
    display: none;
  }
  .aya-sidebar.is-expanded .aya-sidebar__label {
    display: inline;
  }
}

/* Desktop: sidebar 220px full sempre */
@media (min-width: 1024px) {
  .aya-sidebar {
    width: var(--aya-sidebar-w);
    max-width: var(--aya-sidebar-w);
  }
  .aya-sidebar__label { display: inline !important; }
}

/* Items da sidebar */
.aya-sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--aya-space-3);
  padding: var(--aya-space-3) var(--aya-space-4);
  border-radius: var(--aya-radius-sm);
  color: inherit;
  text-decoration: none;
  min-height: var(--aya-touch-min);
  transition: background var(--aya-transition);
}
.aya-sidebar__item:hover,
.aya-sidebar__item.is-active {
  background: rgba(124, 58, 237, 0.15);
}

/* ───────────────────────────────────────────────────────────────────────────
 * 5. MAIN CONTENT
 * ─────────────────────────────────────────────────────────────────────────── */
.aya-main {
  flex: 1;
  padding: var(--aya-content-pad);
  max-width: 100%;
  overflow-x: hidden;
}

@media (min-width: 768px) {
  .aya-main {
    margin-left: var(--aya-sidebar-w);
    transition: margin-left var(--aya-transition);
  }
}

@media (min-width: 1024px) {
  .aya-main {
    margin-left: var(--aya-sidebar-w);
  }
}

@media (min-width: 1440px) {
  .aya-main {
    max-width: var(--aya-content-max);
    margin-left: var(--aya-sidebar-w);
    margin-right: auto;
  }
}

/* ───────────────────────────────────────────────────────────────────────────
 * 6. CARDS & GRIDS
 * ─────────────────────────────────────────────────────────────────────────── */
.aya-card {
  background: var(--card, #1a1d2e);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: var(--aya-radius-md);
  padding: var(--aya-space-4);
  width: 100%;
}

@media (min-width: 768px) {
  .aya-card {
    padding: var(--aya-space-5);
    border-radius: var(--aya-radius-lg);
  }
}

/* Grid: 1col mobile → 2col tablet → 3col desktop → 4col wide */
.aya-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--aya-space-3);
}
@media (min-width: 480px) {
  .aya-grid { gap: var(--aya-space-4); }
}
@media (min-width: 768px) {
  .aya-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .aya-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1440px) {
  .aya-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Variantes — fixed columns */
.aya-grid--2 { grid-template-columns: 1fr; }
@media (min-width: 768px) { .aya-grid--2 { grid-template-columns: repeat(2, 1fr); } }

.aya-grid--3 { grid-template-columns: 1fr; }
@media (min-width: 768px) { .aya-grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .aya-grid--3 { grid-template-columns: repeat(3, 1fr); } }

/* ───────────────────────────────────────────────────────────────────────────
 * 7. TOUCH TARGETS — sistémico
 * ─────────────────────────────────────────────────────────────────────────── */
button, .btn, a.button, [role="button"], .aya-btn {
  min-height: var(--aya-touch-min);
  min-width: var(--aya-touch-min);
  padding: var(--aya-space-2) var(--aya-space-4);
  cursor: pointer;
}

/* Inputs nunca causam zoom em iOS */
input, select, textarea {
  font-size: 16px;
  min-height: var(--aya-touch-min);
}

/* ───────────────────────────────────────────────────────────────────────────
 * 8. TABLES — responsive
 * ─────────────────────────────────────────────────────────────────────────── */

/* Wrapper com scroll horizontal momentum */
.aya-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border-radius: var(--aya-radius-sm);
}

/* Em mobile, tabelas viram cards (opcional via class) */
@media (max-width: 767px) {
  .aya-table--cards {
    display: block;
  }
  .aya-table--cards thead { display: none; }
  .aya-table--cards tbody, .aya-table--cards tr {
    display: block;
    width: 100%;
  }
  .aya-table--cards tr {
    background: var(--card, #1a1d2e);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: var(--aya-radius-md);
    padding: var(--aya-space-3);
    margin-bottom: var(--aya-space-3);
  }
  .aya-table--cards td {
    display: flex;
    justify-content: space-between;
    padding: var(--aya-space-2) 0;
    border: none;
  }
  .aya-table--cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted, rgba(255,255,255,0.6));
    margin-right: var(--aya-space-3);
  }
}

/* ───────────────────────────────────────────────────────────────────────────
 * 9. MODAIS / BOTTOM-SHEET
 * ─────────────────────────────────────────────────────────────────────────── */

/* Mobile: fullscreen */
.aya-modal {
  position: fixed;
  inset: 0;
  background: var(--card, #1a1d2e);
  z-index: var(--aya-z-modal);
  overflow-y: auto;
  padding: var(--aya-space-4);
  display: flex;
  flex-direction: column;
}

/* Tablet+: dialog centrado */
@media (min-width: 768px) {
  .aya-modal {
    inset: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, 90vw);
    max-height: 85vh;
    border-radius: var(--aya-radius-lg);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7);
  }
}

/* Bottom-sheet (alternativa em mobile p/ ações secundárias) */
.aya-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card, #1a1d2e);
  z-index: var(--aya-z-modal);
  border-top-left-radius: var(--aya-radius-lg);
  border-top-right-radius: var(--aya-radius-lg);
  padding: var(--aya-space-4);
  padding-bottom: calc(var(--aya-space-4) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform var(--aya-transition);
  max-height: 85vh;
  overflow-y: auto;
}
.aya-sheet.is-open {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .aya-sheet {
    /* Em tablet+, comporta-se como modal centrado */
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, 90vw);
    border-radius: var(--aya-radius-lg);
  }
  .aya-sheet.is-open {
    transform: translate(-50%, -50%);
  }
}

/* ───────────────────────────────────────────────────────────────────────────
 * 10. UTILITIES
 * ─────────────────────────────────────────────────────────────────────────── */

/* Stack — coluna com gap consistente */
.aya-stack { display: flex; flex-direction: column; gap: var(--aya-space-3); }
.aya-stack--lg { gap: var(--aya-space-5); }
.aya-stack--sm { gap: var(--aya-space-2); }

/* Row — linha com gap e wrap */
.aya-row { display: flex; flex-direction: row; gap: var(--aya-space-3); flex-wrap: wrap; }

/* Visibilidade por breakpoint */
.aya-hide-mobile { display: none; }
@media (min-width: 768px) { .aya-hide-mobile { display: initial; } }

.aya-show-mobile { display: initial; }
@media (min-width: 768px) { .aya-show-mobile { display: none; } }

.aya-hide-desktop { display: initial; }
@media (min-width: 1024px) { .aya-hide-desktop { display: none; } }

/* Truncar texto (1 linha) */
.aya-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Scroll snap horizontal (úteis p/ Pipeline cards mobile) */
.aya-snap-x {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: var(--aya-space-3);
  padding-bottom: var(--aya-space-2);
}
.aya-snap-x > * {
  scroll-snap-align: start;
  flex: 0 0 85%;
}
@media (min-width: 480px) {
  .aya-snap-x > * { flex: 0 0 70%; }
}
@media (min-width: 768px) {
  .aya-snap-x { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); overflow: visible; }
  .aya-snap-x > * { flex: initial; }
}

/* Tap highlight customizado */
.aya-tap {
  position: relative;
  overflow: hidden;
}
.aya-tap:active {
  background: rgba(124, 58, 237, 0.1);
}

/* ───────────────────────────────────────────────────────────────────────────
 * 11. ACCESSIBILITY
 * ─────────────────────────────────────────────────────────────────────────── */

/* Focus visível (teclado + iOS Safari VoiceOver) */
:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  border-radius: var(--aya-radius-sm);
}

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

/* Screen-reader only */
.aya-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ───────────────────────────────────────────────────────────────────────────
 * 12. AYA-NAV.JS OVERRIDES (sidebar mobile-first sem mexer na JS)
 *
 * aya-nav.js injecta CSS em runtime com paradigma desktop-first:
 *   default     → sidebar visível 220px, body padding-left 220px
 *   <900px      → drawer mode (translateX -100%, hamburger visível)
 *
 * Mobile-first override:
 *   <1024px     → drawer mode (extende o range de 900 para 1023)
 *   ≥1024px    → sidebar 220px full
 *
 * Carrega DEPOIS de aya-nav.js para vencer specificity (ou usa !important).
 * ─────────────────────────────────────────────────────────────────────────── */

/* Mobile + tablet (até 1023px): drawer */
@media (max-width: 1023px) {
  body.aya-has-nav {
    padding-left: 0 !important;
  }
  .aya-sidebar:not(.open) {
    transform: translateX(-100%) !important;
    transition: transform 0.25s ease !important;
  }
  .aya-sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
  .aya-nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: var(--aya-touch-min) !important;
    min-height: var(--aya-touch-min) !important;
    padding: 0 var(--aya-space-3) !important;
    top: var(--aya-space-2) !important;
    left: var(--aya-space-2) !important;
    border-radius: var(--aya-radius-sm) !important;
  }
  .aya-sidebar.open ~ .aya-nav-overlay,
  .aya-nav-overlay.is-visible {
    display: block !important;
  }
}

/* Desktop (≥1024px): sidebar permanente */
@media (min-width: 1024px) {
  body.aya-has-nav {
    padding-left: var(--aya-nav-w, 220px);
  }
  .aya-sidebar {
    transform: translateX(0) !important;
  }
  .aya-nav-toggle {
    display: none !important;
  }
  .aya-nav-overlay {
    display: none !important;
  }
}

/* Score Box mobile: ligeiramente menor para caber melhor em drawer */
@media (max-width: 479px) {
  .aya-score-box {
    margin: 0.5rem 0.6rem !important;
    padding: 0.65rem !important;
  }
  .aya-score-num {
    font-size: 1.75rem !important;
  }
}

/* Sidebar drawer: padding-bottom para safe-area iOS */
.aya-sidebar {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Auto-close drawer on nav-item click (UX em mobile) — implementado via JS no app
 * mas garantimos que click em link fecha visualmente. Adicionar:
 *   document.querySelectorAll('.aya-nav-item').forEach(a => a.addEventListener('click', () => {
 *     document.getElementById('aya-sidebar')?.classList.remove('open');
 *   }));
 * (A integrar no Phase 6 polish.)
 */

/* ═══════════════════════════════════════════════════════════════════════════
 * FIM aya-mobile-first.css v1.0
 * ═══════════════════════════════════════════════════════════════════════════ */
