/* Global Styles */
:root {
  --primary-color: #007bff;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --sidebar-width: 260px;
  --topbar-height: 60px;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  color: #333;
  background-color: #f8f9fa;
  overflow-x: hidden;
}

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

/* New shared layout root */
#appLayoutRoot {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

#sidebarMount {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
}

.main-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#pageContent {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
  width: 100%;
}

/* Content area */
.content {
  flex: 1;
  padding: 20px;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
  color: white;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

#sidebarMount .sidebar {
  position: sticky;
  top: 0;
  left: auto;
  height: 100%;
  width: 100%;
  background: transparent;
  box-shadow: none;
}

/* Scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.sidebar-header h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.sidebar-header small,
.sidebar-header p {
  margin: 5px 0 0 0;
  font-size: 12px;
  opacity: 0.8;
}

.sidebar-nav {
  padding: 20px 0;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav .nav-item {
  margin: 0;
}

.sidebar-nav .nav-link,
.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.3s;
  font-size: 14px;
  border-radius: 0;
  border: none;
  background: transparent;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active,
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar-nav .nav-link i,
.sidebar-nav a i {
  margin-right: 10px;
  width: 20px;
  text-align: center;
  font-size: 16px;
}


/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  z-index: 999;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.topbar h5 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.topbar-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* User menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-menu span {
  font-size: 14px;
  color: #333;
}

.user-menu .dropdown-toggle {
  background: transparent;
  border: none;
  color: #333;
  font-size: 20px;
  padding: 5px;
}

.user-menu .dropdown-toggle:hover {
  color: var(--primary-color);
}

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

/* Cards */
.card {
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.card-header {
  background: white;
  border-bottom: 1px solid #dee2e6;
  padding: 15px 20px;
  font-weight: 600;
}

/* Buttons */
.btn {
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Tables */
.table {
  font-size: 14px;
}

.table thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

/* Badges */
.badge {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
}

/* Maintenance Banner */
.maintenance-banner {
  background: #ff6b6b;
  color: white;
  padding: 12px;
  text-align: center;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 1001;
}

.maintenance-banner + .topbar {
  top: 44px;
}

.maintenance-banner + .topbar + .main-content {
  margin-top: calc(var(--topbar-height) + 44px);
}

.maintenance-banner + .topbar + #pageContent {
  margin-top: calc(var(--topbar-height) + 44px);
}

/* Session Warning */
#sessionWarning {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  min-width: 300px;
}

/* Toast Container */
#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h2 {
  color: #333;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-header p {
  color: #6c757d;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

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

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    left: 0;
    right: 0;
    padding: 0 15px;
  }

  .topbar h5 {
    font-size: 16px;
  }

  .content {
    padding: 15px;
    padding-top: 80px;
  }

  .maintenance-banner {
    left: 0;
  }

  /* Mobile menu toggle */
  .mobile-menu-toggle {
    display: block !important;
    background: transparent;
    border: none;
    font-size: 24px;
    color: #333;
    padding: 5px;
    margin-right: 10px;
  }

  /* User menu adjustments */
  .user-menu span {
    display: none;
  }

  /* Card adjustments */
  .card {
    margin-bottom: 15px;
  }

  .card-header {
    padding: 12px 15px;
  }

  .card-header h5 {
    font-size: 16px;
  }

  .card-body {
    padding: 15px;
  }

  /* Table responsive */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -15px;
    padding: 0 15px;
  }

  .table {
    font-size: 13px;
    min-width: 600px;
  }

  .table th,
  .table td {
    padding: 8px 6px;
    white-space: nowrap;
  }

  .table thead th {
    font-size: 12px;
    font-weight: 600;
  }

  /* Buttons on mobile */
  .btn {
    font-size: 13px;
    padding: 6px 12px;
  }

  .btn-sm {
    font-size: 12px;
    padding: 4px 8px;
  }

  /* Form adjustments */
  .filter-row {
    flex-direction: column;
  }

  .filter-item {
    min-width: 100%;
  }

  .row.mb-3 > [class*='col-'] {
    margin-bottom: 10px;
  }

  .row.mb-3 > [class*='col-']:last-child {
    margin-bottom: 0;
  }

  /* Login card */
  .login-card {
    max-width: 100%;
    margin: 20px;
    padding: 30px 20px;
  }

  /* Stat cards */
  .row > [class*='col-'] {
    margin-bottom: 15px;
  }

  /* Dropdown menu positioning */
  .dropdown-menu {
    font-size: 13px;
  }

  /* Card header with button */
  .card-header.d-flex {
    flex-wrap: wrap;
    gap: 10px;
  }

  .card-header .btn {
    font-size: 12px;
    white-space: nowrap;
  }

  /* Modal adjustments */
  .modal-dialog {
    margin: 10px;
  }

  .modal-body {
    padding: 15px;
  }

  /* Badge adjustments */
  .badge {
    font-size: 10px;
    padding: 3px 6px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .topbar h5 {
    font-size: 14px;
  }

  .table {
    font-size: 12px;
  }

  .table th,
  .table td {
    padding: 6px 4px;
  }

  .btn {
    font-size: 12px;
    padding: 5px 10px;
  }

  .card-header h5 {
    font-size: 14px;
  }

  .content {
    padding: 10px;
    padding-top: 75px;
  }
}

/* Desktop - hide mobile toggle */
@media (min-width: 769px) {
  .mobile-menu-toggle {
    display: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

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

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: none;
  cursor: pointer;
}

/* DataTables Overrides */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  margin-bottom: 15px;
}

.dataTables_wrapper .dataTables_paginate {
  margin-top: 15px;
}

/* Filters */
.filters-card {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.filter-row {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.filter-item {
  flex: 1;
  min-width: 200px;
}

/* Status Pills */
.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-pending {
  background: #fff3cd;
  color: #856404;
}

.status-approved {
  background: #d4edda;
  color: #155724;
}

.status-rejected {
  background: #f8d7da;
  color: #721c24;
}

.status-active {
  background: #d1ecf1;
  color: #0c5460;
}
