/* Responsive Design - Mobile First */

/* Global sidebar z-index for desktop */
.sidebar {
  z-index: 2000;
}

/* Mobile Styles (default) */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.5rem;
  }

  .app-container {
    grid-template-areas: 
      "main";
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 300px;
    z-index: 2000;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    left: 0;
  }

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

  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .main-content {
    margin-left: 0;
  }

  /* Hide floating toggle on mobile */
  .sidebar-edge-toggle {
    display: none !important;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background-color: transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--border-radius);
  }

  .mobile-menu-btn:hover {
    background-color: var(--bg-hover);
  }

  .content-body {
    padding: var(--spacing-lg);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
  }

  .table-container {
    font-size: var(--font-size-sm);
  }

  .table th,
  .table td {
    padding: var(--spacing-sm);
  }

  .actions {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-xs);
  }

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

  .form-group {
    margin-bottom: var(--spacing-md);
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }
  
  .form-section-title {
    font-size: var(--font-size-base);
  }
  
  .form-actions {
    flex-direction: column-reverse;
  }
  
  .form-actions .btn {
    width: 100%;
  }

  .modal {
    margin: var(--spacing-sm);
    max-width: calc(100vw - var(--spacing-md));
    max-height: calc(100vh - var(--spacing-md));
  }
  
  .modal-body {
    padding: var(--spacing-md);
  }
  
  .modal-header,
  .modal-footer {
    padding: var(--spacing-md);
  }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 200px;
  }

  .content-body {
    padding: var(--spacing-lg) var(--spacing-xl);
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  /* Show floating toggle on tablet for manual sidebar control */
  .sidebar-edge-toggle {
    display: flex;
  }
}

/* Desktop Styles */
@media (min-width: 1025px) {
  .mobile-header {
    display: none;
  }

  .sidebar-overlay {
    display: none;
  }

  .sidebar-edge-toggle {
    display: flex;
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  :root {
    --content-max-width: 1400px;
  }
}

/* Print Styles */
@media print {
  .sidebar,
  .mobile-header,
  .page-actions,
  .actions {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  .content-body {
    padding: 0;
  }

  .table {
    border: 1px solid #000;
  }

  .table th,
  .table td {
    border: 1px solid #000;
  }
}

/* Utility classes for responsive design */
.hide-mobile {
  display: none;
}

.show-mobile {
  display: block;
}

@media (min-width: 769px) {
  .hide-mobile {
    display: block;
  }

  .show-mobile {
    display: none;
  }
}

/* Accessible focus indicators */
@media (prefers-reduced-motion: no-preference) {
  .sidebar {
    transition: left 0.3s ease;
  }

  .sidebar-overlay {
    transition: all 0.3s ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-overlay {
    transition: none;
  }
}
