/* ═══════════════════════════════════════════════════════════
   ADMIN DASHBOARD — COMPREHENSIVE RESPONSIVE DESIGN
   Mobile-First Approach with Full Device Support
   320px → 767px (Mobile) | 768px → 1024px (Tablet) | 1025px+ (Desktop)
   ═══════════════════════════════════════════════════════════ */

:root {
  --admin-spacing-xs: 8px;
  --admin-spacing-sm: 12px;
  --admin-spacing-md: 16px;
  --admin-spacing-lg: 24px;
  --admin-spacing-xl: 32px;
  --admin-sidebar-width: 280px;
  --admin-sidebar-width-compact: 240px;
}

/* ═══════════════════════════════════════════════════════════
   1. BASE MOBILE LAYOUT (320px - 767px)
   ═══════════════════════════════════════════════════════════ */

.dashboard-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--surface);
  overflow-x: hidden;
}

/* SIDEBAR - Hidden on Mobile, Fixed Overlay */
#adminSidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  max-width: 280px;
  height: 100vh;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 50%, var(--navy-light) 100%);
  box-shadow: 2px 0 15px rgba(0,0,0,0.3);
  z-index: 1040;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

#adminSidebar.show {
  transform: translateX(0);
}

/* Mobile Toggle Button */
#sidebarToggle {
  display: block;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(29,78,216,0.4);
  z-index: 1050;
  transition: all 0.3s ease;
}

#sidebarToggle:active {
  transform: scale(0.95);
}

/* DASHBOARD CONTENT - Full Width on Mobile */
.dashboard-content {
  flex: 1;
  width: 100%;
  margin-left: 0;
  padding: 12px;
  overflow-x: hidden;
}

/* Sidebar Styles */
.sidebar-search {
  padding: 12px 16px;
}

.sidebar-nav {
  padding: 16px;
}

.sidebar-nav .nav-link {
  padding: 12px 16px;
  font-size: 0.9rem;
  border-radius: 8px;
  color: rgba(255,255,255,0.75);
  transition: all 0.3s ease;
}

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

.sidebar-nav .nav-link.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
}

/* TOPBAR - Mobile Responsive */
.admin-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px;
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.admin-topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  flex: 1;
}

.admin-topbar-title h4 {
  margin: 0;
  font-size: 1rem;
}

.admin-topbar-title small {
  display: block;
  font-size: 0.8rem;
  color: var(--text-light);
}

.admin-topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* STATS CARDS - Stack Vertically */
.admin-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.admin-stat-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
  transition: all 0.3s ease;
}

.admin-stat-card:hover {
  box-shadow: 0 4px 24px rgba(15,23,42,0.06);
  transform: translateY(-2px);
}

.admin-stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.admin-stat-card-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-stat-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-dark);
}

/* FORMS */
.admin-form {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
  border: 1px solid var(--border-light);
}

.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.admin-form-field {
  display: flex;
  flex-direction: column;
}

.admin-form-field.span-2 {
  grid-column: span 1;
}

.admin-form-field label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 6px;
  display: block;
}

.admin-form-field input,
.admin-form-field select,
.admin-form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text-body);
  background: #fff;
  transition: all 0.3s ease;
}

.admin-form-field input:focus,
.admin-form-field select:focus,
.admin-form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}

.admin-form-field textarea {
  min-height: 120px;
  resize: vertical;
}

.admin-form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.admin-form-actions.span-2 {
  grid-column: span 1;
}

/* BUTTONS */
.admin-btn {
  padding: 10px 16px;
  font-size: 0.9rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}

.admin-btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
}

.admin-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(29,78,216,0.3);
}

.admin-btn-secondary,
.admin-btn-ghost {
  background: #f3f4f6;
  color: var(--text-dark);
  border: 1px solid var(--border-light);
}

.admin-btn-secondary:hover,
.admin-btn-ghost:hover {
  background: #e5e7eb;
}

.admin-btn-danger {
  background: #ef4444;
  color: #fff;
}

.admin-btn-danger:hover {
  background: #dc2626;
}

.admin-btn-success {
  background: #10b981;
  color: #fff;
}

.admin-btn-success:hover {
  background: #059669;
}

/* TABLES - Horizontal Scroll on Mobile */
.admin-table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: #fff;
  margin-bottom: 24px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table thead {
  background: #f9fafb;
  border-bottom: 2px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-table thead th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.2s ease;
}

.admin-table tbody tr:hover {
  background: #f9fafb;
}

.admin-table tbody td {
  padding: 12px;
  color: var(--text-body);
}

/* CARDS */
.admin-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
  border: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.admin-card-body {
  padding: 16px;
}

/* ALERTS */
.admin-alert {
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.admin-alert.success {
  background: rgba(16,185,129,0.1);
  color: #059669;
  border: 1px solid rgba(16,185,129,0.3);
}

.admin-alert.error {
  background: rgba(239,68,68,0.1);
  color: #dc2626;
  border: 1px solid rgba(239,68,68,0.3);
}

/* ═══════════════════════════════════════════════════════════
   2. TABLET (768px - 1024px)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 768px) {
  .dashboard-content {
    padding: 18px;
  }

  .admin-topbar {
    padding: 18px;
  }

  /* Tablet Grid - 2 columns */
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .admin-form {
    padding: 24px;
  }

  .admin-form-grid {
    gap: 16px;
  }

  .admin-form-field.span-2 {
    grid-column: span 1;
  }

  .admin-card-body {
    padding: 20px;
  }

  .admin-table {
    font-size: 0.95rem;
  }

  .admin-table thead th,
  .admin-table tbody td {
    padding: 14px;
  }
}

/* ═══════════════════════════════════════════════════════════
   3. DESKTOP/LAPTOP (1025px and above)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 1025px) {
  .dashboard-wrapper {
    flex-direction: row;
  }

  #adminSidebar {
    position: static;
    width: 280px;
    max-width: none;
    height: auto;
    transform: none;
    box-shadow: 2px 0 15px rgba(0,0,0,0.1);
  }

  #sidebarToggle {
    display: none;
  }

  .dashboard-content {
    flex: 1;
    margin-left: 0;
    padding: 24px;
    overflow-y: auto;
  }

  .admin-topbar {
    padding: 24px;
  }

  /* Desktop Grid - Multiple columns */
  .admin-stats {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
  }

  .admin-stat-card {
    padding: 20px;
  }

  .admin-stat-card-value {
    font-size: 2rem;
  }

  .admin-form {
    max-width: 800px;
    padding: 28px;
  }

  .admin-form-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .admin-form-field.span-2 {
    grid-column: span 2;
  }

  .admin-form-actions.span-2 {
    grid-column: span 2;
  }

  .admin-table {
    font-size: 0.95rem;
  }

  .admin-table thead th,
  .admin-table tbody td {
    padding: 16px;
  }

  .admin-card-body {
    padding: 24px;
  }
}

/* ═══════════════════════════════════════════════════════════
   4. LARGE SCREENS (1440px+)
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 1440px) {
  .admin-stats {
    grid-template-columns: repeat(5, 1fr);
  }

  .dashboard-content {
    max-width: 1600px;
    margin: 0 auto;
  }

  .admin-form-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════
   5. NO HORIZONTAL OVERFLOW - CRITICAL
   ═══════════════════════════════════════════════════════════ */

html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

.dashboard-wrapper,
.dashboard-content,
.admin-form,
.admin-table-container {
  overflow-x: hidden;
  max-width: 100%;
}


/* ═══════════════════════════════════════════════════════════
   6. ADVANCED MOBILE UTILITIES
   ═══════════════════════════════════════════════════════════ */

/* Shell containers for responsive padding */
.admin-form-shell {
  padding: 0;
  width: 100%;
}

/* Responsive flex utilities */
.admin-flex {
  display: flex;
}

.admin-flex-col {
  flex-direction: column;
}

.admin-flex-row {
  flex-direction: row;
}

.admin-flex-wrap {
  flex-wrap: wrap;
}

.admin-flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Responsive grid utility */
.admin-grid {
  display: grid;
}

.admin-grid-cols-1 {
  grid-template-columns: 1fr;
}

.admin-grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.admin-grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 768px) {
  .admin-grid-cols-2-tablet {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .admin-grid-cols-3-tablet {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1025px) {
  .admin-grid-cols-3-desktop {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .admin-grid-cols-4-desktop {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Responsive gap utilities */
.admin-gap-0 {
  gap: 0;
}

.admin-gap-2 {
  gap: 8px;
}

.admin-gap-3 {
  gap: 12px;
}

.admin-gap-4 {
  gap: 16px;
}

.admin-gap-6 {
  gap: 24px;
}

.admin-gap-8 {
  gap: 32px;
}

/* Responsive margin utilities */
.admin-m-0 {
  margin: 0;
}

.admin-m-2 {
  margin: 8px;
}

.admin-m-3 {
  margin: 12px;
}

.admin-m-4 {
  margin: 16px;
}

.admin-m-6 {
  margin: 24px;
}

.admin-mt-0 {
  margin-top: 0;
}

.admin-mt-2 {
  margin-top: 8px;
}

.admin-mt-3 {
  margin-top: 12px;
}

.admin-mt-4 {
  margin-top: 16px;
}

.admin-mt-6 {
  margin-top: 24px;
}

.admin-mb-0 {
  margin-bottom: 0;
}

.admin-mb-2 {
  margin-bottom: 8px;
}

.admin-mb-3 {
  margin-bottom: 12px;
}

.admin-mb-4 {
  margin-bottom: 16px;
}

.admin-mb-6 {
  margin-bottom: 24px;
}

.admin-mx-auto {
  margin-left: auto;
  margin-right: auto;
}

/* Responsive padding utilities */
.admin-p-0 {
  padding: 0;
}

.admin-p-2 {
  padding: 8px;
}

.admin-p-3 {
  padding: 12px;
}

.admin-p-4 {
  padding: 16px;
}

.admin-p-6 {
  padding: 24px;
}

.admin-px-2 {
  padding-left: 8px;
  padding-right: 8px;
}

.admin-px-3 {
  padding-left: 12px;
  padding-right: 12px;
}

.admin-px-4 {
  padding-left: 16px;
  padding-right: 16px;
}

.admin-py-2 {
  padding-top: 8px;
  padding-bottom: 8px;
}

.admin-py-3 {
  padding-top: 12px;
  padding-bottom: 12px;
}

.admin-py-4 {
  padding-top: 16px;
  padding-bottom: 16px;
}

/* Responsive width utilities */
.admin-w-full {
  width: 100%;
}

.admin-w-1-2 {
  width: 50%;
}

.admin-w-1-3 {
  width: 33.333%;
}

.admin-w-2-3 {
  width: 66.666%;
}

.admin-w-1-4 {
  width: 25%;
}

.admin-w-3-4 {
  width: 75%;
}

@media (min-width: 768px) {
  .admin-w-1-2-tablet {
    width: 50%;
  }
  
  .admin-w-1-3-tablet {
    width: 33.333%;
  }
}

/* Display utilities */
.admin-hidden {
  display: none;
}

.admin-hidden-mobile {
  display: none;
}

.admin-hidden-tablet {
  display: block;
}

.admin-hidden-desktop {
  display: block;
}

.admin-block {
  display: block;
}

.admin-inline {
  display: inline;
}

.admin-inline-block {
  display: inline-block;
}

@media (min-width: 768px) {
  .admin-hidden-mobile {
    display: block;
  }

  .admin-hidden-tablet {
    display: none;
  }

  .admin-block-tablet {
    display: block;
  }
}

@media (min-width: 1025px) {
  .admin-hidden-tablet {
    display: block;
  }

  .admin-hidden-desktop {
    display: none;
  }

  .admin-block-desktop {
    display: block;
  }
}

/* Text utilities */
.admin-text-center {
  text-align: center;
}

.admin-text-left {
  text-align: left;
}

.admin-text-right {
  text-align: right;
}

.admin-text-justify {
  text-align: justify;
}

.admin-text-xs {
  font-size: 0.75rem;
}

.admin-text-sm {
  font-size: 0.875rem;
}

.admin-text-base {
  font-size: 1rem;
}

.admin-text-lg {
  font-size: 1.125rem;
}

.admin-text-xl {
  font-size: 1.25rem;
}

.admin-text-2xl {
  font-size: 1.5rem;
}

.admin-font-normal {
  font-weight: 400;
}

.admin-font-medium {
  font-weight: 500;
}

.admin-font-semibold {
  font-weight: 600;
}

.admin-font-bold {
  font-weight: 700;
}

/* Color utilities */
.admin-text-muted {
  color: var(--text-light);
}

.admin-text-dark {
  color: var(--text-dark);
}

.admin-text-primary {
  color: var(--accent);
}

.admin-text-success {
  color: #10b981;
}

.admin-text-danger {
  color: #ef4444;
}

.admin-text-warning {
  color: #f59e0b;
}

/* Background utilities */
.admin-bg-white {
  background: #fff;
}

.admin-bg-gray-50 {
  background: #f9fafb;
}

.admin-bg-gray-100 {
  background: #f3f4f6;
}

.admin-bg-gray-200 {
  background: #e5e7eb;
}

.admin-bg-primary {
  background: var(--accent);
  color: #fff;
}

.admin-bg-success {
  background: #10b981;
  color: #fff;
}

.admin-bg-danger {
  background: #ef4444;
  color: #fff;
}

/* Border utilities */
.admin-border {
  border: 1px solid var(--border-light);
}

.admin-border-t {
  border-top: 1px solid var(--border-light);
}

.admin-border-b {
  border-bottom: 1px solid var(--border-light);
}

.admin-border-l {
  border-left: 1px solid var(--border-light);
}

.admin-border-r {
  border-right: 1px solid var(--border-light);
}

.admin-rounded {
  border-radius: 8px;
}

.admin-rounded-lg {
  border-radius: 12px;
}

.admin-rounded-full {
  border-radius: 9999px;
}

/* Shadow utilities */
.admin-shadow {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.admin-shadow-md {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.admin-shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.admin-shadow-none {
  box-shadow: none;
}

/* Overflow utilities */
.admin-overflow-auto {
  overflow: auto;
}

.admin-overflow-hidden {
  overflow: hidden;
}

.admin-overflow-x-auto {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-overflow-y-auto {
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════
   7. RESPONSIVE FORM IMPROVEMENTS
   ═══════════════════════════════════════════════════════════ */

.admin-input-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-input-group input,
.admin-input-group select,
.admin-input-group button {
  min-height: 40px;
}

.admin-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-checkbox-wrap input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.admin-checkbox-wrap span {
  cursor: pointer;
  user-select: none;
}

/* ═══════════════════════════════════════════════════════════
   8. RESPONSIVE LIST/ITEM COMPONENTS
   ═══════════════════════════════════════════════════════════ */

.admin-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.admin-list-item {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-list-item:last-child {
  border-bottom: none;
}

.admin-list-item-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.admin-list-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   9. BADGES AND LABELS
   ═══════════════════════════════════════════════════════════ */

.admin-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.admin-badge-primary {
  background: rgba(29,78,216,0.1);
  color: var(--accent);
}

.admin-badge-success {
  background: rgba(16,185,129,0.1);
  color: #10b981;
}

.admin-badge-warning {
  background: rgba(245,158,11,0.1);
  color: #f59e0b;
}

.admin-badge-danger {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}

/* ═══════════════════════════════════════════════════════════
   10. ACCESSIBILITY
   ═══════════════════════════════════════════════════════════ */

.admin-btn:focus-visible,
.admin-form-field input:focus-visible,
.admin-form-field select:focus-visible,
.admin-form-field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   11. CUSTOM SCROLLBAR STYLING
   ═══════════════════════════════════════════════════════════ */

.admin-table-container::-webkit-scrollbar,
.dashboard-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.admin-table-container::-webkit-scrollbar-track,
.dashboard-content::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.admin-table-container::-webkit-scrollbar-thumb,
.dashboard-content::-webkit-scrollbar-thumb {
  background: rgba(37,99,235,.35);
  border-radius: 4px;
}

.admin-table-container::-webkit-scrollbar-thumb:hover,
.dashboard-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

