/* ═══════════════════════════════════════════════════════════════
   admin-base.css
   ───────────────
   Fundação do admin:
     • Fonte Rodfat
     • Tokens de tema (claro + escuro)
     • Reset mínimo
     • Body + textura de pergaminho
     • Layout shell (grid sidebar + conteúdo)
     • Sidebar completa (brand, nav, user, footer, tema, logout)
     • Page head

   Carregar ANTES de admin-ui.css e admin-data.css.
   ═══════════════════════════════════════════════════════════════ */


/* ─── Fonte da marca ─────────────────────────────────────────── */
@font-face {
  font-family: 'Rodfat';
  src: url('/assets/fonts/rodfat.woff2') format('woff2'),
       url('/assets/fonts/rodfat.ttf')   format('truetype');
  font-weight: normal;
  font-style:  normal;
  font-display: swap;
}


/* ─── Reset mínimo (escopo admin) ────────────────────────────── */
body[data-admin],
body[data-admin] *,
body[data-admin] *::before,
body[data-admin] *::after {
  box-sizing: border-box;
}

body[data-admin] { margin: 0; padding: 0; }


/* ─── Tokens: tema CLARO (pergaminho, padrão) ────────────────── */
body[data-admin] {
  /* Cores base */
  --admin-bg:           #F4EFE3;
  --admin-bg-deep:      #EBE3D1;
  --admin-surface:      #FFFFFF;
  --admin-surface-2:    #FBF6EA;
  --admin-surface-hover:#F1E9D4;
  --admin-card:         #FFFFFF;
  --admin-border:       #E2D6B8;
  --admin-border-soft:  #EFE5CD;
  --admin-divider:      #D6C99E;

  /* Texto */
  --admin-text:        #1F1812;
  --admin-text-strong: #0E0A06;
  --admin-text-muted:  #7B6C53;
  --admin-text-faint:  #A89878;

  /* Ouro (acento da marca) */
  --admin-gold:        #B58407;
  --admin-gold-strong: #8C6500;
  --admin-gold-light:  #D4A017;
  --admin-gold-soft:   rgba(181, 132, 7, 0.10);
  --admin-gold-hover:  rgba(181, 132, 7, 0.16);
  --admin-gold-glow:   rgba(181, 132, 7, 0.22);

  /* Aliases legados */
  --admin-accent:       var(--admin-gold);
  --admin-accent-text:  var(--admin-gold-strong);
  --admin-accent-soft:  var(--admin-gold-soft);

  /* Status */
  --admin-success:     #2E7D3B;
  --admin-success-soft:rgba(46, 125, 59, 0.10);
  --admin-warn:        #B45309;
  --admin-warn-soft:   rgba(180, 83, 9, 0.10);
  --admin-danger:      #B91C1C;
  --admin-danger-soft: rgba(185, 28, 28, 0.10);
  --admin-info:        #1E5C8C;
  --admin-info-soft:   rgba(30, 92, 140, 0.10);

  /* Tipografia */
  --font-ui:      'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Rodfat', 'Cinzel', 'Poppins', serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
  --admin-font-display: var(--font-display);
  --admin-font-mono:    var(--font-mono);

  /* Raios */
  --r-xs:   6px;
  --r:      10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-pill: 999px;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(60, 40, 10, 0.06);
  --shadow-sm: 0 4px 14px rgba(60, 40, 10, 0.08);
  --shadow-md: 0 10px 30px rgba(60, 40, 10, 0.12);
  --shadow-lg: 0 28px 70px rgba(60, 40, 10, 0.18);
  --shadow-xl: 0 40px 100px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 8px 28px var(--admin-gold-glow);

  /* Easing base (suave com micro-overshoot) */
  --ease: cubic-bezier(.34, 1.56, .64, 1);
}


/* ─── Tokens: tema ESCURO ────────────────────────────────────── */
body[data-admin][data-theme="dark"] {
  --admin-bg:           #0A0805;
  --admin-bg-deep:      #050402;
  --admin-surface:      #131008;
  --admin-surface-2:    #1A140B;
  --admin-surface-hover:#211A0F;
  --admin-card:         #15110A;
  --admin-border:       #2C2316;
  --admin-border-soft:  #221B11;
  --admin-divider:      #3A2F1E;

  --admin-text:        #F5F0E1;
  --admin-text-strong: #FFFAEC;
  --admin-text-muted:  #A8997C;
  --admin-text-faint:  #6B5F49;

  --admin-gold:        #D4A017;
  --admin-gold-strong: #F0C040;
  --admin-gold-light:  #F0C040;
  --admin-gold-soft:   rgba(212, 160, 23, 0.12);
  --admin-gold-hover:  rgba(212, 160, 23, 0.18);
  --admin-gold-glow:   rgba(212, 160, 23, 0.30);

  --admin-accent-text: var(--admin-gold-light);

  --admin-success-soft:rgba(64, 167, 88, 0.16);
  --admin-warn-soft:   rgba(225, 130, 35, 0.16);
  --admin-danger-soft: rgba(220, 60, 60, 0.16);
  --admin-info-soft:   rgba(80, 160, 220, 0.16);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 12px 36px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.7);
  --shadow-xl: 0 40px 100px rgba(0, 0, 0, 0.8);
  --shadow-glow: 0 8px 32px var(--admin-gold-glow);
}


/* ─── Body + textura de pergaminho ───────────────────────────── */
body[data-admin] {
  font-family: var(--font-ui);
  font-size:   15px;
  line-height: 1.55;
  background:  var(--admin-bg);
  color:       var(--admin-text);
  min-height:  100vh;
  position:    relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ruído fractal sutil (mesmo padrão do site público) */
body[data-admin]::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.65'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  opacity: 0.10;
  mix-blend-mode: multiply;
}

body[data-admin][data-theme="dark"]::before {
  opacity: 0.18;
  mix-blend-mode: overlay;
}


/* ─── Helpers globais ────────────────────────────────────────── */
body[data-admin] a { color: inherit; text-decoration: none; }

.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;
}


/* ═══════════════════════════════════════════════════════════════
   LAYOUT SHELL
   ═══════════════════════════════════════════════════════════════ */

.admin-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 2;
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
}


/* ═══════════════════════════════════════════════════════════════
   SIDEBAR (brand + nav + user + theme + logout)
   ═══════════════════════════════════════════════════════════════ */

.admin-sidebar {
  background: linear-gradient(170deg, #100B05 0%, #0A0703 60%, #050300 100%);
  color: #E9DFC5;
  display: flex;
  flex-direction: column;
  /* altura da viewport + align-self:start pra não esticar no grid  */
  /* (essencial pra sticky funcionar quando o conteúdo é mais alto) */
  height: 100vh;
  align-self: start;
  position: sticky;
  top: 0;
  overflow-y: auto;
  border-right: 1px solid rgba(212, 160, 23, 0.18);
  box-shadow: 4px 0 28px rgba(0, 0, 0, 0.35);
  z-index: 5;
}

/* Halo dourado sutil (topo + base) */
.admin-sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 30% at 50% 0%, rgba(212,160,23,0.08), transparent 60%),
    radial-gradient(ellipse 80% 20% at 50% 100%, rgba(212,160,23,0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.admin-sidebar > * { position: relative; z-index: 1; }


/* ─── Brand (emblema + nome) ────────────────────────────────── */
.admin-sidebar-brand {
  padding: 26px 24px 22px;
  border-bottom: 1px solid rgba(212, 160, 23, 0.12);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}

.admin-sidebar-brand::after {
  content: '';
  position: absolute;
  left: 24px; right: 24px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(212,160,23,0.35), transparent);
}

.brand-emblem {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-emblem svg {
  width: 34px;
  height: 34px;
  color: var(--admin-gold-light);
  filter: drop-shadow(0 0 12px rgba(212, 160, 23, 0.45));
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 400;
  color: #F5F0E8;
  letter-spacing: 0.04em;
  line-height: 1.05;
}

.brand-name span {
  display: block;
  color: var(--admin-gold-light);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

.brand-tag {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(212, 160, 23, 0.75);
  padding: 4px 10px;
  border: 1px solid rgba(212, 160, 23, 0.30);
  border-radius: var(--r-pill);
  background: rgba(212, 160, 23, 0.06);
  backdrop-filter: blur(4px);
}


/* ─── Navegação ──────────────────────────────────────────────── */
.admin-sidebar-nav {
  flex: 1;
  padding: 18px 14px;
  overflow-y: auto;
}

.admin-sidebar-nav::-webkit-scrollbar       { width: 4px; }
.admin-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(212,160,23,0.20); border-radius: 4px; }

/* Cabeçalho de seção: "◆ Operação ◆" com linha de cada lado */
.nav-section {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(212, 160, 23, 0.60);
  padding: 18px 12px 8px;
  margin-top: 6px;
}

.nav-section::before,
.nav-section::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(212,160,23,0.20), transparent);
}

.nav-section::before { background: linear-gradient(to left, rgba(212,160,23,0.20), transparent); }
.nav-section::after  { background: linear-gradient(to right, rgba(212,160,23,0.20), transparent); }

.nav-section .nav-section-mark {
  color: rgba(212, 160, 23, 0.55);
  font-size: 0.55rem;
}

/* Item de navegação */
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 2px 0;
  border-radius: var(--r);
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(233, 223, 197, 0.78);
  border: 1px solid transparent;
  transition: all 0.22s ease;
  position: relative;
  cursor: pointer;
}

.nav-link .nav-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  color: rgba(212, 160, 23, 0.55);
  transition: all 0.22s ease;
  flex-shrink: 0;
}

.nav-link .nav-icon svg { width: 100%; height: 100%; display: block; }

.nav-link:hover {
  background: rgba(212, 160, 23, 0.06);
  border-color: rgba(212, 160, 23, 0.20);
  color: #F5F0E8;
}

.nav-link:hover .nav-icon { color: var(--admin-gold-light); }

.nav-link.is-active {
  background: linear-gradient(95deg, rgba(212,160,23,0.12), rgba(212,160,23,0.04));
  border-color: rgba(212, 160, 23, 0.35);
  color: #F5F0E8;
  box-shadow: 0 4px 16px rgba(212, 160, 23, 0.10);
}

.nav-link.is-active::before {
  content: '';
  position: absolute;
  left: -14px; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: linear-gradient(to bottom, transparent, var(--admin-gold-light), transparent);
  box-shadow: 0 0 8px var(--admin-gold-light);
  border-radius: 2px;
}

.nav-link.is-active .nav-icon { color: var(--admin-gold-light); }

.nav-link .nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link .nav-ext {
  margin-left: auto;
  font-size: 0.72rem;
  color: rgba(212, 160, 23, 0.55);
  transition: color 0.2s ease;
}

.nav-link:hover .nav-ext { color: var(--admin-gold-light); }

.nav-link .nav-hint {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: rgba(212, 160, 23, 0.55);
  padding: 3px 8px;
  border: 1px solid rgba(212, 160, 23, 0.22);
  border-radius: var(--r-pill);
  background: rgba(212, 160, 23, 0.05);
  margin-left: auto;
  flex-shrink: 0;
}

.nav-link.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.nav-link.is-disabled .nav-label,
.nav-link.is-disabled .nav-icon { opacity: 0.6; }


/* ─── Rodapé da sidebar (usuário + tema + logout) ───────────── */
.admin-sidebar-foot {
  padding: 18px 16px;
  border-top: 1px solid rgba(212, 160, 23, 0.12);
  position: relative;
}

.admin-sidebar-foot::before {
  content: '';
  position: absolute;
  left: 24px; right: 24px;
  top: -1px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(212,160,23,0.35), transparent);
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(212, 160, 23, 0.14);
  border-radius: var(--r);
  background: rgba(212, 160, 23, 0.04);
}

.admin-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--admin-gold), var(--admin-gold-light));
  color: #1A1308;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(212, 160, 23, 0.35), inset 0 0 0 1px rgba(255, 240, 200, 0.25);
}

.admin-user-avatar.admin-user-avatar-placeholder {
  background: rgba(212, 160, 23, 0.08);
  color: rgba(212, 160, 23, 0.55);
  box-shadow: inset 0 0 0 1px rgba(212, 160, 23, 0.18);
}
.admin-user-avatar.admin-user-avatar-placeholder svg {
  width: 20px; height: 20px;
  display: block;
}

.admin-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-user-info strong {
  font-size: 0.84rem;
  font-weight: 600;
  color: #F5F0E8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.admin-user-info small {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(212, 160, 23, 0.75);
  margin-top: 1px;
}

.admin-foot-actions {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 8px;
}

.theme-toggle,
.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid rgba(212, 160, 23, 0.22);
  border-radius: var(--r);
  color: rgba(233, 223, 197, 0.85);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle .theme-icon,
.logout-btn .logout-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  color: var(--admin-gold-light);
  transition: color 0.2s ease;
}
.theme-toggle .theme-icon svg,
.logout-btn .logout-icon svg { width: 100%; height: 100%; display: block; }

.theme-toggle:hover,
.logout-btn:hover {
  background: rgba(212, 160, 23, 0.10);
  border-color: var(--admin-gold-light);
  color: #F5F0E8;
}

.logout-btn:hover             { border-color: var(--admin-danger); color: #FFB4B4; }
.logout-btn:hover .logout-icon { color: #FFB4B4; }


/* ═══════════════════════════════════════════════════════════════
   CONTEÚDO PRINCIPAL + PAGE HEAD
   ═══════════════════════════════════════════════════════════════ */

.admin-content {
  padding: 36px clamp(20px, 4vw, 44px);
  min-height: 100vh;
  position: relative;
  z-index: 2;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .admin-content { padding: 24px 18px; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--admin-border-soft);
  position: relative;
}

/* Losango dourado sobre a linha divisória */
.page-head::after {
  content: '◆';
  position: absolute;
  bottom: -7px;
  left: 0;
  font-size: 0.7rem;
  color: var(--admin-gold);
  background: var(--admin-bg);
  padding: 0 8px 0 0;
  line-height: 1;
}

.page-head-text { min-width: 0; }

.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 2.6vw, 2.2rem);
  font-weight: 400;
  margin: 0 0 6px;
  color: var(--admin-text-strong);
  letter-spacing: 0.01em;
  line-height: 1.05;
}

.page-subtitle {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--admin-text-muted);
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVO (sidebar em mobile)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .admin-sidebar {
    /* mobile: sidebar vira header em cima, rola normal com a página */
    position: relative;
    height: auto;
    min-height: auto;
    align-self: stretch;
    overflow-y: visible;
    border-right: 0;
    border-bottom: 1px solid rgba(212, 160, 23, 0.18);
  }

  .admin-sidebar-nav { padding: 8px 12px; }
  .nav-section       { padding: 12px 12px 6px; }
}
