/* ============================================================
   GW CONTA - Estilos principales
   Diseño moderno, minimalista con modo claro/oscuro
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ──────────────────────────────────── */
:root {
  --accent: #4f6ef2;
  --accent-hover: #3b57d6;
  --accent-soft: rgba(79, 110, 242, 0.12);

  --bg-body: #f4f6fb;
  --bg-card: #ffffff;
  --bg-sidebar: #1a1f36;
  --bg-topbar: #ffffff;

  --text-primary: #1e253a;
  --text-secondary: #6b7280;
  --text-sidebar: #a0aec0;
  --text-sidebar-active: #ffffff;

  --border: #e5e9f2;
  --shadow: 0 2px 12px rgba(0, 0, 0, .07);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .10);

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --topbar-h: 60px;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

/* ── Modo oscuro ──────────────────────────────── */
[data-theme="dark"] {
  --bg-body: #0f1117;
  --bg-card: #1a1f2e;
  --bg-sidebar: #12151f;
  --bg-topbar: #1a1f2e;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;

  --border: #2a3044;
  --shadow: 0 2px 12px rgba(0, 0, 0, .3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .4);
}

/* ── Reset & Base ───────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
  transition: background .3s, color .3s;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* ── Layout ─────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-brand .brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.02em;
}

.sidebar-brand .brand-sub {
  font-size: .7rem;
  color: var(--text-sidebar);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-user {
  padding: 12px 16px;
  margin: 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .05);
}

.sidebar-user .user-name {
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
}

.sidebar-user .user-role {
  font-size: .7rem;
  color: var(--text-sidebar);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: .65rem;
  font-weight: 600;
  color: var(--text-sidebar);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 12px 20px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-sidebar);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: all .2s;
  position: relative;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .07);
}

.sidebar-link.active {
  color: var(--text-sidebar-active);
  background: linear-gradient(90deg, rgba(79, 110, 242, .25), transparent);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.sidebar-link i {
  width: 18px;
  text-align: center;
  font-size: .95rem;
}

/* ── Sidebar Dropdowns ── */
.sidebar-dropdown {
  display: flex;
  flex-direction: column;
}

.sidebar-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 20px;
  color: var(--text-sidebar);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.sidebar-dropdown-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, .05);
}

.sidebar-dropdown-toggle i:first-child {
  margin-right: 10px;
  width: 18px;
  text-align: center;
}

.sidebar-dropdown-toggle .arrow {
  font-size: .7rem;
  transition: transform .2s;
  opacity: .5;
}

.sidebar-dropdown.show .sidebar-dropdown-toggle {
  color: #fff;
  background: rgba(255, 255, 255, .03);
}

.sidebar-dropdown.show .arrow {
  transform: rotate(90deg);
  opacity: 1;
}

.sidebar-submenu {
  display: none;
  list-style: none;
  padding: 4px 0 8px 48px;
  margin: 0;
  background: rgba(0, 0, 0, .15);
}

.sidebar-dropdown.show .sidebar-submenu {
  display: block;
}

.submenu-link {
  display: block;
  padding: 6px 0;
  color: var(--text-sidebar);
  font-size: .8rem;
  font-weight: 400;
  transition: color .2s;
}

.submenu-link:hover,
.submenu-link.active {
  color: #fff;
}

.submenu-link.active {
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

/* ── Main Content ───────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow);
  transition: background .3s;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Dark mode toggle */
.dark-toggle {
  background: var(--accent-soft);
  border: none;
  color: var(--accent);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s;
  font-size: 1rem;
}

.dark-toggle:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Page Content ───────────────────────────── */
.page-body {
  flex: 1;
  padding: 24px;
}

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background .3s, border .3s;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h5,
.card-header h6 {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: all .25s;
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.stat-icon.success {
  background: rgba(16, 185, 129, .12);
  color: var(--success);
}

.stat-icon.warning {
  background: rgba(245, 158, 11, .12);
  color: var(--warning);
}

.stat-icon.danger {
  background: rgba(239, 68, 68, .12);
  color: var(--danger);
}

.stat-icon.info {
  background: rgba(59, 130, 246, .12);
  color: var(--info);
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: .78rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* Indicator cards (UF, UTM...) */
.indicator-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: center;
}

.indicator-name {
  font-size: .7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 600;
}

.indicator-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.indicator-date {
  font-size: .68rem;
  color: var(--text-secondary);
}

/* ── Tables ─────────────────────────────────── */
.table {
  color: var(--text-primary);
}

.table th {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border) !important;
}

.table td {
  vertical-align: middle;
  border-color: var(--border);
  font-size: .875rem;
  color: var(--text-primary);
  /* Force primary color on cells */
}

.table tbody tr {
  transition: background .15s;
}

.table-hover tbody tr:hover {
  background: var(--accent-soft) !important;
}

/* Especial para clases de texto en tablas */
.table .text-secondary {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .table {
  --bs-table-bg: transparent;
}

[data-theme="dark"] .table-striped>tbody>tr:nth-of-type(odd)>* {
  --bs-table-accent-bg: rgba(255, 255, 255, .03);
}

/* ── Buttons ─────────────────────────────────── */
.btn {
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  padding: 0.5rem 1.25rem;
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-sm,
.btn-group-sm>.btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
}

.btn:focus {
  box-shadow: 0 0 0 0.25rem var(--accent-soft);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 4px 10px rgba(79, 110, 242, 0.25);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 6px 14px rgba(79, 110, 242, 0.35);
  transform: translateY(-2px);
}

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
  border-width: 2px;
}

.btn-outline-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 4px 10px rgba(79, 110, 242, 0.2);
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

/* ── Forms ───────────────────────────────────── */
.form-control,
.form-select {
  background: var(--bg-body);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  transition: all .2s;
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-card);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  color: var(--text-primary);
}

.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: rgba(255, 255, 255, .04);
  color: var(--text-primary);
  border-color: var(--border);
}

[data-theme="dark"] .form-control::placeholder {
  color: var(--text-secondary);
}

[data-theme="dark"] .form-select option {
  background: var(--bg-card);
}

/* ── Badges ─────────────────────────────────── */
.badge {
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: .03em;
}

/* ── Alerts ──────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  font-size: .875rem;
  border: none;
}

.alert-success {
  background: rgba(16, 185, 129, .12);
  color: #059669;
}

.alert-danger {
  background: rgba(239, 68, 68, .12);
  color: #dc2626;
}

.alert-warning {
  background: rgba(245, 158, 11, .12);
  color: #d97706;
}

.alert-info {
  background: rgba(59, 130, 246, .12);
  color: #2563eb;
}

[data-theme="dark"] .alert-success {
  color: #34d399;
}

[data-theme="dark"] .alert-danger {
  color: #f87171;
}

[data-theme="dark"] .alert-warning {
  color: #fbbf24;
}

[data-theme="dark"] .alert-info {
  color: #60a5fa;
}

/* ── Login Page ──────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 40%, rgba(79, 110, 242, .15) 0%, transparent 60%),
    var(--bg-body);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  border: 1px solid var(--border);
  animation: slideUp .4s ease;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--accent-soft);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--accent);
  margin: 0 auto 16px;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Misc ────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-header p {
  font-size: .85rem;
  color: var(--text-secondary);
  margin: 0;
}

.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: .4;
}

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 1.3rem;
  }
}

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ── Transitions ─────────────────────────────── */
.card,
.sidebar,
.topbar,
.form-control,
.form-select {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}