/* ==========================================================================
   Responsive Architecture & Overrides
   ========================================================================== */

/* --- 1. Large Screens & Desktop Collapsible --- */
@media (min-width: 992px) {
  /* Transition timings for a super smooth slide experience */
  .pp-sidebar, .pp-main {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* When the sidebar is collapsed on desktop */
  .sidebar-collapsed .pp-sidebar {
    width: 70px;
  }

  /* Hide textual elements inside the collapsed sidebar */
  .sidebar-collapsed .pp-sidebar .logo-text,
  .sidebar-collapsed .pp-sidebar .nav-label,
  .sidebar-collapsed .pp-sidebar .nav-item span {
    opacity: 0;
    pointer-events: none;
    display: none !important;
  }

  /* Center the icons and brand mark in collapsed state */
  .sidebar-collapsed .pp-sidebar .logo {
    justify-content: center;
    padding: 1.5rem 0;
  }

  .sidebar-collapsed .pp-sidebar .logo-icon {
    font-size: 1.75rem;
    margin: 0 !important;
  }

  .sidebar-collapsed .pp-sidebar .nav-item {
    justify-content: center;
    padding: 0.75rem 0;
    margin: 0.25rem 0.5rem;
  }

  .sidebar-collapsed .pp-sidebar .nav-item i {
    font-size: 1.25rem;
    margin: 0 !important;
    width: auto;
    text-align: center;
  }

  /* Main panel adjustments */
  .sidebar-collapsed .pp-main {
    margin-left: 70px;
    width: calc(100% - 70px);
  }

  /* Sticky Topbar collapse alignment */
  .sidebar-collapsed .pp-topbar {
    width: 100%;
  }
}

/* --- 2. Mobile & Tablet Drawers (< 992px) --- */
@media (max-width: 991.98px) {
  /* Sidebar initially slides out of the viewport */
  .pp-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    height: 100vh;
  }

  /* Content area occupies full width */
  .pp-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Open Drawer State */
  .sidebar-open .pp-sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-premium);
  }

  /* Show Backdrop Overlay */
  .sidebar-open .pp-sidebar-overlay {
    display: block;
    opacity: 1;
  }

  /* Topbar Padding adjustments */
  .pp-topbar {
    padding: 0.75rem 1rem;
  }

  .pp-content-container {
    padding: 1rem;
  }

  /* Modern cards responsive padding */
  .pp-card {
    padding: 1.25rem;
    margin-bottom: 1rem;
  }

  /* Adjust display text */
  .page-display-title {
    font-size: 1.1rem;
  }
}

/* --- 3. Extra Small Mobile Devices (< 576px) --- */
@media (max-width: 575.98px) {
  /* Hide page title in topbar on very small screens to fit profile */
  .page-display-title {
    display: none !important;
  }

  /* Slim down modern forms */
  .form-control, .form-select {
    padding: 0.45rem 0.75rem;
    font-size: 0.825rem;
  }

  /* Stack button layouts */
  .d-flex.justify-content-between {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start !important;
  }

  .d-flex.justify-content-between a, 
  .d-flex.justify-content-between button {
    width: 100%;
    text-align: center;
  }

  /* Force responsive scroll in tables on extreme small screens */
  .table-responsive {
    border: 0;
  }

  /* Custom padding for notifications */
  .pp-card ul {
    padding-left: 1.25rem;
  }
}

/* ==========================================================================
   Responsive Swipeable Tables (Mobile & Tablet ≤ 991px)
   Tables stay as full HTML tables — user swipes left/right to scroll.
   A fade-shadow on the right edge hints that more columns exist.
   ========================================================================== */
@media (max-width: 991.98px) {

  /* Scrollable container with smooth iOS touch momentum */
  .table-modern,
  .table-responsive.table-modern {
    overflow: auto !important;           /* fully override overflow: hidden from style.css */
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;   /* smooth momentum on iOS */
    overscroll-behavior-x: contain;      /* prevent page scroll hijack */
    border-radius: 12px !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
    background: var(--card-bg) !important;
    position: relative;
  }

  /* Ensure the inner table has enough room to be wider than the viewport */
  .table-modern table,
  .table-modern .table {
    min-width: 600px;   /* prevents columns from squishing — adjust per need */
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }

  /* Compact cell padding on small screens to fit more content */
  .table-modern thead th,
  .container table th,
  table.table th {
    padding: 0.7rem 0.75rem !important;
    font-size: 0.7rem !important;
    white-space: nowrap;
  }

  .table-modern tbody td,
  .container table td,
  table.table td {
    padding: 0.7rem 0.75rem !important;
    font-size: 0.82rem !important;
    white-space: nowrap;
  }
}

/* Scroll hint: right-edge fade shadow when table overflows */
@media (max-width: 991.98px) {
  /* Wrapper that holds the scroll-shadow effect */
  .table-scroll-wrap {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
  }

  /* Right fade-out gradient — fades when scrolled to end via JS */
  .table-scroll-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.85));
    pointer-events: none;
    border-radius: 0 12px 12px 0;
    transition: opacity 0.25s ease;
    z-index: 2;
  }

  /* Hide fade when user has scrolled to the end */
  .table-scroll-wrap.scrolled-end::after {
    opacity: 0;
  }
}

/* Thin custom scrollbar on the table — visible on desktop Chrome, subtle on mobile */
.table-modern::-webkit-scrollbar {
  height: 5px;
}
.table-modern::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.table-modern::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.table-modern::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}