/* ==========================================================================
   PNS MANAGER - RESPONSIVE ARCHITECTURE (PC, TABLET, MOBILE SP)
   Compliant with Apple Human Interface Guidelines & Material Design
   ========================================================================== */

/* Utility Visibility Helpers */
.mobile-only {
  display: none !important;
}

.tablet-only {
  display: none !important;
}

.desktop-only {
  display: flex !important;
}

/* ==========================================================================
   LAPTOPS & STANDARD MONITORS (1024px - 1440px, e.g. MacBook 13-inch)
   Strict Zero Horizontal Scroll Optimization
   ========================================================================== */
@media (max-width: 1440px) and (min-width: 1024px) {
  :root {
    --sidebar-width: 210px;
  }

  .content-viewport {
    padding: 18px 18px;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  .table-responsive {
    overflow-x: hidden !important;
  }

  .data-table {
    table-layout: fixed;
    width: 100%;
  }

  .kpi-grid {
    gap: 12px;
  }

  .kpi-card {
    padding: 12px 14px;
  }

  .kpi-value {
    font-size: 20px;
  }

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

/* ==========================================================================
   1. TABLET VIEWPORT (768px - 1023px)
   ========================================================================== */
@media (max-width: 1023px) and (min-width: 768px) {
  .tablet-only {
    display: flex !important;
  }

  /* Compact Icon-only Sidebar */
  :root {
    --sidebar-width: 68px;
  }

  .sidebar {
    padding: 16px 8px;
    align-items: center;
  }

  .nav-section-title, .nav-label, .nav-counter, .sidebar-footer {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
    width: 48px;
    height: 48px;
  }

  .nav-icon {
    font-size: 20px;
  }

  /* KPI Grid: 2 Columns */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Detail Panels: 1 Column */
  .grid-2-cols {
    grid-template-columns: 1fr;
  }

  .content-viewport {
    padding: 20px 24px;
  }

  /* Touch Target minimum 40px */
  .btn, .btn-icon, .form-input, .form-select {
    min-height: 40px;
  }
}

/* ==========================================================================
   2. SMARTPHONE / MOBILE SP VIEWPORT (< 768px)
   ========================================================================== */
@media (max-width: 767px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  /* Topbar Mobile */
  .topbar {
    padding: 0 16px;
  }

  .brand-name {
    font-size: 16px;
  }

  /* Drawer Navigation on Mobile */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -280px;
    width: 270px;
    z-index: 1500;
    background: #0d1322;
    border-right: 1px solid var(--border-medium);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1400;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  /* Viewport Padding */
  .content-viewport {
    padding: 16px;
  }

  .view-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .view-actions {
    justify-content: flex-start;
  }

  /* KPI Grid: 1 Column Stacked */
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .grid-2-cols {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Filter bar */
  .search-filter-bar {
    flex-direction: column;
  }

  .search-filter-bar .form-input,
  .search-filter-bar .form-select {
    max-width: 100%;
  }

  /* Modal Full Width on Mobile */
  .modal-container {
    max-width: 100%;
    border-radius: var(--radius-lg);
  }

  .emp-projects-grid {
    grid-template-columns: 1fr;
  }

  /* Stacked Responsive Table Rows for Employees */
  @media (max-width: 640px) {
    .data-table thead {
      display: none;
    }

    .data-table, .data-table tbody, .data-table tr, .data-table td {
      display: block;
      width: 100%;
    }

    .data-table tr {
      background: var(--bg-surface);
      border: 1px solid var(--border-subtle);
      border-radius: var(--radius-md);
      margin-bottom: 12px;
      padding: 12px;
    }

    .data-table td {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 0;
      border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
    }

    .data-table td:last-child {
      border-bottom: none;
      padding-top: 12px;
    }

    .data-table td::before {
      content: attr(data-label);
      font-size: 11px;
      font-weight: 700;
      color: var(--text-muted);
      text-transform: uppercase;
    }
  }
}
