html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

/* ==========================================
   CSS VARIABLES - DESIGN TOKENS
   ========================================== */
:root {
  /* Color Palette */
  --bg-neutral: #f8f9fa;
  --bg-white: #ffffff;
  --bg-primary: #4a6fa5;
  --bg-primary-dark: #3a5a8f;
  --bg-success: #28a745;
  --bg-info: #5a9fd4;
  --bg-warning: #ffc107;
  --bg-danger: #dc3545;
  
  /* Sidebar Colors */
  --sidebar-bg: #4a6fa5;
  --sidebar-bg-gradient: linear-gradient(180deg, #4a6fa5 10%, #3a5a8f 100%);
  --sidebar-dark: #3a5a8f;
  
  /* Borders & Lines */
  --border-color: #dee2e6;
  --border-subtle: #e9ecef;
  --border-radius: 0.375rem;
  --border-radius-sm: 0.25rem;
  --border-radius-lg: 0.5rem;
  
  /* Text Colors */
  --text-primary: #2c3e50;
  --text-secondary: #6c757d;
  --text-muted: #95a5a6;
  --text-white: #ffffff;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Shadows */
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  
  /* Accent Color for Section Headers */
  --accent-blue: #5a9fd4;
  --accent-blue-light: #e8f4fd;
}

/* ==========================================
   TYPOGRAPHY - CLEAN & READABLE
   ========================================== */
html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
}

body {
  background-color: var(--bg-neutral);
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--bg-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--bg-primary-dark);
}

/* ==========================================
   SECTION HEADERS - SUBTLE BLUE ACCENT
   ========================================== */
.section-header {
  display: flex;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-blue);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--border-subtle);
}

.section-header i {
  margin-right: var(--spacing-sm);
  font-size: 1.25rem;
}

.section-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: var(--spacing-xl) 0;
}

/* ==========================================
   CARDS - MODERN CLEAN DESIGN
   ========================================== */
.card {
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background-color: var(--bg-white);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-lg);
  overflow: hidden;
}

.card-header {
  background-color: #f8f9fc;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  color: var(--accent-blue);
}

.card-header h6,
.card-header .h6 {
  margin: 0;
  font-weight: 600;
  color: var(--accent-blue);
  font-size: 1rem;
}

.card-header i {
  color: var(--accent-blue);
}

.card-body {
  padding: 1.5rem;
}

.card.shadow-sm {
  box-shadow: var(--shadow-md) !important;
}

.card-footer {
  background-color: #f8f9fc;
  border-top: 1px solid var(--border-subtle);
  padding: 0.75rem 1.25rem;
}

/* ==========================================
   INFO BOXES - FOR DETAILS PAGES
   ========================================== */
.info-box {
  border: 1px solid var(--border-subtle);
  padding: 1rem;
  border-radius: var(--border-radius-sm);
  background-color: var(--bg-white);
  transition: all 0.2s ease;
  margin-bottom: var(--spacing-md);
}

.info-box:hover {
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}

.info-box .detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  display: block;
}

.info-box .detail-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
  margin: 0;
}

/* Standalone labels/values without info-box */
.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  display: block;
}

.detail-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ==========================================
   FORM STYLING - CLEAN & CONSISTENT
   ========================================== */
.form-label {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.form-control,
.form-select {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 0.2rem rgba(90, 159, 212, 0.25);
  outline: none;
}

.form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.form-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Input Groups */
.input-group-text {
  background-color: #f8f9fc;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* Form sections */
.form-section {
  margin-bottom: var(--spacing-xl);
}

.form-section-header {
  display: flex;
  align-items: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-blue);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border-subtle);
}

.form-section-header i {
  margin-right: var(--spacing-sm);
}

/* ==========================================
   TABLES - CLEAN LIST PAGES
   ========================================== */
.table {
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-white);
  margin-bottom: 0;
}

.table thead th {
  background-color: #f8f9fc;
  border-bottom: 2px solid var(--border-color);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-blue);
  padding: 0.875rem 0.75rem;
  vertical-align: middle;
}

.table tbody td {
  padding: 0.875rem 0.75rem;
  vertical-align: middle;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-hover tbody tr {
  transition: background-color 0.15s ease;
}

.table-hover tbody tr:hover {
  background-color: #f8f9fc;
}

/* Table responsive wrapper */
.table-responsive {
  border-radius: var(--border-radius);
  overflow: hidden;
}

/* ==========================================
   BUTTONS - MODERN & ACCESSIBLE
   ========================================== */
.btn {
  border-radius: var(--border-radius-sm);
  padding: 0.5rem 1rem;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn-primary {
  background-color: var(--bg-primary);
  border-color: var(--bg-primary);
  color: var(--text-white) !important;
}

.btn-primary:hover {
  background-color: var(--bg-primary-dark);
  border-color: var(--bg-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-outline-primary {
  border-color: var(--bg-primary);
  color: var(--bg-primary);
}

.btn-outline-primary:hover {
  background-color: var(--bg-primary);
  color: var(--text-white);
}

.btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
  color: var(--text-white);
}

.btn-outline-secondary {
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-outline-secondary:hover {
  background-color: #6c757d;
  border-color: #6c757d;
  color: var(--text-white);
}

.btn-success {
  background-color: var(--bg-success);
  border-color: var(--bg-success);
}

.btn-warning {
  background-color: var(--bg-warning);
  border-color: var(--bg-warning);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--bg-danger);
  border-color: var(--bg-danger);
}

.btn-info {
  background-color: var(--bg-info);
  border-color: var(--bg-info);
  color: var(--text-white);
}

.btn-outline-info {
  border-color: var(--bg-info);
  color: var(--bg-info);
}

.btn-outline-info:hover {
  background-color: var(--bg-info);
  color: var(--text-white);
}

/* Action button groups */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ==========================================
   BADGES - CLEAN STATUS INDICATORS
   ========================================== */
.badge {
  padding: 0.35em 0.65em;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
}

.badge.bg-primary {
  background-color: var(--bg-primary) !important;
}

.badge.bg-info {
  background-color: var(--bg-info) !important;
}

/* ==========================================
   ALERTS - FEEDBACK MESSAGES
   ========================================== */
.alert {
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  padding: 0.875rem 1rem;
  margin-bottom: var(--spacing-lg);
}

.alert i {
  margin-right: 0.5rem;
}

.alert-info {
  background-color: #d1ecf1;
  border-color: #bee5eb;
  color: #0c5460;
}

.alert-success {
  background-color: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
}

.alert-warning {
  background-color: #fff3cd;
  border-color: #ffeaa7;
  color: #856404;
}

.alert-danger {
  background-color: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

/* ==========================================
   EMPTY STATES - NO DATA MESSAGING
   ========================================== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state i {
  font-size: 4rem;
  color: var(--text-muted);
  opacity: 0.5;
  margin-bottom: 1rem;
}

.empty-state h5 {
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ==========================================
   METADATA DISPLAY - TIMESTAMPS & INFO
   ========================================== */
.metadata-item {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  gap: 0.5rem;
}

.metadata-item i {
  color: var(--text-muted);
  font-size: 1rem;
}

.metadata-item strong {
  font-weight: 600;
  margin-right: 0.25rem;
}

.metadata-section {
  padding: 1rem;
  background-color: #f8f9fc;
  border-radius: var(--border-radius-sm);
  margin-top: var(--spacing-lg);
}

/* ==========================================
   SIDEBAR - NAVIGATION
   ========================================== */
.sidebar {
  background: var(--sidebar-bg-gradient) !important;
  border-right: none !important;
  box-shadow: var(--shadow-lg);
}

.sidebar-brand {
  color: var(--text-white) !important;
  padding: 1.5rem 1rem;
  font-size: 1.1rem;
}

.sidebar-brand:hover {
  color: rgba(255, 255, 255, 0.9) !important;
}

.sidebar-brand i {
  color: var(--text-white);
}

.sidebar-divider {
  border-color: rgba(255, 255, 255, 0.15);
  margin: 0.5rem 1rem;
}

.sidebar-link {
  color: rgba(255, 255, 255, 0.8) !important;
  padding: 0.75rem 1rem;
  margin-bottom: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 400;
  transition: all 0.15s ease-in-out;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-white) !important;
  border-left-color: rgba(255, 255, 255, 0.5);
}

.sidebar-link.active {
  background-color: rgba(255, 255, 255, 0.2) !important;
  color: var(--text-white) !important;
  font-weight: 700;
  border-left-color: var(--text-white);
}

.sidebar-link i {
  width: 1.25rem;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  margin-right: 0.5rem;
}

.sidebar-link.active i,
.sidebar-link:hover i {
  color: var(--text-white);
}

/* Offcanvas for mobile */
.offcanvas-header {
  background: var(--sidebar-bg-gradient);
  color: var(--text-white);
}

.offcanvas-header .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

.offcanvas-title {
  color: var(--text-white);
  font-weight: 600;
}

/* ==========================================
   NAVBAR - TOP NAVIGATION
   ========================================== */
.navbar.sticky-top {
  box-shadow: var(--shadow-md);
  padding: 0.5rem 1rem;
  background-color: var(--bg-white);
}

.navbar .navbar-brand {
  letter-spacing: 0.05rem;
  font-weight: 600;
  color: var(--sidebar-bg);
}

.navbar .navbar-brand i {
  color: var(--sidebar-bg);
}

/* ==========================================
   FOOTER
   ========================================== */
.footer {
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  padding: 1.5rem;
  background-color: var(--bg-white);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ==========================================
   DATATABLES CUSTOMIZATION
   ========================================== */
/* Search on LEFT, Show entries on RIGHT */
.dataTables_wrapper .row:first-of-type {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between !important;
  padding: 0.75rem 0;
}

.dataTables_wrapper .row:first-of-type > div {
  display: flex !important;
  align-items: center;
}

.dataTables_wrapper .row:first-of-type > div:first-child {
  order: 1;
  justify-content: flex-start !important;
  margin-right: auto !important;
}

.dataTables_wrapper .row:first-of-type > div:last-child {
  order: 2;
  justify-content: flex-end !important;
  margin-left: auto !important;
}

.dataTables_wrapper .dataTables_filter {
  float: none !important;
  text-align: left !important;
  display: flex !important;
  align-items: center !important;
}

.dataTables_wrapper .dataTables_filter label {
  display: flex !important;
  align-items: center !important;
  margin-bottom: 0 !important;
  gap: 0.5rem !important;
}

.dataTables_wrapper .dataTables_filter input[type="search"] {
  margin-left: 0.5rem !important;
  width: 200px !important;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.375rem 0.75rem;
}

.dataTables_wrapper .dataTables_length {
  float: none !important;
  text-align: right !important;
  display: flex !important;
  align-items: center !important;
}

.dataTables_wrapper .dataTables_length label {
  display: flex !important;
  align-items: center !important;
  margin-bottom: 0 !important;
  gap: 0.5rem !important;
}

.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.375rem 0.5rem;
  margin: 0 0.5rem;
}

.dataTables_wrapper .row:last-of-type {
  padding: 0.75rem 0;
  display: flex !important;
  align-items: center;
}

@media (max-width: 576px) {
  .dataTables_wrapper .row:first-of-type {
    flex-direction: column;
    align-items: stretch;
  }
  
  .dataTables_wrapper .row:first-of-type > div:first-child,
  .dataTables_wrapper .row:first-of-type > div:last-child {
    order: initial;
    margin: 0 0 0.5rem 0;
    justify-content: flex-start !important;
  }
}

/* ==========================================
   DRAG & DROP ZONES
   ========================================== */
.drop-zone {
  border: 3px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  transition: all 0.3s ease;
  background-color: #f8f9fc;
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--accent-blue);
  background-color: var(--accent-blue-light);
}

.drop-zone.drag-over {
  border-color: var(--accent-blue);
  background-color: var(--accent-blue-light);
  transform: scale(1.02);
}

/* ==========================================
   IMAGE GALLERIES & GRIDS
   ========================================== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }
}

.image-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius);
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
}

.image-item:hover .image-overlay {
  background: rgba(0, 0, 0, 0.5);
}

/* ==========================================
   HOVER EFFECTS
   ========================================== */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

/* ==========================================
   PROGRESS BARS
   ========================================== */
.progress {
  height: 1.5rem;
  border-radius: var(--border-radius);
  background-color: #e9ecef;
}

.progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--border-radius);
}

/* ==========================================
   AUTHENTICATION PAGES
   ========================================== */
.bg-gradient-primary {
  background-color: var(--bg-primary);
  background-image: linear-gradient(180deg, var(--bg-primary) 10%, var(--sidebar-dark) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.form-control-user {
  font-size: 0.875rem;
  border-radius: 10rem;
  padding: 0.75rem 1rem;
}

.btn-user {
  font-size: 0.875rem;
  border-radius: 10rem;
  padding: 0.75rem 1rem;
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.object-fit-cover { object-fit: cover; }
.object-fit-contain { object-fit: contain; }

/* ==========================================
   RESPONSIVE LAYOUT
   ========================================== */
body > .d-flex {
  display: flex;
  min-height: calc(100vh - 56px);
}

.flex-grow-1 {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

main {
  flex: 1 0 auto;
  background-color: var(--bg-neutral);
}

/* Sidebar positioning */
@media (min-width: 992px) {
  .offcanvas-lg {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    visibility: visible !important;
    transform: none !important;
    transition: none !important;
    z-index: 1040 !important;
    display: flex !important;
    flex-direction: column;
    width: 260px !important;
    height: 100vh !important;
    border-right: none !important;
    overflow-y: auto;
    overflow-x: hidden;
  }
  
  .offcanvas-lg .offcanvas-header,
  .offcanvas-lg .btn-close {
    display: none;
  }
  
  .offcanvas-lg .offcanvas-body {
    visibility: visible !important;
    overflow-y: auto;
  }

  #wrapper {
    padding-left: 0 !important;
  }

  #content-wrapper {
    margin-left: 260px !important;
    width: calc(100% - 260px) !important;
  }
}

@media (max-width: 991.98px) {
  .sidebar {
    width: 260px !important;
  }

  #content-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
  }
}

/* ==========================================
   FOCUS STATES - ACCESSIBILITY
   ========================================== */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(90, 159, 212, 0.25);
  outline: none;
}

/* ==========================================
   PRINT STYLES
   ========================================== */
@media print {
  .sidebar,
  .navbar,
  .footer,
  .btn,
  .action-buttons {
    display: none !important;
  }
  
  .card {
    box-shadow: none !important;
    border: 1px solid #000 !important;
  }
  
  body {
    background-color: #fff !important;
  }
}

/* ==========================================
   ANIMATION KEYFRAMES
   ========================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* ==========================================
   SORTABLE/DRAGGABLE ITEMS
   ========================================== */
.sortable-card {
  cursor: move;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sortable-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.sortable-ghost {
  opacity: 0.4;
}

.sortable-chosen {
  transform: scale(1.05);
}

.drag-handle {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: var(--border-radius-sm);
  cursor: move;
  z-index: 5;
}

/* ==========================================
   CUSTOM SCROLLBAR (WEBKIT)
   ========================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-neutral);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
