/* =============================================
   Design System — Prosegur Platform
   Dark/Light mode via CSS custom properties
   Brand colors injected dynamically from BrandConfig
   ============================================= */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  /* Brand (overridden by BrandConfig via inline style) */
  --brand-primary: #1B3A5C;
  --brand-secondary: #28A745;
  --brand-accent: #FFC107;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 0.9375rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --topbar-height: 60px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 20px rgba(var(--brand-primary-rgb, 27,58,92), 0.15);
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg-body: #F0F2F5;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F8F9FA;
  --bg-sidebar: #1A1D23;
  --bg-sidebar-hover: #2A2D35;
  --bg-sidebar-active: var(--brand-primary);
  --bg-topbar: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-input: #F8F9FA;
  --bg-badge: #E9ECEF;

  --text-primary: #1A1D23;
  --text-secondary: #6C757D;
  --text-muted: #ADB5BD;
  --text-sidebar: #B0B7C3;
  --text-sidebar-active: #FFFFFF;
  --text-on-primary: #FFFFFF;
  --text-link: var(--brand-primary);

  --border-color: #E2E8F0;
  --border-light: #F1F3F5;
  --divider: #E9ECEF;

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

  --overlay: rgba(0,0,0,0.4);
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg-body: #0D1117;
  --bg-surface: #161B22;
  --bg-surface-hover: #1C2333;
  --bg-sidebar: #0D1117;
  --bg-sidebar-hover: #1C2333;
  --bg-sidebar-active: var(--brand-primary);
  --bg-topbar: #161B22;
  --bg-card: #161B22;
  --bg-input: #1C2333;
  --bg-badge: #21262D;

  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --text-muted: #484F58;
  --text-sidebar: #8B949E;
  --text-sidebar-active: #FFFFFF;
  --text-on-primary: #FFFFFF;
  --text-link: #58A6FF;

  --border-color: #21262D;
  --border-light: #1C2333;
  --divider: #21262D;

  --status-success: #3FB950;
  --status-warning: #D29922;
  --status-danger: #F85149;
  --status-info: #58A6FF;

  --overlay: rgba(0,0,0,0.6);
}

/* ── Base ── */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-body);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-base), color var(--transition-base);
}
a { color: var(--text-link); text-decoration: none; transition: opacity var(--transition-fast); }
a:hover { opacity: 0.8; }

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

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-slow), transform var(--transition-slow);
  overflow-x: hidden;
}
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}
.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: var(--space-sm);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  transition: padding var(--transition-slow);
}
body.sidebar-collapsed .sidebar-brand {
  padding: 0 16px;
  justify-content: center;
}
.sidebar-brand img {
  height: 32px;
  width: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.sidebar-brand h1 {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  transition: opacity var(--transition-fast), width var(--transition-fast);
}
body.sidebar-collapsed .sidebar-brand h1 {
  opacity: 0;
  width: 0;
  overflow: hidden;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-sm);
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.nav-section-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-lg) var(--space-md) var(--space-sm);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-sidebar);
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  transition: all var(--transition-fast);
  white-space: nowrap;
  font-size: var(--font-size-sm);
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #FFFFFF;
  opacity: 1;
}
.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 500;
}
.nav-item .nav-icon { font-size: 1.15rem; width: 24px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--status-danger);
  color: white;
  font-size: var(--font-size-xs);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}
.nav-item span:not(.nav-badge) {
  transition: opacity var(--transition-fast);
}

body.sidebar-collapsed .nav-section-title {
  display: none;
}
body.sidebar-collapsed .nav-item {
  color: transparent !important;
}
body.sidebar-collapsed .nav-icon {
  color: var(--text-sidebar) !important;
}
body.sidebar-collapsed .nav-item.active .nav-icon {
  color: var(--text-sidebar-active) !important;
}
body.sidebar-collapsed .nav-item:hover .nav-icon {
  color: #FFFFFF !important;
}
body.sidebar-collapsed .nav-badge {
  display: none;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-slow);
}
body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed);
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}
.topbar-left { display: flex; align-items: center; gap: var(--space-md); }
.topbar-left h2 { font-size: var(--font-size-lg); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: var(--space-md); }

/* ── Page Content ── */
.page-content { padding: var(--space-xl); max-width: 1400px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: var(--font-size-base); font-weight: 600; }
.card-body { padding: var(--space-lg); }

/* ── Stats Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--stat-color, var(--brand-primary));
  border-radius: 0 2px 2px 0;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--bg-badge);
  flex-shrink: 0;
}
.stat-info { flex: 1; }
.stat-label { font-size: var(--font-size-sm); color: var(--text-secondary); }
.stat-value { font-size: var(--font-size-2xl); font-weight: 700; line-height: 1.2; }
.stat-change {
  font-size: var(--font-size-xs);
  font-weight: 500;
  margin-top: var(--space-xs);
}
.stat-change.up { color: var(--status-success); }
.stat-change.down { color: var(--status-danger); }

/* ── Tables ── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
}
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-sm);
}
.data-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}
.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-surface-hover); }

/* ── Badges / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: rgba(40,167,69,0.12); color: var(--status-success); }
.badge-warning { background: rgba(255,193,7,0.15); color: var(--status-warning); }
.badge-danger  { background: rgba(220,53,69,0.12); color: var(--status-danger); }
.badge-info    { background: rgba(23,162,184,0.12); color: var(--status-info); }
.badge-neutral { background: var(--bg-badge); color: var(--text-secondary); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  font-family: var(--font-family);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.btn-primary {
  background: var(--brand-primary);
  color: var(--text-on-primary);
}
.btn-primary:hover { filter: brightness(1.15); }
.btn-secondary {
  background: var(--bg-badge);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border-color); }
.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.1rem;
}
.btn-icon:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

/* ── Theme Toggle ── */
.theme-toggle {
  position: relative;
  width: 44px; height: 24px;
  background: var(--bg-badge);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: none;
  transition: background var(--transition-base);
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: var(--brand-primary);
  border-radius: 50%;
  transition: transform var(--transition-base);
}
[data-theme="dark"] .theme-toggle::after {
  transform: translateX(20px);
}

/* ── User Menu ── */
.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.user-menu:hover { background: var(--bg-surface-hover); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--font-size-sm);
}
.user-name { font-size: var(--font-size-sm); font-weight: 500; }

/* ── License Banners ── */
.license-banner {
  padding: var(--space-sm) var(--space-xl);
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: 500;
}
.license-banner.warning { background: var(--status-warning); color: #000; }
.license-banner.grace { background: var(--status-danger); color: #fff; }

/* ── Grid Layouts ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: var(--space-md); }
  .topbar { padding: 0 var(--space-md); }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeIn var(--transition-slow) both; }
.animate-in:nth-child(2) { animation-delay: 50ms; }
.animate-in:nth-child(3) { animation-delay: 100ms; }
.animate-in:nth-child(4) { animation-delay: 150ms; }

/* ── Forms ── */
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(27,58,92,0.12);
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-checkbox { width: auto; }
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}
.form-group { margin-bottom: var(--space-lg); }

/* ── Delete Confirm ── */
.delete-card {
  max-width: 500px;
  margin: var(--space-2xl) auto;
  text-align: center;
}

