/* ==========================================================================
   RESPONSIVE UTILITY CSS - Shared across all pages
   Mobile-first approach with progressive enhancement
   
   NOTE: This file SUPPLEMENTS individual page CSS files.
   Individual CSS files handle page-specific responsive breakpoints.
   This file provides shared utility classes and cross-page responsive rules.
   ========================================================================== */

/* CSS Variables for responsive breakpoints */
:root {
  --breakpoint-xs: 0;
  --breakpoint-sm: 480px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
  --breakpoint-xxl: 1400px;
  
  --container-max: 1400px;
  --container-padding: 1rem;
  
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 80px;
  --header-height: 70px;
  
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  --spacing-3xl: 4rem;
}

/* ==========================================================================
   BASE MOBILE STYLES (Mobile First)
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Touch-friendly tap targets */
button, a, input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  min-height: 44px;
  min-width: 44px;
}

input, select, textarea {
  font-size: 16px; /* Prevents zoom on iOS */
}

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* ==========================================================================
   SIDEBAR - Desktop only (992px+)
   Note: Individual CSS files handle sidebar layout at tablet/mobile sizes.
   This section only applies the fixed sidebar for desktop view.
   ========================================================================== */

/* Base sidebar styles (non-positioning - individual CSS handles mobile layout) */
.sidebar {
  z-index: 1000;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 44px;
  height: 44px;
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 1001;
}

.mobile-menu-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  background: var(--primary, var(--primary));
  border-radius: 3px;
  transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(-10px);
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Sidebar logo responsive */
.sidebar .logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem;
}

.sidebar .logo img {
  width: 60px;
  height: auto;
}

.sidebar .logo h2 {
  font-size: 1.1rem;
  margin: 0.5rem 0 0;
  white-space: nowrap;

    color: var(--primary);}

/* Sidebar navigation */
.sidebar ul.menu {
  list-style: none;
  padding: 0 1rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar ul.menu li {
  margin: 0.25rem 0;
}

.sidebar ul.menu li a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  min-height: 48px;
}

.sidebar ul.menu li a i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar ul.menu li a span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar ul.menu li a:hover {
  background: rgba(13, 110, 253, 0.08);
  color: var(--white);
  padding-left: 1.5rem;
}

.sidebar ul.menu li.active a {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   MAIN CONTENT - Desktop only (992px+)
   Individual CSS handles main-content padding at mobile sizes.
   ========================================================================== */

.main-content {
  overflow-y: auto;
}

/* ==========================================================================
   HEADER/NAVBAR - Dashboard pages only
   Scoped to header.navbar to avoid conflicting with landing page <nav class="navbar">
   ========================================================================== */

/* Dashboard navbar base styles */
header.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.header-left,
.navbar-left {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.header-left h1,
.navbar-left h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary, var(--primary));
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.header-left .subtitle,
.navbar-left .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.header-right,
.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Search box */
.search-box {
  display: none; /* Hidden on mobile by default */
  align-items: center;
  background: var(--white);
  padding: 0.5rem 1rem;
  border-radius: 25px;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.875rem;
  width: 150px;
}

/* Notifications */
.notifications {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.3s ease;
}

.notifications:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.notifications i {
  font-size: 1.1rem;
  color: var(--primary, var(--primary));
}

/* User info */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  background: var(--white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 44px;
}

.user-info:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.user-details {
  display: none; /* Hidden on mobile by default */
  flex-direction: column;
  align-items: flex-end;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink-800);
}

.user-role {
  font-size: 0.7rem;
  color: var(--ink-500);
}

.user-info img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--primary, var(--primary));
  object-fit: cover;
}

/* ==========================================================================
   CARDS & GRIDS
   Note: Individual CSS files handle their own card layouts.
   This provides sensible defaults that individual CSS can override.
   ========================================================================== */

.card,
.stat-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.card:hover,
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

/* Dashboard grid - default single column, multi-column at breakpoints */
.dashboard-grid,
.profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary, var(--primary));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-header h2 i {
  font-size: 1.5rem;
}

/* Form responsive */
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-700);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
  background: var(--white);
  min-height: 48px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary, var(--primary));
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* Buttons - full width on mobile */
.btn,
.btn-primary,
.btn-secondary,
.btn-submit,
.action-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  border: none;
  min-height: 48px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(13, 110, 253, 0.4);
}

.btn-secondary {
  background: var(--white);
  color: var(--primary, var(--primary));
  border: 2px solid var(--primary, var(--primary));
}

.btn-secondary:hover {
  background: var(--primary, var(--primary));
  color: var(--white);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary, var(--primary));
  color: var(--primary, var(--primary));
}

.btn-outline:hover {
  background: var(--primary, var(--primary));
  color: var(--white);
}

/* ==========================================================================
   TABLES RESPONSIVE
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--ink-100);
}

th {
  background: var(--ink-50);
  font-weight: 600;
  color: var(--ink-700);
  font-size: 0.875rem;
  white-space: nowrap;
}

td {
  font-size: 0.9rem;
  color: var(--ink-800);
}

/* ==========================================================================
   MODALS RESPONSIVE
   ========================================================================== */

.modal,
.popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.modal.active,
.popup-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content,
.popup-content {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header,
.popup-content > h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 2px solid var(--ink-100);
  background: linear-gradient(135deg, var(--ink-50) 0%, var(--white) 100%);
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary, var(--primary));
  margin: 0;
}

.modal-close,
.close-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ink-100);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  min-height: 44px;
  min-width: 44px;
}

.modal-close:hover,
.close-btn:hover {
  background: #ff4757;
  color: var(--white);
  transform: rotate(90deg);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 2px solid var(--ink-100);
  background: var(--ink-50);
  flex-wrap: wrap;
}

/* ==========================================================================
   TABS RESPONSIVE
   ========================================================================== */

.input-tabs,
.analysis-tabs,
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: #f5f5f5;
  padding: 0.5rem;
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn,
.analysis-tab {
  flex: 1;
  min-width: 120px;
  padding: 0.875rem 1rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  min-height: 44px;
}

.tab-btn.active,
.analysis-tab.active {
  background: var(--white);
  color: var(--primary, var(--primary));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ==========================================================================
   LOADING & EMPTY STATES
   ========================================================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 9999;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--ink-100);
  border-top: 4px solid var(--primary, var(--primary));
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-overlay p {
  color: var(--primary, var(--primary));
  font-weight: 500;
  font-size: 1rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.empty-state i {
  font-size: 4rem;
  color: var(--border);
  margin-bottom: 1.5rem;
}

.empty-state h3 {
  font-size: 1.5rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 1rem;
  color: var(--ink-500);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.notification-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: 1rem;
  max-width: 400px;
  margin-left: auto;
  background: linear-gradient(135deg, #00c853 0%, #00e676 100%);
  color: var(--white);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 200, 83, 0.4);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateX(calc(100% + 1rem));
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 10001;
}

.notification-toast.active {
  transform: translateX(0);
}

.notification-toast.error {
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  box-shadow: 0 8px 25px rgba(255, 71, 87, 0.4);
}

/* ==========================================================================
   TEXT UTILITIES
   ========================================================================== */

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* ==========================================================================
   SPACING UTILITIES
   ========================================================================== */

.m-0 { margin: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mt-5 { margin-top: var(--spacing-xl); }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mb-5 { margin-bottom: var(--spacing-xl); }

.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-xs); }
.p-2 { padding: var(--spacing-sm); }
.p-3 { padding: var(--spacing-md); }
.p-4 { padding: var(--spacing-lg); }
.p-5 { padding: var(--spacing-xl); }

/* ==========================================================================
   DISPLAY UTILITIES
   ========================================================================== */

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

.flex-column { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-auto { flex: 1 1 auto; }
.flex-shrink-0 { flex-shrink: 0; }

.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.gap-1 { gap: var(--spacing-xs); }
.gap-2 { gap: var(--spacing-sm); }
.gap-3 { gap: var(--spacing-md); }
.gap-4 { gap: var(--spacing-lg); }
.gap-5 { gap: var(--spacing-xl); }

/* ==========================================================================
   BREAKPOINTS - TABLET (768px and up)
   ========================================================================== */

@media (min-width: 768px) {
  :root {
    --container-padding: 1.5rem;
  }
  
  html {
    font-size: 16px;
  }
  
  .search-box {
    display: flex;
  }
  
  .search-box input {
    width: 180px;
  }
  
  .user-details {
    display: flex;
  }
  
  .user-info img {
    width: 42px;
    height: 42px;
  }
  
  .header-left h1,
  .navbar-left h1 {
    font-size: 1.5rem;
    max-width: 250px;
  }
  
  .header-left .subtitle,
  .navbar-left .subtitle {
    font-size: 0.875rem;
    max-width: 250px;
  }
  
  .dashboard-grid {
    grid-template-columns: 2fr 1fr;
  }
  
  .profile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .modal-content,
  .popup-content {
    max-width: 600px;
  }
  
  .action-buttons {
    flex-direction: row;
  }
  
  .action-btn {
    width: auto;
    flex: 1;
  }
  
  .download-buttons {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   BREAKPOINTS - DESKTOP (992px and up)
   ========================================================================== */

@media (min-width: 992px) {
  :root {
    --container-padding: 2rem;
  }
  
  /* Sidebar: fixed and visible on desktop */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    min-height: 100vh;
    transform: none;
  }
  
  /* Sidebar open state - used by JS for mobile toggle */
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.2);
  }
  
  .sidebar-overlay {
    display: none !important;
  }
  
  .mobile-menu-toggle {
    display: none;
  }
  
  .main-content {
    margin-left: var(--sidebar-width);
  }
  
  /* Dashboard navbar: offset for sidebar, reset flex-direction */
  header.navbar {
    left: var(--sidebar-width);
    padding: 0 3rem;
    height: 100px;
    border-radius: 0;
    flex-direction: row;
  }
  
  .header-left h1,
  .navbar-left h1 {
    font-size: 2.5rem;
    max-width: none;
  }
  
  .header-left .subtitle,
  .navbar-left .subtitle {
    font-size: 1rem;
    max-width: none;
  }
  
  .search-box input {
    width: 200px;
  }
  
  .sidebar .logo h2 {
    font-size: 1.25rem;
  
      color: var(--primary);}
  
  .sidebar ul.menu li a span {
    display: inline;
  }
  
  .form-row {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
  
  .download-buttons {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   BREAKPOINTS - LARGE DESKTOP (1200px and up)
   ========================================================================== */

@media (min-width: 1200px) {
  :root {
    --container-padding: 3rem;
  }
  
  .header-left h1,
  .navbar-left h1 {
    font-size: 2.5rem;
  }
  
  .dashboard-grid {
    gap: 2rem;
  }
  
  .profile-grid {
    gap: 2rem;
  }
}

/* ==========================================================================
   BREAKPOINTS - XL DESKTOP (1400px and up)
   ========================================================================== */

@media (min-width: 1400px) {
  .container {
    max-width: 1400px;
  }
  
  .main-content {
    padding-left: 3rem;
    padding-right: 3rem;
  }
  
  header.navbar {
    padding: 0 4rem;
    height: 100px;
  }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
  .sidebar,
  .mobile-menu-toggle,
  header,
  .navbar,
  .notifications,
  .user-info,
  .btn,
  .action-btn,
  .modal,
  .popup-overlay,
  .loading-overlay,
  .notification-toast,
  .sidebar-overlay {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0;
    padding: 0;
    min-height: auto;
  }
  
  body {
    background: var(--white);
  }
  
  .card,
  .stat-card,
  .profile-card {
    box-shadow: none;
    border: 1px solid var(--border);
    break-inside: avoid;
  }
  
  a {
    text-decoration: none;
    color: var(--ink-800);
  }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

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

/* Note: high-contrast colour tokens are defined in css/theme.css, which loads
   after this file and would otherwise win the cascade. */
@media (prefers-contrast: high) {
  .btn-primary {
    background: var(--primary);
    border: 2px solid var(--primary-dark);
  }
  
  .card,
  .stat-card,
  .profile-card {
    border: 2px solid var(--ink-800);
  }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 3px solid var(--primary, var(--primary));
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary, var(--primary));
  outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary, var(--primary));
  color: var(--white);
  padding: 1rem 2rem;
  border-radius: 0 0 8px 8px;
  z-index: 100000;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
}

/* ==========================================================================
   EXTRA SMALL SCREENS (480px and below)
   ========================================================================== */

@media (max-width: 480px) {
  :root {
    --container-padding: 0.75rem;
    --sidebar-width: 240px;
    --header-height: 60px;
  }

  html {
    font-size: 15px;
  }
  
  .container {
    padding: 0 0.75rem;
  }

  .sidebar .logo {
    padding: 1rem 0.75rem;
  }
  
  .sidebar .logo img {
    width: 45px;
  }
  
  .sidebar .logo h2 {
    font-size: 0.95rem;
  
      color: var(--primary);}
  
  .sidebar ul.menu {
    padding: 0 0.75rem;
  }
  
  .sidebar ul.menu li a {
    padding: 0.75rem;
    font-size: 0.85rem;
    gap: 0.75rem;
  }
  
  .sidebar ul.menu li a i {
    font-size: 1.1rem;
    width: 20px;
  }

  header.navbar {
    padding: 0 0.75rem;
    height: var(--header-height);
  }
  
  .header-left h1,
  .navbar-left h1 {
    font-size: 1rem;
    max-width: 120px;
  }
  
  .header-left .subtitle,
  .navbar-left .subtitle {
    display: none;
  }
  
  .header-right {
    gap: 0.5rem;
  }
  
  .notifications {
    width: 34px;
    height: 34px;
  }
  
  .notifications i {
    font-size: 0.9rem;
  }
  
  .notifications .badge {
    width: 16px;
    height: 16px;
    font-size: 9px;
    top: -4px;
    right: -4px;
  }
  
  .user-info {
    padding: 4px 8px;
    gap: 8px;
  }
  
  .user-info img {
    width: 30px;
    height: 30px;
  }
  
  .user-name {
    font-size: 0.75rem;
  }
  
  .user-role {
    font-size: 0.65rem;
  }

  .search-box {
    display: none !important;
  }
  
  .user-details {
    display: none !important;
  }

  .card-number,
  .stat-number {
    font-size: 1.75rem;
  }
  
  .card-icon,
  .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
  
  .card h3,
  .stat-info h3 {
    font-size: 0.75rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .analytics-section,
  .activity-section,
  .recommendations-section,
  .quick-actions-section,
  .recent-users-section {
    padding: 1.25rem;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .section-header h2 {
    font-size: 1rem;
  }
  
  .section-header h2 i {
    font-size: 1.1rem;
  }
  
  .time-filter {
    width: 100%;
  }

  .chart-container {
    height: 180px;
    padding: 12px;
  }

  .quick-actions-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  
  .quick-action-btn {
    padding: 16px 12px;
    font-size: 12px;
  }
  
  .quick-action-btn i {
    font-size: 22px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
  
  .form-group input,
  .form-group textarea,
  .form-group select {
    padding: 0.7rem 0.875rem;
    font-size: 0.875rem;
  }

  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-submit,
  .action-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    min-height: 42px;
  }
  
  button, a, input, select, textarea {
    min-height: 40px;
    min-width: 40px;
  }

  .modal-content,
  .popup-content {
    max-width: 100%;
    margin: 0.5rem;
    border-radius: 16px;
  }
  
  .modal-header,
  .popup-content > h2 {
    padding: 1rem;
  }
  
  .modal-header h3 {
    font-size: 1.1rem;
  }
  
  .modal-body {
    padding: 1rem;
  }
  
  .modal-footer {
    padding: 1rem;
    flex-direction: column;
  }
  
  .modal-footer .btn {
    width: 100%;
  }

  .input-tabs,
  .analysis-tabs,
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.375rem;
  }
  
  .tab-btn,
  .analysis-tab {
    min-width: 80px;
    padding: 0.625rem 0.75rem;
    font-size: 0.8rem;
  }

  .notification-toast {
    left: 0.75rem;
    right: 0.75rem;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
  }

  .empty-state {
    padding: 2rem 1rem;
  }
  
  .empty-state i {
    font-size: 3rem;
  }
  
  .empty-state h3 {
    font-size: 1.25rem;
  }

  .loading-overlay p {
    font-size: 0.9rem;
  }
  
  .spinner {
    width: 40px;
    height: 40px;
  }

  .activity-item {
    padding: 10px;
    gap: 10px;
  }
  
  .activity-icon {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  
  .activity-title {
    font-size: 0.8rem;
  }
  
  .activity-time {
    font-size: 0.7rem;
  }

  .users-grid {
    grid-template-columns: 1fr;
  }
  
  .user-card {
    padding: 14px;
  }
  
  .user-avatar img {
    width: 44px;
    height: 44px;
  }
  
  .user-info-card h4 {
    font-size: 14px;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .pagination-controls {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .page-number {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  .action-buttons {
    flex-direction: column;
  }
  
  .action-btn {
    width: 100%;
  }

  .job-card {
    flex-direction: column;
    padding: 16px;
  }
  
  .job-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .job-header h4 {
    font-size: 16px;
  }
  
  .job-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  
  .job-actions .btn,
  .job-actions .btn-delete {
    flex: 1;
    justify-content: center;
  }

  .filter-controls {
    flex-direction: column;
    gap: 12px;
  }
  
  .filter-group {
    width: 100%;
  }
  
  .filter-group select {
    flex: 1;
  }

  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .controls-left,
  .controls-right {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }
  
  .filter-select {
    width: 100%;
  }
  
  .btn-action {
    width: 100%;
    justify-content: center;
  }
  
  .action-btns {
    flex-direction: column;
    gap: 5px;
  }
  
  .action-btn {
    width: 100%;
    justify-content: center;
  }

  .dual-input-container {
    grid-template-columns: 1fr;
  }
  
  .output-grid {
    grid-template-columns: 1fr;
  }
  
  .download-buttons {
    grid-template-columns: 1fr;
  }

  .score-card {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }
  
  .score-circle {
    width: 80px;
    height: 80px;
    margin: 0 auto;
  }
  
  .score-number {
    font-size: 1.5rem;
  }
  
  .score-details h3 {
    font-size: 1.2rem;
  }

  .templates-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .template-item {
    padding: 10px;
  }

  .textarea-wrapper textarea {
    min-height: 150px;
    font-size: 0.875rem;
  }

  .upload-area {
    padding: 20px 12px;
    min-height: 150px;
  }
  
  .upload-area i {
    font-size: 36px;
  }
  
  .upload-area h3 {
    font-size: 16px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }
  
  .profile-card {
    padding: 1.25rem;
  }
  
  .card-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .cover-photo-section {
    height: 150px;
  }
  
  .profile-info-overlay {
    padding: 16px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }
  
  .profile-avatar {
    width: 100px;
    height: 100px;
  }
  
  .profile-avatar-section {
    padding: 60px 16px 20px;
  }
  
  .profile-basic-info h2 {
    font-size: 20px;
  }
  
  .profile-actions {
    width: 100%;
    flex-direction: column;
  }

  .info-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
  }

  .skills-grid {
    gap: 8px;
  }
  
  .skill-tag {
    padding: 6px 12px;
    font-size: 12px;
  }

  .timeline-header {
    flex-direction: column;
    gap: 6px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .settings-card {
    padding: 16px;
  }
  
  .toggle-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .stat-item {
    gap: 6px;
  }
  
  .progress-bar {
    height: 8px;
  }

  .recommendation-card {
    padding: 16px;
  }
  
  .recommendation-card i {
    font-size: 20px;
  }

  /* Auth pages responsiveness */
  .auth-wrapper {
    flex-direction: column-reverse;
  }
  
  .auth-brand,
  .auth-card {
    width: 100%;
  }
  
  .auth-brand {
    padding: 24px 20px;
    min-height: auto;
  }
  
  .auth-card {
    padding: 24px 20px;
  }
  
  .auth-card h2 {
    font-size: 22px;
  }
  
  .auth-container {
    width: 100%;
    max-width: 100%;
    margin: 10px;
    border-radius: 14px;
    animation: none;
  }

  /* Chatbot on very small screens */
  .chatbot-container {
    width: calc(100% - 16px);
    right: 8px;
    bottom: 80px;
    max-height: 400px;
    border-radius: 16px;
  }
  
  .chatbot-header {
    padding: 12px 14px;
  }
  
  .chatbot-header h2 {
    font-size: 15px;
  }
  
  .chat-messages {
    padding: 10px;
    max-height: 250px;
  }
  
  .message-content {
    max-width: 90%;
    font-size: 13px;
    padding: 10px 12px;
  }
  
  .chat-input-form {
    padding: 10px;
  }
  
  .chat-input-form input {
    font-size: 13px;
    padding: 10px 12px;
  }
  
  #chat-toggle-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
    bottom: 16px;
    right: 16px;
  }

  .btn-export {
    width: 100%;
    justify-content: center;
  }

  /* Data tables: allow horizontal scroll */
  .table-responsive {
    margin: 0 -0.75rem;
  }
  
  th, td {
    padding: 0.625rem 0.75rem;
    font-size: 0.8rem;
  }

  .image-preview-overlay img {
    max-width: 95%;
    max-height: 85vh;
  }

  .popup-content h2 {
    font-size: 20px;
  }

  .corrected-textarea {
    min-height: 250px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .metric-card {
    padding: 14px;
  }
  
  .metric-card i {
    font-size: 22px;
  }
  
  .metric-value {
    font-size: 20px;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 10px;
    font-size: 12px;
  }

  .page-numbers {
    flex-wrap: wrap;
  }

  .recent-section {
    padding: 16px;
  }
}