/* ==========================================================================
   Torédo Finance Tracker - Mobile & Tablet Responsive Media Queries
   ========================================================================== */

.pc-only {
  display: inline-flex;
}

@media (max-width: 991px) {
  .pc-only {
    display: none !important;
  }
}

.mobile-header {
  display: none;
  min-height: 60px;
  height: 60px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
  box-sizing: border-box;
}

.mobile-menu-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: #fff;
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  padding: 0;
  line-height: 1;
  margin: 0;
}

.hamburger-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  transform: translateY(-1px);
  line-height: 1;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1400;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.25s ease-out;
}

.mobile-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}


@media (max-width: 991px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1500;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    width: 280px !important;
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .sidebar.mobile-open {
    transform: translateX(0) !important;
    display: flex !important;
  }

  .sidebar .sidebar-toggle-btn {
    display: none;
  }

  .main-content {
    padding: 12px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 20px;
    width: 100%;
  }

  .topbar > div:last-child {
    width: 100%;
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .filter-controls {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 12px;
    padding: 12px;
  }

  .date-picker-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
  }

  .date-picker-group input {
    width: 100% !important;
    max-width: 100% !important;
  }

  .preset-btn-group {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px !important;
    width: 100%;
  }

  .preset-btn-group .btn {
    width: 100%;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .triad-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .grid-2col,
  .form-row,
  .triad-box .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
  }

  /* Make dashboard a flex column to reorder net profit to the top */
  #view-dashboard.active {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
  #view-dashboard.active > .grid-2col {
    display: contents;
  }
  #view-dashboard.active .budget-panel {
    order: -1;
  }
  #view-dashboard.active > *,
  #view-dashboard.active .grid-2col > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }

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

  .pos-layout {
    grid-template-columns: 1fr;
  }

  /* Prevent auto-zooming on iOS Safari when focusing text/number/date fields & proportion widths */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  select,
  textarea,
  .search-input {
    font-size: 16px !important;
    padding: 12px 14px !important;
    max-width: 100% !important;
  }

  .btn {
    min-height: 44px;
  }

  .nav-btn {
    min-height: 48px;
    font-size: 15px;
  }
}

@media (max-width: 575px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .search-input {
    width: 100%;
  }

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

  .modal-card {
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
  }

  .view-toggle {
    flex-wrap: wrap;
    gap: 2px;
  }

  .view-toggle button {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  #summary-pivot-toggle {
    width: 100%;
    justify-content: center;
  }
}

/* ==========================================================================
   Receipt Print Stylesheet (@media print)
   ========================================================================== */
@media print {
  body * {
    visibility: hidden !important;
  }

  #modal-receipt,
  #modal-receipt * {
    visibility: visible !important;
  }

  #modal-receipt {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 20px !important;
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    z-index: 99999 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
  }

  #modal-receipt .modal-card {
    background: #ffffff !important;
    color: #000000 !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 600px !important;
    padding: 0 !important;
    margin: 0 auto !important;
  }

  #modal-receipt .modal-header,
  #modal-receipt .modal-footer,
  .modal-close,
  .sidebar,
  .topbar,
  .toast-container {
    display: none !important;
  }

  #receipt-modal-body * {
    color: #000000 !important;
  }

  .cart-summary-box {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    color: #000000 !important;
  }

  .cart-summary-box * {
    color: #000000 !important;
  }

  .data-table th,
  .data-table td {
    color: #000000 !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
}
