/* ============================================================
   MYSTIK DESIGN SYSTEM — Tokens + Base (Modern Minimalist Dark/Light)
   Identidade: Indigo Profundo #3B2DAA, Violeta Luminoso #9032B0,
   Magenta Místico #DC35E3, Ouro Oracular #F59E0B, Lavanda #E0EAF9
   ============================================================ */

:root {
  /* Royal Purple Brand */
  --p: #8250df;
  --p2: #6639ba;
  --mag: #8250df;
  --rosa: #cf222e;
  --gold: #d4a72c;
  --cyano: #0969da;
  
  /* Royal Parchment / Pergaminho Místico (Warm, high-end, zero sterile hospital glare) */
  --bg: #FAF7F2;
  --bg2: #FFFFFF;
  --bg3: #F2ECE0;
  --bg-card: rgba(255, 255, 255, 0.96);
  
  --tx: #1E1B24;
  --tx2: #655E72;
  --tx3: #8C8499;
  
  --brd: #E4DDD1;
  --brd-hover: #8250df;
  --glow: rgba(130, 80, 223, 0.18);
  
  --grad-btn: linear-gradient(135deg, #8250df 0%, #7c3aed 100%);
  --grad-btn-hover: linear-gradient(135deg, #6639ba 0%, #6d28d9 100%);
  --grad-gold: linear-gradient(135deg, #d4a72c 0%, #bf8700 100%);
  
  --page-bg: var(--bg);
  --card-shadow: 0 4px 16px rgba(120, 110, 130, 0.10), 0 1px 3px rgba(30, 27, 36, 0.05);
  --card-shadow-hover: 0 12px 30px rgba(130, 80, 223, 0.20), 0 2px 8px rgba(30, 27, 36, 0.08);
  
  --danger: #cf222e;
  --success: #1a7f37;
  --radius: 18px;
  --radius-sm: 10px;
  --radius-pill: 9999px;
}

[data-theme="dark"] {
  /* Luminous Amethyst Purple (Dark mode - ethereal, rich, zero eye strain) */
  --p: #a371f7;
  --p2: #8957e5;
  --mag: #a371f7;
  --rosa: #ff7b72;
  --gold: #d29922;
  --cyano: #58a6ff;
  
  /* Deep Cosmic Obsidian (Atmospheric, Sacred) */
  --bg: #090B10;
  --bg2: #121520;
  --bg3: #1B202E;
  --bg-card: rgba(18, 21, 32, 0.92);
  
  --tx: #F0F4FC;
  --tx2: #9AA3B8;
  --tx3: #6B7488;
  
  --brd: #252B3C;
  --brd-hover: #a371f7;
  --glow: rgba(163, 113, 247, 0.26);
  
  --grad-btn: linear-gradient(135deg, #8957e5 0%, #7c3aed 100%);
  --grad-btn-hover: linear-gradient(135deg, #7c3aed 0%, #6e40c9 100%);
  --grad-gold: linear-gradient(135deg, #d29922 0%, #e3b341 100%);
  
  --page-bg: var(--bg);
  --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --card-shadow-hover: 0 16px 36px rgba(137, 87, 229, 0.28), 0 0 0 1px rgba(163, 113, 247, 0.5);
  
  --danger: #ff7b72;
  --success: #3fb950;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--tx);
  background: var(--page-bg);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  transition: background 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

*:focus-visible {
  outline: 2px solid var(--p);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

a {
  color: var(--p);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--p2);
}

::selection {
  background: var(--p);
  color: #fff;
}

/* Botao de Alternancia de Tema */
.theme-toggle {
  background: var(--bg2);
  border: 1px solid var(--brd);
  color: var(--tx);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.theme-toggle:hover {
  border-color: var(--p);
  transform: scale(1.05);
  box-shadow: 0 0 0 3px var(--glow);
}

/* Cartao Padrao com Efeito Glassmorphic */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--brd);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--brd-hover);
  box-shadow: var(--card-shadow-hover);
}

/* Estados Visuais (Loading / Empty / Error) */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.animate-pulse {
  animation: pulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.skeleton {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  animation: pulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-card {
  background: var(--bg2);
  border: 1px solid var(--brd);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  display: flex;
  gap: 14px;
  align-items: center;
}

/* Estado vazio com iconografia moderna */
.empty-state {
  text-align: center;
  color: var(--tx2);
  padding: 44px 24px;
  font-size: 0.92rem;
  background: var(--bg2);
  border: 1px dashed var(--brd);
  border-radius: var(--radius);
  margin: 16px 0;
}

.empty-state .empty-icon {
  font-size: 2.6rem;
  margin-bottom: 14px;
  opacity: 0.9;
  filter: drop-shadow(0 4px 8px var(--glow));
}

.empty-state h4 {
  color: var(--p);
  font-size: 1.15rem;
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.empty-state p {
  color: var(--tx2);
  font-size: 0.88rem;
  max-width: 440px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Estado de erro com acao de retry */
.error-state {
  text-align: center;
  padding: 32px 24px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  margin: 16px 0;
}

.error-state .error-icon {
  font-size: 2.2rem;
  margin-bottom: 10px;
  color: #ef4444;
}

.error-state h4 {
  color: #dc2626;
  font-size: 1.05rem;
  margin-bottom: 8px;
  font-weight: 700;
}

.error-state p {
  color: var(--tx2);
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.error-state .btn-retry {
  background: var(--p);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  transition: all 0.2s ease;
}

.error-state .btn-retry:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* Scrollbar refinada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--brd);
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--p2);
}

/* Tabelas limpas */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tx2);
  padding: 12px 14px;
  border-bottom: 1px solid var(--brd);
  font-weight: 600;
}

td {
  padding: 12px 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--brd);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: var(--bg3);
}

tbody tr:nth-child(even) {
  background: rgba(79, 70, 229, 0.02);
}

[data-theme="dark"] tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Toast de Notificacao Moderno */
#toast, #adminToast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  background: var(--bg2);
  color: var(--tx);
  border: 1px solid var(--brd);
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#toast.show, #adminToast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Icones SVG */
.ic {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  color: currentColor;
}

.btn-gold, .btn-ghost, .btn-outline, .btn-logout, .user-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-gold .ic, .btn-ghost .ic, .btn-outline .ic, .btn-logout .ic {
  color: inherit;
}

h1, h2, h3, h4, .section-title, .app-logo, .logo span, .plan-name {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -0.02em;
}

/* Spinner de carregamento em botoes */
.btn-loader {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  animation: spinBtn 0.7s linear infinite;
  flex-shrink: 0;
}

.btn-ghost .btn-loader, .btn-outline .btn-loader {
  border-color: var(--brd);
  border-top-color: var(--p);
}

.btn-loading {
  pointer-events: none;
  opacity: 0.85;
  cursor: wait;
}

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

/* Erro de validacao inline */
.form-error {
  display: none;
  color: var(--danger);
  font-size: 0.82rem;
  margin: 10px 0 0;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
}

.form-error.show {
  display: block;
}
