/* ============================================
   responsive.css — POS-Core Mobile Responsive
   Desktop view is UNTOUCHED.
   All rules are inside @media queries only.
   Load AFTER inline <style> in every page.
   ============================================ */

/* ── Hamburger button (hidden on desktop, injected by left-nav-canonical.js) ── */
.hamburger-btn {
  display: none;
}
.sidebar-overlay {
  display: none;
}

/* ══════════════════════════════════════════════
   ≤1200px — Grid column adjustments
   ══════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .info-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ══════════════════════════════════════════════
   ≤900px — Sidebar narrows, grids to 2 columns
   ══════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar {
    width: 200px;
  }
  .info-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .summary-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .report-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ══════════════════════════════════════════════
   ≤768px — Main mobile breakpoint
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Hamburger mode ── */
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border, #2b2b2b);
    border-radius: 8px;
    color: var(--text, #d0d0d0);
    font-size: 22px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .hamburger-btn:hover {
    background: var(--panel2, #242424);
  }
  .hamburger-btn:active {
    background: var(--border, #2b2b2b);
  }

  .sidebar {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 900 !important;
    background: var(--panel, #1c1c1c) !important;
    border-right: 1px solid var(--border, #2b2b2b) !important;
    border-bottom: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.sidebar--open {
    display: block !important;
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 899;
    display: none;
    -webkit-tap-highlight-color: transparent;
  }
  .sidebar-overlay.active {
    display: block;
  }

  /* ── Header ── */
  .header {
    height: auto !important;
    min-height: 48px;
    padding: 8px 12px !important;
    flex-wrap: wrap;
    gap: 6px;
  }
  .brand {
    font-size: 14px !important;
  }
  .header-right {
    flex-wrap: wrap;
    gap: 6px;
  }
  .badge {
    font-size: 11px !important;
    padding: 4px 8px !important;
  }

  /* ── Main & Content ── */
  .main {
    flex-direction: column;
  }
  .content {
    padding: 10px !important;
  }

  /* ── Tables: horizontal scroll ── */
  .table-wrap,
  .section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    font-size: 12px;
  }
  th, td {
    padding: 8px 6px;
  }

  /* ── Filter bars & forms: stack vertically ── */
  .filter-row,
  .filter-bar,
  .form-inline {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .filter-row > *,
  .filter-bar > *,
  .form-inline > * {
    width: 100% !important;
    min-width: unset !important;
  }

  /* ── Grids: force 1-2 columns ── */
  .info-grid,
  .kpi-grid,
  .summary-grid,
  .detail-grid,
  .stats-grid,
  .cast-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .five-step-grid {
    grid-template-columns: 1fr !important;
  }
  .report-grid {
    grid-template-columns: 1fr !important;
  }
  .summary-card {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* ── Modals ── */
  .modal,
  .popup-box {
    max-width: 95% !important;
    width: 95% !important;
    margin: 10px auto !important;
    padding: 14px !important;
  }
  .modal-overlay,
  .popup-overlay {
    padding: 10px !important;
    align-items: flex-start !important;
  }

  /* ── Tabs: horizontal scroll ── */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    flex-wrap: nowrap !important;
  }

  /* ── Section ── */
  .section {
    padding: 12px !important;
    border-radius: 10px !important;
  }

  /* ── Page titles ── */
  .page-title,
  h1 {
    font-size: 18px !important;
  }
  h2 {
    font-size: 16px !important;
  }

  /* ── Buttons: better touch targets ── */
  .btn {
    min-height: 40px;
    padding: 8px 14px !important;
  }

  /* ── invoices/create: 16-col grid horizontal scroll ── */
  .inv-row {
    min-width: 900px;
  }

  /* ── shifts/calendar: smaller heatmap cells ── */
  .hm-cell {
    width: 48px !important;
    min-width: 48px !important;
  }
  .hm-col-header {
    min-width: 48px !important;
  }
  .hm-corner {
    min-width: 44px !important;
    width: 44px !important;
  }

  /* ── closings/daily: stack panels ── */
  .month-panel {
    width: 100% !important;
    max-height: 300px;
  }

  /* ── Specific inputs: unset fixed widths ── */
  .add-cast-select {
    min-width: unset !important;
    width: 100% !important;
  }
  .sel-h,
  .sel-m {
    width: auto !important;
    min-width: 50px;
  }

  /* ── Seat grid ── */
  .seat-grid {
    gap: 6px !important;
  }
  .seat-grid .seat-card {
    min-width: 70px !important;
  }

  /* ── Payment blocks form ── */
  .pb-add-form {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .pb-add-form .pb-select,
  .pb-add-form .pb-input {
    width: 100% !important;
  }

  /* ── Review sheet checkboxes ── */
  .review-sheet .check-row {
    flex-wrap: wrap;
  }

  /* ── Action buttons bar ── */
  .action-bar {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
}

/* ══════════════════════════════════════════════
   ≤480px — Extra small (iPhone SE etc)
   ══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .header {
    padding: 6px 10px !important;
  }
  .header-right .badge {
    display: none !important;
  }
  .content {
    padding: 8px !important;
  }
  .modal,
  .popup-box {
    width: 98% !important;
    padding: 10px !important;
  }
  .btn {
    font-size: 12px !important;
    padding: 6px 10px !important;
  }
  table {
    font-size: 11px;
  }
  th, td {
    padding: 6px 4px;
  }
  .section {
    padding: 10px !important;
  }
  .info-grid,
  .kpi-grid,
  .summary-grid,
  .detail-grid {
    grid-template-columns: 1fr !important;
  }
  .page-title,
  h1 {
    font-size: 16px !important;
  }
}

/* ══════════════════════════════════════════════
   Print: ensure sidebar/hamburger hidden + 1ページ収め
   ══════════════════════════════════════════════ */
@page {
  size: A4;
  margin: 10mm;
}
@media print {
  html, body {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    color: #000 !important;
  }
  * {
    color: #000 !important;
    background: transparent !important;
    border-color: #ccc !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  .sidebar,
  .hamburger-btn,
  .sidebar-overlay,
  .header {
    display: none !important;
  }
  .app {
    min-height: auto !important;
  }
  .main {
    display: block !important;
  }
  .content {
    padding: 0 !important;
  }
  /* 印刷用店舗名ヘッダー（通常時は非表示） */
  .print-store-header {
    display: block !important;
    text-align: center;
    margin-bottom: 12px;
    page-break-after: avoid;
  }
  .print-store-header h1 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px;
  }
  .print-store-header p {
    font-size: 11px;
    margin: 0;
  }
}
/* 印刷用店舗名ヘッダー（画面では非表示） */
.print-store-header {
  display: none;
}
