/**
 * AL-HASSAN BRICKS — DIGI KHATA
 * Comprehensive Responsive Layout Stylesheet
 * Optimized for Mobiles, Tablets, Laptops & Desktops
 */

/* ==========================================================================
   1. TABLET & MOBILE (< 992px) — OFF-CANVAS SIDEBAR DRAWER & NAVIGATION
   ========================================================================== */
@media (max-width: 991.98px) {
  .app-container {
    flex-direction: column;
    position: relative;
  }

  /* Offcanvas Drawer Sidebar */
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 1060 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s ease !important;
    box-shadow: none !important;
    background-color: var(--bg-sidebar) !important;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.45) !important;
  }

  .app-header {
    padding: 0 1rem;
    height: 3.75rem;
  }

  .header-title-area {
    gap: 0.5rem;
  }

  .header-title {
    font-size: 1rem;
    max-width: 220px;
  }

  .header-date {
    display: none;
  }

  .header-actions {
    gap: 0.65rem;
  }

  .search-wrapper {
    display: none !important;
  }

  #page-content-wrapper {
    padding: 1rem !important;
    /* Bottom padding to prevent content from getting covered by bottom bar */
    padding-bottom: 5.5rem !important;
  }

  .app-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-default);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .app-bottom-bar > div:first-child {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .app-bottom-bar .btn-sleek {
    flex: 1;
    font-size: 0.75rem;
    padding: 0.65rem 0.5rem;
    white-space: nowrap;
    text-align: center;
  }

  .app-bottom-bar > div:last-child {
    display: none !important;
  }
}

/* ==========================================================================
   2. SMALL TABLETS & MOBILE SCREENS (< 768px)
   ========================================================================== */
@media (max-width: 767.98px) {
  /* Stat Cards */
  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  /* Tables */
  .table-container {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background-color: var(--bg-card);
  }

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

  /* Modals */
  .modal-dialog {
    margin: 0.75rem auto;
    max-width: calc(100% - 1.5rem);
  }

  .modal-body {
    padding: 1.25rem !important;
  }

  /* Buttons & Form controls: touch targets min 44px on mobile */
  .form-control,
  .form-select {
    font-size: 1rem; /* Prevents auto-zoom on iOS */
    min-height: 44px;
  }

  .btn-sleek {
    min-height: 42px;
    font-size: 0.8125rem;
  }
}

/* ==========================================================================
   3. EXTRA SMALL MOBILE PHONES (< 576px)
   ========================================================================== */
@media (max-width: 575.98px) {
  .header-title {
    max-width: 140px;
    font-size: 0.9rem;
  }

  .btn-hamburger-toggle {
    width: 38px;
    height: 38px;
  }

  .header-avatar {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
  }

  #page-content-wrapper {
    padding: 0.75rem !important;
    padding-bottom: 5.5rem !important;
  }

  /* KPI Grid on Mobile */
  .stat-card {
    padding: 0.85rem;
  }

  .stat-label {
    font-size: 0.6875rem;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  .stat-meta {
    font-size: 0.625rem;
    margin-top: 0.25rem;
  }

  /* Khata Top Card */
  .card-sleek {
    border-radius: var(--radius-md);
  }

  .card-header-sleek {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .card-header-sleek > div,
  .card-header-sleek > div.d-flex {
    width: 100%;
    justify-content: space-between;
  }

  /* Chart Canvas height on small mobile */
  #salesChartCanvas {
    max-height: 200px !important;
  }

  /* Bottom Actions dock on tiny screens */
  .app-bottom-bar .btn-sleek {
    padding: 0.55rem 0.25rem;
    font-size: 0.7rem;
  }

  .app-bottom-bar .btn-sleek i {
    display: inline-block;
    margin-right: 2px !important;
  }

  /* Receipt Modal */
  #receiptContent {
    font-size: 0.8rem;
  }

  #receiptContent table td,
  #receiptContent table th {
    padding: 0.4rem 0.5rem;
  }
}

/* ==========================================================================
   4. LARGE LAPTOPS & DESKTOPS (>= 1200px)
   ========================================================================== */
@media (min-width: 1200px) {
  .app-sidebar {
    width: 270px;
  }

  #page-content-wrapper {
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
  }
}

