/* ═══════════════════════════════════════════════════════════════════
   Mirage App — Design System
   Paleta: Preto profundo + Dourado + Branco
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary:    #0D0D10;
  --bg-secondary:  #13131A;
  --bg-card:       #1A1A26;
  --bg-sidebar:    #0A0A12;
  --bg-hover:      #22223A;

  --gold-primary:  #D4A017;
  --gold-light:    #F0BE35;
  --gold-dim:      #8A6510;
  --gold-bg:       rgba(212, 160, 23, 0.10);

  --text-primary:  #F0EDE8;
  --text-muted:    #8A8A9A;
  --text-dim:      #4A4A5A;

  --border-color:  #2A2A3A;
  --border-gold:   rgba(212, 160, 23, 0.30);

  --danger:        #DC3545;
  --success:       #28A745;
  --warning:       #FFC107;
  --info:          #17A2B8;

  --sidebar-width: 260px;
  --radius:        10px;
  --radius-sm:     6px;
  --transition:    0.2s ease;
}

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

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--gold-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

/* Scrollbar personalizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-primary); }

/* ─── Layout Principal ────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
}

.sidebar-logo {
  text-align: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-gold);
  margin-bottom: 1.5rem;
}

.sidebar-logo img {
  max-width: 180px;
  height: auto;
}

.sidebar-letra {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin-bottom: 0.25rem;
}

.sidebar-brand {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Grupo de seção */
.nav-section {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  font-weight: 700;
  padding: 1rem 0 0.4rem 0.5rem;
  margin-top: 0.5rem;
}

.nav-section-toggle {
  display: flex;
  align-items: center;
  user-select: none;
  transition: color 0.15s;
}

.nav-section-toggle:hover {
  color: var(--gold-primary);
}

.nav-section-chevron {
  transition: transform 0.2s ease;
}

.nav-section-toggle[aria-expanded="true"] .nav-section-chevron {
  transform: rotate(180deg);
}

/* Nav links */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-muted);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-link i, .nav-link .bi {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  color: var(--text-dim);
  transition: color var(--transition);
}

.nav-link:hover {
  background: var(--gold-bg);
  color: var(--gold-primary);
}

.nav-link:hover i, .nav-link:hover .bi {
  color: var(--gold-primary);
}

.nav-link.active {
  background: var(--gold-bg);
  color: var(--gold-primary);
  border-left: 3px solid var(--gold-primary);
}

.nav-link.active i, .nav-link.active .bi {
  color: var(--gold-primary);
}

/* Submenu */
.submenu {
  padding-left: 1rem;
  border-left: 1px solid var(--border-color);
  margin-left: 0.75rem;
}

.submenu .nav-link {
  font-size: 0.825rem;
  padding: 0.4rem 0.6rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold-bg);
  border: 2px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-primary);
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Navbar mobile ──────────────────────────────────────────── */
.navbar-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 200;
}

.navbar-mobile .brand-logo {
  height: 36px;
}

/* ─── Page Header ────────────────────────────────────────────── */
.page-header {
  padding: 1.75rem 2rem 0;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.page-header-divider {
  height: 1px;
  background: linear-gradient(to right, var(--border-gold), transparent);
  margin: 1rem 2rem 0;
}

/* ─── Content Area ───────────────────────────────────────────── */
.content-area {
  padding: 1.5rem 2rem 2rem;
  flex: 1;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.875rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header .card-icon {
  color: var(--gold-primary);
}

.card-body { padding: 1.25rem; }

/* Stats cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-gold);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-primary), var(--gold-light));
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--gold-bg);
  border: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--gold-primary);
  margin-bottom: 1rem;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.25rem;
}

/* ─── Botões ──────────────────────────────────────────────────── */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.45rem 1rem;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn-gold {
  background: var(--gold-primary);
  color: #0A0A12;
  border-color: var(--gold-primary);
  font-weight: 600;
}

.btn-gold:hover {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: #0A0A12;
}

.btn-outline-gold {
  background: transparent;
  color: var(--gold-primary);
  border-color: var(--border-gold);
}

.btn-outline-gold:hover {
  background: var(--gold-bg);
  color: var(--gold-light);
  border-color: var(--gold-primary);
}

.btn-outline-light {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-color);
}

.btn-outline-light:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #b02a37;
  border-color: #b02a37;
  color: #fff;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-outline-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* ─── Formulários ────────────────────────────────────────────── */
.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.form-control, .form-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  padding: 0.5rem 0.85rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
  background: var(--bg-secondary);
  border-color: var(--gold-primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.15);
  outline: none;
}

.form-control::placeholder { color: var(--text-dim); }

.form-control.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.invalid-feedback { color: var(--danger); font-size: 0.78rem; }

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

/* Checkboxes */
.form-check-input {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  width: 1.1em;
  height: 1.1em;
}

.form-check-input:checked {
  background-color: var(--gold-primary);
  border-color: var(--gold-primary);
}

.form-check-input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.15);
}

.form-check-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Grupo de checkboxes (MultiCheckboxField) */
ul.multi-checkbox {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

ul.multi-checkbox li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}

ul.multi-checkbox li:hover {
  border-color: var(--border-gold);
}

ul.multi-checkbox li input[type="checkbox"]:checked + label,
ul.multi-checkbox li:has(input:checked) {
  color: var(--gold-primary);
}

ul.multi-checkbox li:has(input:checked) {
  border-color: var(--gold-primary);
  background: var(--gold-bg);
}

ul.multi-checkbox li label {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ─── Tabelas ─────────────────────────────────────────────────── */
.table-dark-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.table-dark-custom thead th {
  background: var(--bg-secondary);
  color: var(--gold-primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-gold);
  white-space: nowrap;
}

.table-dark-custom thead th a {
  color: var(--gold-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.sort-link:hover { color: var(--gold-light, var(--accent)); }
.sort-link.active { color: var(--gold-light, #fff); }
.sort-link .bi { font-size: 0.7rem; opacity: 0.85; }

.table-dark-custom tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}

.table-dark-custom tbody tr:hover {
  background: var(--bg-hover);
}

.table-dark-custom tbody td {
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  vertical-align: middle;
}

.table-dark-custom tbody tr:last-child {
  border-bottom: none;
}

/* ─── Badges ──────────────────────────────────────────────────── */
.badge-gold {
  background: var(--gold-bg);
  color: var(--gold-primary);
  border: 1px solid var(--border-gold);
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
}

.badge-success {
  background: rgba(40, 167, 69, 0.15);
  color: #5cb85c;
  border: 1px solid rgba(40, 167, 69, 0.3);
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
}

.badge-danger {
  background: rgba(220, 53, 69, 0.15);
  color: #f87171;
  border: 1px solid rgba(220, 53, 69, 0.3);
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
}

.badge-muted {
  background: rgba(90, 90, 120, 0.2);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
}

/* ─── Flash Messages ─────────────────────────────────────────── */
.flash-container {
  padding: 0 2rem;
  margin-top: 1rem;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-success {
  background: rgba(40, 167, 69, 0.12);
  color: #5cb85c;
  border-color: rgba(40, 167, 69, 0.3);
}

.alert-danger {
  background: rgba(220, 53, 69, 0.12);
  color: #f87171;
  border-color: rgba(220, 53, 69, 0.3);
}

.alert-warning {
  background: rgba(255, 193, 7, 0.12);
  color: #ffc107;
  border-color: rgba(255, 193, 7, 0.3);
}

.alert-info {
  background: rgba(23, 162, 184, 0.12);
  color: #5bc0de;
  border-color: rgba(23, 162, 184, 0.3);
}

/* ─── Filtros ────────────────────────────────────────────────── */
.filter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

/* ─── Overlay sidebar mobile ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 99;
}

/* ─── Auth Layout ────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(212,160,23,0.06) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius) * 1.5);
  padding: 2.5rem 2rem;
  position: relative;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo img {
  max-width: 200px;
  height: auto;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.75rem;
}

/* ─── Divisores ──────────────────────────────────────────────── */
.section-divider {
  height: 1px;
  background: linear-gradient(to right, var(--border-gold), transparent);
  margin: 1.25rem 0;
}

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

/* ─── Permission grid ───────────────────────────────────────── */
.perm-group-title {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #D4A017 !important;
  font-weight: 700;
  margin: 1.25rem 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(212,160,23,0.4);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.perm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 5px;
  background: #2A2A3E !important;
  border: 1px solid #3A3A52 !important;
  transition: background var(--transition), border-color var(--transition);
}

.perm-item:hover {
  background: #32324A !important;
  border-color: var(--gold-primary) !important;
}

.perm-item-label {
  color: #EDEAE4 !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  line-height: 1.3;
}

.perm-item-endpoint {
  font-size: 0.7rem !important;
  color: #8888AA !important;
  font-family: 'Courier New', monospace;
  margin-top: 2px;
}

/* ─── Toggle switch ─────────────────────────────────────────── */
.form-switch .form-check-input {
  width: 2.5em;
  height: 1.3em;
  cursor: pointer;
}

.form-switch .form-check-input:checked {
  background-color: var(--gold-primary);
  border-color: var(--gold-primary);
}

/* ─── Log badges ────────────────────────────────────────────── */
.log-acao {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
}

.log-acao-login   { background: rgba(23,162,184,.15); color: #5bc0de; border: 1px solid rgba(23,162,184,.3); }
.log-acao-logout  { background: rgba(90,90,120,.2);   color: var(--text-muted); border: 1px solid var(--border-color); }
.log-acao-create  { background: rgba(40,167,69,.12);  color: #5cb85c; border: 1px solid rgba(40,167,69,.3); }
.log-acao-edit    { background: rgba(212,160,23,.12); color: var(--gold-primary); border: 1px solid var(--border-gold); }
.log-acao-delete  { background: rgba(220,53,69,.12);  color: #f87171; border: 1px solid rgba(220,53,69,.3); }
.log-acao-default { background: rgba(90,90,120,.15);  color: var(--text-muted); border: 1px solid var(--border-color); }

/* ─── Collapse submenu ──────────────────────────────────────── */
.collapse .nav-link {
  font-size: 0.82rem;
  padding: 0.4rem 0.65rem;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 150;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .navbar-mobile {
    display: flex;
  }

  .page-header,
  .flash-container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .content-area {
    padding: 1rem;
  }

  .stat-card-value { font-size: 1.5rem; }
}

/* ─── Utilitários ───────────────────────────────────────────── */
.text-gold  { color: var(--gold-primary) !important; }
.text-muted-custom { color: var(--text-muted) !important; }
.bg-card-custom { background: var(--bg-card) !important; }
.border-gold { border-color: var(--border-gold) !important; }
.gap-2 { gap: 0.5rem; }
.fw-600 { font-weight: 600; }
.fs-sm  { font-size: 0.82rem; }
