/* AudioZap Admin — overrides + utilitários custom (Etapa 4a Fase D B12a).
 *
 * Carregado APÓS tailwind.min.js (Play CDN). Usar `--bg-dark`, `--primary`, etc.
 * Componentes prefixados `.az-*` pra não conflitar com Tailwind utilities.
 *
 * Decisões fixadas:
 *   D53 — paleta dark #1a1c24 fundo, #ff830a primário
 *   D34 — tudo local-copy (vendor/), zero CDN externo em prod
 *   Inter via Google Fonts fallback (vendor/ ainda não tem woff2 — anotado no README)
 */

:root {
  --primary: #ff830a;
  --primary-hover: #e6770a;
  --primary-active: #cc6a08;
  --primary-soft: rgba(255, 131, 10, 0.12);
  --bg-dark: #1a1c24;
  --bg-surface: #20232d;
  --bg-elevated: #262936;
  --bg-hover: #2d3140;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --border: #374151;
  --border-soft: #2a2f3a;
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.15);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.35);
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-stack);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-dark);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); }
code, pre { font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace; }

/* Layout shell ----------------------------------------------------------- */
.az-shell { display: flex; min-height: 100vh; }
.az-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-soft);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.2s ease;
}
.az-sidebar__header { padding: 20px 16px; border-bottom: 1px solid var(--border-soft); }
.az-sidebar__brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; color: var(--text); }
.az-sidebar__brand-mark { width: 28px; height: 28px; border-radius: 6px; background: var(--primary); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; }
.az-sidebar__nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.az-sidebar__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500;
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
.az-sidebar__item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.az-sidebar__item--active { background: var(--primary-soft); color: var(--primary); }
.az-sidebar__item--active:hover { background: var(--primary-soft); color: var(--primary); }
.az-sidebar__item-icon { width: 18px; height: 18px; flex-shrink: 0; }
.az-sidebar__footer { margin-top: auto; padding: 16px; border-top: 1px solid var(--border-soft); font-size: 12px; color: var(--text-dim); }

.az-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
}
.az-topbar {
  display: none; /* mobile only */
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.az-topbar__user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.az-hamburger {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); cursor: pointer;
}

/* Mobile breakpoint */
@media (max-width: 768px) {
  .az-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-elevated); }
  .az-sidebar--open { transform: translateX(0); }
  .az-main { margin-left: 0; padding: 16px; }
  .az-topbar { display: flex; }
  .az-sidebar__backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5); z-index: 35;
  }
  .az-sidebar--open + .az-sidebar__backdrop { display: block; }
}

/* Cards ------------------------------------------------------------------ */
.az-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.az-card__title { font-size: 13px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.az-card__value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.2; }
.az-card__hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.az-card--clickable { cursor: pointer; transition: transform 0.12s, border-color 0.12s; }
.az-card--clickable:hover { transform: translateY(-1px); border-color: var(--border); }

/* Badges ----------------------------------------------------------------- */
.az-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
  background: var(--bg-elevated); color: var(--text-muted);
}
.az-badge--success { background: var(--success-soft); color: var(--success); }
.az-badge--warning { background: var(--warning-soft); color: var(--warning); }
.az-badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.az-badge--info    { background: var(--info-soft);    color: var(--info); }
.az-badge--primary { background: var(--primary-soft); color: var(--primary); }

/* Tables ----------------------------------------------------------------- */
.az-table-wrap { background: var(--bg-surface); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.az-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.az-table thead th {
  text-align: left; padding: 12px 14px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px;
  background: var(--bg-elevated); border-bottom: 1px solid var(--border-soft);
}
.az-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text); }
.az-table tbody tr:last-child td { border-bottom: none; }
.az-table tbody tr:hover { background: var(--bg-hover); }
.az-table__empty { padding: 32px; text-align: center; color: var(--text-dim); }
.az-table__actions { display: flex; gap: 6px; }

/* Forms ------------------------------------------------------------------ */
.az-input, .az-select, .az-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.az-input:focus, .az-select:focus, .az-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.az-input::placeholder { color: var(--text-dim); }
.az-input--error, .az-select--error, .az-textarea--error { border-color: var(--danger); }
.az-input--error:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.az-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.az-field { margin-bottom: 14px; }
.az-field__error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.az-field__hint  { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

/* Buttons ---------------------------------------------------------------- */
.az-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
  text-decoration: none; line-height: 1;
}
.az-btn:active { transform: translateY(1px); }
.az-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.az-btn--primary   { background: var(--primary); color: #fff; }
.az-btn--primary:hover:not(:disabled)   { background: var(--primary-hover); color: #fff; text-decoration: none; }
.az-btn--primary:active:not(:disabled)  { background: var(--primary-active); }
.az-btn--secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
.az-btn--secondary:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.az-btn--danger    { background: var(--danger); color: #fff; }
.az-btn--danger:hover:not(:disabled)    { background: #dc2626; color: #fff; text-decoration: none; }
.az-btn--ghost     { background: transparent; color: var(--text-muted); }
.az-btn--ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.az-btn--sm { padding: 6px 10px; font-size: 12px; }
.az-btn--block { width: 100%; }
.az-btn--loading { position: relative; color: transparent !important; }
.az-btn--loading::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--text); animation: az-spin 0.7s linear infinite;
}
@keyframes az-spin { to { transform: rotate(360deg); } }

/* Toasts ----------------------------------------------------------------- *
 * Flutuante moderno: glassmorphism + ícone tipo + progress bar decay + close
 * on hover + pause-on-hover (CSS visual; JS pausa setTimeout também).
 * Mobile (<640px): bottom-centered, largura total. */
.az-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

@media (max-width: 640px) {
  .az-toast-container {
    bottom: 16px;
    left: 16px;
    right: 16px;
    align-items: center;
  }
}

.az-toast {
  pointer-events: auto;
  position: relative;
  min-width: 320px;
  max-width: 420px;
  background: rgba(38, 41, 54, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 14px 14px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  overflow: hidden;
  animation: az-toast-in 280ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@media (max-width: 640px) {
  .az-toast {
    min-width: 0;
    width: 100%;
  }
}

.az-toast--leaving {
  animation: az-toast-out 200ms ease-in forwards !important;
}

.az-toast__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.az-toast__icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

.az-toast--success .az-toast__icon { background: var(--success-soft); color: var(--success); }
.az-toast--success .az-toast__progress { background: var(--success); }

.az-toast--error .az-toast__icon { background: var(--danger-soft); color: var(--danger); }
.az-toast--error .az-toast__progress { background: var(--danger); }

.az-toast--warning .az-toast__icon { background: var(--warning-soft); color: var(--warning); }
.az-toast--warning .az-toast__progress { background: var(--warning); }

.az-toast--info .az-toast__icon { background: var(--info-soft); color: var(--info); }
.az-toast--info .az-toast__progress { background: var(--info); }

.az-toast__body {
  flex: 1;
  min-width: 0;
}

.az-toast__message {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  margin-top: 6px;
  word-wrap: break-word;
}

.az-toast__close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  opacity: 0.5;
  border-radius: 6px;
  margin-top: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, background 0.12s, color 0.12s;
}

.az-toast:hover .az-toast__close { opacity: 1; }
.az-toast__close:hover { background: var(--bg-hover); color: var(--text); }
.az-toast__close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.az-toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2.5px;
  width: 100%;
  opacity: 0.8;
  animation: az-toast-progress var(--toast-duration, 4000ms) linear forwards;
}

.az-toast:hover .az-toast__progress { animation-play-state: paused; }

@keyframes az-toast-in {
  from { transform: translateX(24px) scale(0.95); opacity: 0; }
  to   { transform: translateX(0) scale(1); opacity: 1; }
}
@keyframes az-toast-out {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(24px); opacity: 0; }
}
@keyframes az-toast-progress {
  from { width: 100%; }
  to   { width: 0%; }
}

@media (prefers-reduced-motion: reduce) {
  .az-toast {
    animation: az-toast-fade-in 280ms ease forwards;
  }
  .az-toast--leaving {
    animation: az-toast-fade-out 200ms ease forwards !important;
  }
  @keyframes az-toast-fade-in  { from { opacity: 0; } to { opacity: 1; } }
  @keyframes az-toast-fade-out { from { opacity: 1; } to { opacity: 0; } }
}

/* Banners (top, full width) --------------------------------------------- */
.az-banner {
  padding: 10px 16px; font-size: 13px;
  background: var(--danger-soft); color: var(--danger);
  border-bottom: 1px solid var(--danger);
}
.az-banner--warning { background: var(--warning-soft); color: var(--warning); border-bottom-color: var(--warning); }
.az-banner--info    { background: var(--info-soft);    color: var(--info);    border-bottom-color: var(--info); }

/* Skeletons -------------------------------------------------------------- */
.az-skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 0%, var(--bg-hover) 50%, var(--bg-elevated) 100%);
  background-size: 200% 100%;
  animation: az-skeleton-shimmer 1.4s linear infinite;
  border-radius: 6px;
  display: inline-block;
}
.az-skeleton--text  { height: 14px; width: 100%; }
.az-skeleton--title { height: 22px; width: 60%; }
.az-skeleton--card  { height: 90px; width: 100%; }
@keyframes az-skeleton-shimmer { to { background-position: -200% 0; } }

/* Pagination ------------------------------------------------------------- */
.az-paginator { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; gap: 8px; }
.az-paginator__info { font-size: 12px; color: var(--text-muted); }
.az-paginator__pages { display: flex; gap: 4px; }
.az-paginator__btn {
  min-width: 32px; height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border-soft);
  color: var(--text-muted); font-size: 13px; cursor: pointer;
}
.az-paginator__btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.az-paginator__btn--active { background: var(--primary); color: #fff; border-color: var(--primary); }
.az-paginator__btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Page header ------------------------------------------------------------ */
.az-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.az-page-header__title { font-size: 22px; font-weight: 700; }
.az-page-header__sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.az-page-header__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Utility ---------------------------------------------------------------- */
.az-stack > * + * { margin-top: 12px; }
.az-row { display: flex; gap: 8px; align-items: center; }
.az-grow { flex: 1; min-width: 0; }
.az-mono { font-family: 'JetBrains Mono', Consolas, Monaco, monospace; font-size: 12px; }
.az-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.az-text-muted { color: var(--text-muted); }
.az-text-dim   { color: var(--text-dim); }
.az-hidden { display: none !important; }

/* SweetAlert2 dark overrides */
.swal2-popup.swal2-modal { background: var(--bg-surface) !important; color: var(--text) !important; border: 1px solid var(--border-soft); }
.swal2-popup .swal2-title, .swal2-popup .swal2-html-container { color: var(--text) !important; }
.swal2-popup .swal2-styled.swal2-confirm { background: var(--primary) !important; box-shadow: none !important; }
.swal2-popup .swal2-styled.swal2-confirm:hover { background: var(--primary-hover) !important; }
.swal2-popup .swal2-styled.swal2-cancel { background: var(--bg-elevated) !important; color: var(--text) !important; border: 1px solid var(--border) !important; }
.swal2-popup .swal2-styled.swal2-deny { background: var(--danger) !important; }
.swal2-popup .swal2-input, .swal2-popup .swal2-textarea, .swal2-popup .swal2-select {
  background: var(--bg-elevated) !important; color: var(--text) !important;
  border: 1px solid var(--border) !important; box-shadow: none !important;
}
