/**
 * Responsive Stylesheet
 * Project Codex PRD V3 - Requirement 7
 * Perfect compatibility across Computer, Tablet, and Mobile
 */

/* ==========================================================================
   Base Responsive Helpers
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-md);
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.tabs-nav {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

.tabs-nav .tab-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ==========================================================================
   Tablet Devices (max-width: 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 250px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .page-container {
    padding: 1.25rem;
  }

  .card {
    padding: 1.25rem;
  }
}

/* ==========================================================================
   Mobile & Small Tablet Devices (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(100%);
    width: 280px;
    z-index: 100;
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

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

  .app-main {
    margin-right: 0 !important;
  }

  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
  }

  .app-header {
    padding: 0.75rem 1rem;
  }

  .page-title-box h1 {
    font-size: 1.15rem;
  }

  .page-container {
    padding: 0.85rem;
    gap: 0.85rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .search-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .search-box {
    max-width: none;
    width: 100%;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
  }

  .modal-dialog {
    width: 95% !important;
    max-width: 95vw !important;
    max-height: 92vh;
    padding: 1.25rem !important;
    border-radius: var(--radius-md);
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
  }

  /* Make actions wrap gracefully */
  .header-actions,
  .action-buttons-group {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* ==========================================================================
   Small Mobile Devices (max-width: 480px)
   ========================================================================== */
@media (max-width: 480px) {
  .page-title-box h1 {
    font-size: 1rem;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    min-height: 40px;
  }

  .btn-sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
    min-height: 32px;
  }

  .form-control {
    font-size: 0.9rem;
    min-height: 42px;
  }

  .kpi-card {
    padding: 1rem 0.85rem;
  }

  .kpi-value {
    font-size: 1.3rem;
  }

  .modal-header h3 {
    font-size: 1.05rem;
  }
}
