/* ============================================
   🧙‍♀️ Circulo Vermelho - Design System CSS
   Based on: instructions/design-system.md
   ============================================ */

/* --- CSS Custom Properties (Tokens) --- */
:root {
  /* Base Colors */
  --black: #0B0B0F;
  --bg: #0F0F14;

  /* Primary Colors */
  --purple: #6D28D9;
  --purple-dark: #2E1065;

  /* Accent Colors */
  --gold: #BFA181;
  --gold-dark: #8B6B3E;

  /* Intensity Colors */
  --red: #7F1D1D;
  --red-accent: #DC2626;

  /* Text Colors */
  --text-primary: #E5E7EB;
  --text-secondary: #9CA3AF;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #2E1065, #6D28D9, #BFA181);
  --gradient-bg: linear-gradient(135deg, #0B0B0F, #2E1065);
  --gradient-border: linear-gradient(90deg, #6D28D9, #BFA181);
  --gradient-danger: linear-gradient(135deg, #7F1D1D, #DC2626);
  --gradient-mystic: linear-gradient(135deg, #2E1065, #7F1D1D, #BFA181);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Spacing */
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;

  /* Shadows */
  --shadow-purple: 0 0 20px rgba(109, 40, 217, 0.5);
  --shadow-red: 0 0 20px rgba(220, 38, 38, 0.4);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

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

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

/* --- Gradient Text --- */
.gradient-text {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.page {
  padding: var(--space-lg) 0;
  min-height: calc(100vh - 70px);
}

/* --- Navigation / Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--black);
  border-right: 1px solid rgba(109, 40, 217, 0.2);
  padding: var(--space-lg) 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  text-align: center;
  padding: 0 var(--space-md) var(--space-lg);
  border-bottom: 1px solid rgba(109, 40, 217, 0.2);
  margin-bottom: var(--space-md);
}

.sidebar-logo h2 {
  font-size: 1.25rem;
  margin-bottom: var(--space-sm);
}

.sidebar-logo p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sidebar-nav {
  list-style: none;
  padding: 0 var(--space-sm);
}

.sidebar-nav li {
  margin-bottom: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  font-size: 0.95rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(109, 40, 217, 0.15);
  color: var(--text-primary);
}

.sidebar-nav a.active {
  border-left: 3px solid var(--purple);
}

.sidebar-nav .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
}

/* --- Main Content Area --- */
.main-content {
  margin-left: 260px;
  padding: var(--space-lg);
  min-height: 100vh;
}

/* --- Cards --- */
.card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  position: relative;
  border: 1px solid transparent;
  background-clip: padding-box;
  margin-bottom: var(--space-md);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: var(--gradient-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card-title {
  font-size: 1.1rem;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.card-content {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
}

.btn-primary {
  background: var(--purple);
  color: white;
}

.btn-primary:hover {
  background: var(--gradient-primary);
  box-shadow: var(--shadow-purple);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
}

.btn-danger:hover {
  box-shadow: var(--shadow-red);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(109, 40, 217, 0.3);
}

.btn-ghost:hover {
  border-color: var(--purple);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 16px;
  font-size: 0.85rem;
}

/* --- Forms --- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--black);
  border: 1px solid rgba(109, 40, 217, 0.3);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.2);
}

.form-textarea {
  min-height: 150px;
  resize: vertical;
}

.form-select {
  cursor: pointer;
}

/* --- Grid Layouts --- */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* --- Header Bar --- */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid rgba(109, 40, 217, 0.15);
}

.header-bar h1 {
  margin: 0;
}

/* --- Stats / Metrics --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--black);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
  border: 1px solid rgba(109, 40, 217, 0.15);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* --- Content List (Admin) --- */
.content-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.content-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--black);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(109, 40, 217, 0.1);
  transition: border-color 0.2s;
}

.content-item:hover {
  border-color: rgba(109, 40, 217, 0.3);
}

.content-item-info h4 {
  margin-bottom: 4px;
}

.content-item-info p {
  font-size: 0.85rem;
  margin: 0;
}

.content-item-actions {
  display: flex;
  gap: var(--space-sm);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-lg) * 2;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* --- Loading --- */
.loading {
  text-align: center;
  padding: var(--space-lg);
  color: var(--text-secondary);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(109, 40, 217, 0.2);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--space-md);
}

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

/* --- Toast / Notifications --- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  color: white;
  font-weight: 500;
  z-index: 1000;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast-success {
  background: var(--purple);
}

.toast-error {
  background: var(--gradient-danger);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid rgba(109, 40, 217, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover {
  color: var(--text-primary);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Section Badge --- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-grimoire {
  background: rgba(109, 40, 217, 0.2);
  color: var(--purple);
}

.badge-meditation {
  background: rgba(191, 161, 129, 0.2);
  color: var(--gold);
}

.badge-spell {
  background: rgba(220, 38, 38, 0.2);
  color: var(--red-accent);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: var(--space-md);
  }

  .sidebar-logo {
    padding-bottom: var(--space-md);
  }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .sidebar-nav li {
    flex: 1;
    min-width: 120px;
  }

  .main-content {
    margin-left: 0;
    padding: var(--space-md);
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .header-bar {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .content-item {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
  }
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
