/* ============================================================
   HOTEL WOOD STONE — Operational Device Optimization
   Phase 10.2 | Operational Device Optimization

   Loaded AFTER dashboard.css / page-embedded styles.
   Three optimization profiles:
     .hws-mobile  — housekeeping phones (< 640px)
     .hws-tablet  — frontdesk tablets  (640–1023px)
     .hws-desktop — management laptops (≥ 1024px)

   Body classes set automatically by HWSResponsive.
   Touch class .hws-touch set automatically on touch devices.
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   0. GLOBAL TOUCH FOUNDATION
   ════════════════════════════════════════════════════════════ */

/* Snap taps — remove 300ms delay on all interactive elements */
a, button, [role="button"], label,
input, select, textarea,
.tab-btn, .period-btn, .filter-pill,
.op-btn, .hk-room-card, .al-card,
.kpi-card, .hub-mod-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Smooth momentum scrolling for all scroll containers */
.modal-body, .data-table-wrap, .sidebar,
.hk-rooms-grid, .al-list, .tab-content,
[class*="-list"], [class*="-scroll"],
[class*="-grid"], .page-content {
  -webkit-overflow-scrolling: touch;
}

/* Visible press state for touch (no hover on touch) */
.hws-touch button:active,
.hws-touch [role="button"]:active,
.hws-touch .tab-btn:active,
.hws-touch .period-btn:active,
.hws-touch .filter-pill:active,
.hws-touch .hk-room-card:active,
.hws-touch .hub-mod-card:active {
  opacity: 0.72;
  transform: scale(0.97);
  transition: opacity 80ms ease, transform 80ms ease;
}

/* Faster transitions on touch — don't hold the user */
.hws-touch * {
  transition-duration: 150ms !important;
}
/* Exceptions: skeleton pulses, spinners */
.hws-touch .hws-spinner,
.hws-touch @keyframes { transition-duration: revert !important; }

/* Safe area insets — notched phones */
.hws-mobile body,
.hws-mobile .page-content {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* ════════════════════════════════════════════════════════════
   1. UNIVERSAL MINIMUM TOUCH TARGETS  (WCAG 2.5.5: 44×44px)
   ════════════════════════════════════════════════════════════ */
.hws-touch button,
.hws-touch [role="button"],
.hws-touch .tab-btn,
.hws-touch .period-btn,
.hws-touch .filter-pill,
.hws-touch select,
.hws-touch input[type="checkbox"],
.hws-touch input[type="radio"] {
  min-height: 44px;
}

/* Inputs: 16px font prevents iOS auto-zoom */
.hws-mobile input,
.hws-mobile select,
.hws-mobile textarea,
.hws-tablet input,
.hws-tablet select,
.hws-tablet textarea {
  font-size: 16px !important;
}

/* Comfortable form field height */
.hws-mobile input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.hws-mobile select,
.hws-tablet input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.hws-tablet select {
  min-height: 48px;
  padding-top: 12px;
  padding-bottom: 12px;
}

/* ════════════════════════════════════════════════════════════
   2. FRONTDESK TABLET — CHECK-IN / CHECK-OUT / BOOKING FORM
   ════════════════════════════════════════════════════════════ */

/* ── Large primary action buttons ─────────────────────────── */
.hws-tablet .ci-btn-primary,
.hws-tablet .co-btn-primary,
.hws-tablet .bf-btn-submit,
.hws-tablet .ra-btn-assign {
  min-height: 54px;
  font-size: 15px;
  padding: 0 28px;
  border-radius: 10px;
}

/* ── Arrivals / departures quick strip ─────────────────────── */
@media (max-width: 1023px) {
  .ci-arrivals-strip,
  .co-departures-strip {
    gap: 10px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }
  .ci-arrival-card,
  .co-departure-card {
    scroll-snap-align: start;
    min-width: 200px;
    flex-shrink: 0;
  }
}

/* ── Booking form: single-column on tablet ─────────────────── */
@media (max-width: 1023px) {
  .bf-form-grid,
  .bf-grid-2,
  .bf-two-col {
    grid-template-columns: 1fr !important;
  }
  .bf-section-wrap {
    padding: 20px 16px;
  }
}

/* ── Room allocation grid: larger tap zones ─────────────────── */
@media (max-width: 1023px) {
  .ra-room-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }
  .ra-room-card {
    min-height: 80px;
    border-radius: 10px;
  }
  .ra-room-number {
    font-size: 20px;
  }
}

/* ── Check-in form layout: large cards, clear steps ─────────── */
@media (max-width: 1023px) {
  .ci-step-strip {
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .ci-step-card {
    min-width: 140px;
    min-height: 60px;
    flex-shrink: 0;
  }
  .ci-main-panel {
    padding: 20px 16px;
  }
  .ci-guest-fields,
  .ci-doc-fields {
    grid-template-columns: 1fr !important;
  }
}

/* ── Fixed bottom action bar: tablet workflow ───────────────── */
.hws-tablet .ci-action-bar,
.hws-tablet .co-action-bar,
.hws-tablet .bf-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 120;
  background: rgba(8,8,8,0.95);
  border-top: 1px solid rgba(201,168,76,0.15);
  padding: 12px 20px max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
  align-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Add space so content isn't hidden behind fixed bar */
.hws-tablet .page-content {
  padding-bottom: 80px !important;
}

/* ── Pending dues: larger row targets ─────────────────────── */
@media (max-width: 1023px) {
  .pd-due-row {
    min-height: 60px;
    padding: 14px 16px;
  }
  .pd-pay-btn {
    min-height: 44px;
    min-width: 80px;
  }
}

/* ════════════════════════════════════════════════════════════
   3. HOUSEKEEPING MOBILE — ONE-HAND OPERATION
   ════════════════════════════════════════════════════════════ */

/* ── Room card: big tap area ───────────────────────────────── */
@media (max-width: 639px) {
  .hk-room-card {
    min-height: 72px;
    border-radius: 12px;
    padding: 14px 16px;
  }
  .hk-room-card-room {
    font-size: 18px;
    font-weight: 700;
  }
  .hk-status-chip,
  .rm-status-chip,
  .mr-priority-chip {
    min-height: 32px;
    font-size: 12px;
    padding: 0 14px;
    border-radius: 16px;
  }
}

/* ── Room grid: 2-col on mobile, no overflow ───────────────── */
@media (max-width: 639px) {
  .hk-rooms-grid,
  .rm-rooms-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* ── Status action buttons: full-width on mobile ───────────── */
@media (max-width: 639px) {
  .hk-panel-actions,
  .rm-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .hk-panel-actions button,
  .rm-panel-actions button {
    width: 100%;
    min-height: 52px;
    font-size: 15px;
    border-radius: 10px;
  }
  /* Primary action always at bottom (thumb reach) */
  .hk-panel-actions .hk-btn-primary,
  .rm-panel-actions .rm-btn-primary {
    order: 10;
  }
}

/* ── Slide panel: full-screen on mobile ────────────────────── */
@media (max-width: 639px) {
  .hk-slide-panel,
  .rm-slide-panel {
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    border-radius: 20px 20px 0 0 !important;
    padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
  }
  .hk-backdrop {
    background: rgba(0,0,0,0.6);
  }
}

/* ── Maintenance report: large form fields ─────────────────── */
@media (max-width: 639px) {
  .mr-form-wrap {
    padding: 16px;
  }
  .mr-section-header {
    font-size: 13px;
  }
  .mr-priority-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .mr-priority-card {
    min-height: 64px;
    border-radius: 10px;
  }
  .mr-submit-btn {
    width: 100%;
    min-height: 54px;
    font-size: 15px;
    margin-top: 8px;
  }
}

/* ── Filter pills: horizontal scroll on mobile ─────────────── */
@media (max-width: 639px) {
  .hk-filter-bar,
  .rm-filter-bar,
  .al-filter-bar,
  .hk-status-filter {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 8px;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .hk-filter-bar::-webkit-scrollbar,
  .rm-filter-bar::-webkit-scrollbar,
  .al-filter-bar::-webkit-scrollbar,
  .hk-status-filter::-webkit-scrollbar { display: none; }

  .filter-pill, .hk-filter-pill, .rm-filter-pill {
    scroll-snap-align: start;
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* ── Camera / Upload CTA: centered, large ──────────────────── */
@media (max-width: 639px) {
  .ic-capture-btn,
  .fu-upload-btn,
  .cp-grant-btn {
    width: 100%;
    min-height: 56px;
    font-size: 16px;
    border-radius: 12px;
  }
  .ic-preview-wrap {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
  }
  .fu-drop-zone {
    padding: 40px 20px;
    border-radius: 12px;
  }
  .fu-drop-icon {
    font-size: 40px;
  }
}

/* ════════════════════════════════════════════════════════════
   4. DASHBOARD RESPONSIVENESS — KPI + ANALYTICS + ALERTS
   ════════════════════════════════════════════════════════════ */

/* ── KPI card grid: 2-col on tablet, 1-col on mobile ───────── */
@media (max-width: 1023px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px;
  }
}
@media (max-width: 479px) {
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
  .kpi-card {
    padding: 18px 16px;
  }
}

/* ── Period switcher: scroll row on mobile ─────────────────── */
@media (max-width: 639px) {
  .period-bar,
  .kpi-period-bar,
  .rev-period-bar,
  .occ-period-bar,
  .ota-period-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 6px;
    padding-bottom: 4px;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .period-bar::-webkit-scrollbar { display: none; }
  .period-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* ── Chart containers: horizontal scroll on mobile ─────────── */
@media (max-width: 639px) {
  .chart-card canvas,
  .rev-chart-wrap canvas,
  .occ-chart-wrap canvas,
  .ota-chart-wrap canvas {
    min-width: 480px;
  }
  .chart-card,
  .rev-chart-wrap,
  .occ-chart-wrap,
  .ota-chart-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Revenue / OTA 2-chart row: stack on tablet ─────────────── */
@media (max-width: 1023px) {
  .rev-charts-row,
  .ota-charts-row,
  .occ-charts-row {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
}

/* ── OTA source cards: responsive grid ─────────────────────── */
@media (max-width: 1023px) {
  .ota-sources-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}
@media (max-width: 639px) {
  .ota-sources-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .ota-src-card {
    padding: 14px 12px;
  }
}

/* ── Comparison matrix table: horizontal scroll ─────────────── */
@media (max-width: 639px) {
  .ota-compare-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ota-compare-wrap table {
    min-width: 560px;
  }
}

/* ── Alerts panel: full-width dropdown on mobile ───────────── */
@media (max-width: 639px) {
  .al-dropdown {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 0 !important;
    overflow-y: auto;
  }
  .al-card {
    padding: 14px 16px;
    border-radius: 10px;
  }
}

/* ── Alerts bell: larger tap zone on mobile ─────────────────── */
@media (max-width: 639px) {
  #alBellBtn {
    width: 48px;
    height: 48px;
  }
}

/* ════════════════════════════════════════════════════════════
   5. DATA TABLES — RESPONSIVE
   ════════════════════════════════════════════════════════════ */

/* Horizontal scroll wrapper for all data tables */
@media (max-width: 1023px) {
  .data-table-wrap,
  .table-responsive,
  [class*="-table-wrap"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }
  .data-table {
    min-width: 640px;
  }
}

/* On mobile: hide low-priority columns */
@media (max-width: 639px) {
  .data-table .col-secondary,
  .data-table .col-hide-mobile,
  th.col-secondary,
  td.col-secondary {
    display: none;
  }
  .data-table {
    min-width: 400px;
  }
  .data-table td,
  .data-table th {
    padding: 12px 10px;
    font-size: 12px;
  }
  .row-actions {
    opacity: 1 !important; /* Always visible on touch */
  }
}

/* ════════════════════════════════════════════════════════════
   6. MODALS — MOBILE FRIENDLY
   ════════════════════════════════════════════════════════════ */

@media (max-width: 639px) {
  .modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .modal {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 92vh !important;
    border-radius: 20px 20px 0 0 !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .modal-footer {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .modal-footer .btn {
    width: 100%;
    min-height: 50px;
  }
}

/* ════════════════════════════════════════════════════════════
   7. PORTAL HUB — MOBILE LAYOUT
   ════════════════════════════════════════════════════════════ */

@media (max-width: 639px) {
  .hub-modules-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    padding: 0 12px;
  }
  .hub-mod-card {
    padding: 18px 14px;
    min-height: 90px;
  }
  .hub-hero-title {
    font-size: clamp(26px, 8vw, 36px);
  }
  .hub-hero-sub {
    font-size: 13px;
  }
  .hub-clock {
    font-size: 20px;
  }
}

@media (max-width: 1023px) {
  .hub-modules-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 14px;
  }
}

/* ════════════════════════════════════════════════════════════
   8. SIDEBAR — COLLAPSE ON TABLET
   ════════════════════════════════════════════════════════════ */

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 200;
    height: 100vh;
    top: 0;
    transition: transform 200ms ease;
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
  }
  .page-layout {
    display: block !important;
  }
  .page-content {
    margin-left: 0 !important;
  }
  /* Hamburger overlay */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }
  .sidebar-backdrop.visible { display: block; }
}

/* ── Header: mobile compact ─────────────────────────────────── */
@media (max-width: 639px) {
  .page-header {
    padding: 10px 16px;
    gap: 12px;
  }
  .header-search-input {
    font-size: 14px;
    min-height: 40px;
  }
}

/* ════════════════════════════════════════════════════════════
   9. PERFORMANCE — PAINT + RENDER OPTIMIZATIONS
   ════════════════════════════════════════════════════════════ */

/* Layer-promote animated elements — avoid paint storms */
.hws-spinner,
.sidebar,
.modal,
.al-dropdown,
.hk-slide-panel,
.rm-slide-panel {
  will-change: transform;
}

/* Contain KPI card repaint to the card itself */
.kpi-card,
.hk-room-card,
.ota-src-card,
.hub-mod-card {
  contain: layout style;
}

/* GPU-accelerate chart canvases */
canvas {
  transform: translateZ(0);
}

/* Reduce animation complexity on mobile */
@media (max-width: 639px) {
  .modal,
  .al-dropdown,
  .hk-slide-panel {
    animation-duration: 150ms !important;
  }
  /* Disable ambient background gradients on mobile (expensive repaint) */
  .page-content[style*="radial-gradient"] {
    /* Background kept but no animation */
    background-attachment: scroll !important;
  }
}

/* ════════════════════════════════════════════════════════════
   10. OPERATOR FOCUS — LARGE TEXT FOR OPERATIONAL READABILITY
   ════════════════════════════════════════════════════════════ */

/* Key operational numbers: bigger on tablet */
@media (min-width: 640px) and (max-width: 1023px) {
  .kpi-value,
  .ci-stat-number,
  .co-stat-number,
  .hk-room-number {
    font-size: clamp(28px, 3vw, 36px);
  }
}

/* Room numbers on room allocation: very large for quick recognition */
@media (max-width: 1023px) {
  .ra-room-number,
  .hk-room-card-room {
    font-size: clamp(22px, 3.5vw, 28px);
    font-weight: 800;
    letter-spacing: -0.5px;
  }
}

/* ════════════════════════════════════════════════════════════
   11. PRINT OVERRIDES (Management Laptops)
   ════════════════════════════════════════════════════════════ */

@media print {
  .sidebar, .page-header,
  .hws-error-banner, #hws-fullpage-loader,
  .al-dropdown, .hk-slide-panel,
  .period-bar, .filter-bar,
  .row-actions { display: none !important; }

  .page-content { padding: 0 !important; }
  .kpi-card, .data-table { break-inside: avoid; }
  body { background: white !important; color: #111 !important; }
}
