/* Base Styles */
:root {
  --primary: #e11d48;
  --primary-dark: #be123c;
  --secondary: #f59e0b;
  --success: #4bb543;
  --danger: #f44336;
  --warning: #ff9800;
  --info: #2196f3;
  --light: #f8f9fa;
  --dark: #0f172a;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --border-radius: 0.375rem;
  --transition: all 0.2s ease-in-out;
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 70px;
  --brand-gradient: linear-gradient(135deg, #f59e0b 0%, #e11d48 100%);
}

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

body {
  font-family: var(--font-sans);
  color: var(--gray-800);
  line-height: 1.5;
  background-color: #f3f4f6;
  -webkit-font-smoothing: antialiased;
  font-size: 0.9rem;
}

/* Layout Utilities */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-grow-1 { flex-grow: 1; }
.min-vh-100 { min-height: 100vh; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.mt-3 { margin-top: 1rem; }
.mb-3 { margin-bottom: 1rem; }
.p-3 { padding: 1rem; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: #0f172a;
  color: #fff;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1030;
  transition: all 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 4px 0 10px rgba(0,0,0,0.05);
}

.sidebar .nav-link {
  color: rgba(255,255,255,0.75);
  padding: 0.65rem 1rem;
  margin: 0.2rem 0.75rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
}

.sidebar .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.sidebar .nav-link.active {
  color: #fff;
  background: var(--brand-gradient);
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

.sidebar .nav-link i {
  width: 24px;
  font-size: 1.1rem;
  margin-right: 0.75rem;
  text-align: center;
  transition: margin 0.3s;
}

/* Sidebar Collapsed (Desktop) */
@media (min-width: 992px) {
  .sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar.collapsed .nav-link {
    padding: 0.75rem 0;
    justify-content: center;
    margin: 0.2rem 0.4rem;
  }

  .sidebar.collapsed .nav-link i {
    margin-right: 0;
    font-size: 1.25rem;
  }

  .sidebar.collapsed .nav-link span,
  .sidebar.collapsed .brand-logo,
  .sidebar.collapsed .text-muted.small,
  .sidebar.collapsed .text-uppercase {
    display: none !important;
  }
}

/* Content Wrapper */
.content-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  background-color: #f3f4f6;
}

@media (min-width: 992px) {
  .sidebar.collapsed ~ .content-wrapper {
    margin-left: var(--sidebar-collapsed-width);
  }
}

/* Mobile Sidebar */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .content-wrapper {
    margin-left: 0;
  }
}

/* Utility Enhancements */
.card .fs-4 { font-weight: 700; }
.login-card { border-radius: 1rem; box-shadow: 0 15px 35px rgba(0,0,0,0.08); }
.form-label { color: #0b0f19; font-weight: 600; }

.badge.bg-success { background-color: var(--success) !important; }
.badge.bg-danger { background-color: var(--danger) !important; }
.badge.bg-warning { background-color: var(--warning) !important; color: #111 !important; }

.table thead th { background-color: #f3f4f6; }
.table tbody tr:hover { background-color: rgba(67,97,238,0.04); }

/* Top Navigation (Compact) */
.navbar {
  backdrop-filter: saturate(180%) blur(6px);
  padding: 0.5rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  background: rgba(255,255,255,0.95) !important;
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* Footer */
footer {
  background-color: #fff;
  padding: 1.5rem 0;
  margin-top: auto;
  border-top: 1px solid var(--gray-200);
}

/* Cards */
.card {
  border: none;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  transition: var(--transition);
  border: 1px solid rgba(0,0,0,0.05);
}

/* Buttons */
.btn {
  padding: 0.5rem 1.25rem;
  border-radius: var(--border-radius);
  font-weight: 500;
  transition: var(--transition);
}
.btn-primary { background: var(--brand-gradient); border: none; color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #e11d48 0%, #f59e0b 100%); opacity: 0.95; box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25); }

/* Forms */
.form-control {
  padding: 0.6rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  transition: var(--transition);
}
.input-group .form-control { height: 44px; }
.input-group-text { border-right: 0; }
.input-group .form-control { border-left: 0; }
.input-group .btn { height: 44px; border-color: var(--gray-300); }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 0.2rem rgba(67,97,238,0.25); }

/* Tables */
.table {
  width: 100%;
  margin-bottom: 1rem;
  color: var(--gray-700);
  background-color: #fff;
  border-collapse: collapse;
}
.table th {
  background-color: var(--gray-100);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--gray-200);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(67, 97, 238, 0.15);
  outline: 0;
}

/* Tables */
.table {
  width: 100%;
  margin-bottom: 1rem;
  color: var(--gray-700);
  border-collapse: collapse;
  background-color: #fff;
  border-radius: var(--border-radius);
  overflow: hidden;
}

.table th,
.table td {
  padding: 1rem 1.5rem;
  vertical-align: middle;
  border-top: 1px solid var(--gray-200);
}

.table thead th {
  background-color: var(--gray-50);
  color: var(--gray-700);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
}

.table tbody tr:last-child td {
  border-bottom: 1px solid var(--gray-200);
}

.table tbody tr:hover {
  background-color: rgba(67, 97, 238, 0.03);
}

/* Page header and guidance */
.page-intro {
  background: #ffffff;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.page-intro .lead {
  color: var(--gray-700);
  font-weight: 500;
}

/* Empty state */
.empty-state {
  border: 1px dashed var(--gray-300);
  border-radius: var(--border-radius);
  padding: 2rem;
  text-align: center;
  color: var(--gray-600);
  background: #fff;
}

.empty-state i {
  font-size: 1.5rem;
  color: var(--gray-500);
}

/* Quick actions */
.quick-actions .card {
  border: 1px solid var(--gray-200);
}

.quick-actions .card:hover {
  transform: translateY(-2px);
}

/* Charts */
.chart-container {
  height: 220px;
}
.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}


/* Global Loader */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  backdrop-filter: blur(2px);
  z-index: 2000;
  display: grid;
  place-items: center;
}
.loader-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  color: #111;
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.loader-overlay[data-theme="dark"] .loader-content { background: #0b0f19; color: #fff; }

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .header {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Auth Pages */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 10% 10%, #eef2f7 0%, #e6ebf3 50%, #dde3ee 100%);
  padding: 2rem;
}

.auth-card {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: 0 20px 50px rgba(20, 22, 34, 0.12);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.auth-header {
  text-align: center;
  padding: 2rem 2rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.auth-logo {
  margin-bottom: 1.5rem;
  display: inline-block;
}

.login-logo {
  height: 60px;
  width: auto;
  max-width: 100%;
}

.auth-logo .brand-logo {
  height: 50px;
  width: auto;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: var(--gray-600);
  font-size: 0.9375rem;
}

.auth-body {
  padding: 2rem;
}

.auth-card .auth-body {
  background: #fff;
}

.input-group-text {
  background-color: #f8f9fb;
  border-color: var(--gray-300);
}

.auth-card .btn {
  height: 46px;
  font-weight: 600;
}

.auth-title { letter-spacing: 0.2px; }
.auth-subtitle { letter-spacing: 0.1px; }

/* Alerts */
.alert {
  padding: 0.875rem 1.25rem;
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
  border: 1px solid transparent;
}

.alert-success {
  color: #0f5132;
  background-color: #d1e7dd;
  border-color: #badbcc;
}

.alert-danger {
  color: #842029;
  background-color: #f8d7da;
  border-color: #f5c2c7;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35em 0.65em;
  font-size: 75%;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 50rem;
}

.badge-success {
  color: #fff;
  background-color: var(--success);
}

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

.badge-warning {
  color: #000;
  background-color: var(--warning);
}

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

::-webkit-scrollbar-track {
  background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 4px;
}

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