/*
 * Mobile Responsive Overrides
 * Breakpoint: 991.98px (matches mobile bottom nav)
 * Bottom nav: 64px tall, z-index 1050
 */

@media (max-width: 991.98px) {

  /* ============================================================
   * 1. WIZARD BUILDERS - STICKY BOTTOM BAR
   * ============================================================ */

  .wizard-mobile-bottom-bar {
    position: fixed;
    bottom: 64px; /* height of mobile-bottom-nav */
    left: 0;
    right: 0;
    z-index: 1040; /* below nav, above content */
    background: var(--bg-surface, #FFFFFF);
    border-top: 1px solid var(--border-default, #e5e7eb);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  }

  /* Public builder has no bottom nav - bar sits at bottom: 0 */
  .wizard-mobile-bottom-bar.no-nav {
    bottom: 0;
  }

  /* Dark mode */
  [data-bs-theme="dark"] .wizard-mobile-bottom-bar {
    background: #1a1a2e;
    border-top-color: #374151;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.3);
  }

  /* Bar contents */
  .wiz-bar-price {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
  }

  [data-bs-theme="dark"] .wiz-bar-price {
    color: #f1f5f9;
  }

  .wiz-bar-details-link {
    font-size: 11px;
    color: #3b82f6;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
  }

  .wiz-bar-next-btn {
    background: #00205B;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    border: none;
  }

  .wiz-bar-back-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    padding: 0;
  }

  /* ============================================================
   * 2. WIZARD - HALF-SCREEN DRAWER
   * ============================================================ */

  .wizard-mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1060;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .wizard-mobile-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .wizard-mobile-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55vh;
    background: var(--bg-surface, #FFFFFF);
    border-radius: 16px 16px 0 0;
    z-index: 1061;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  .wizard-mobile-drawer.open {
    transform: translateY(0);
  }

  /* Dark mode */
  [data-bs-theme="dark"] .wizard-mobile-drawer {
    background: #1a1a2e;
  }

  /* Drawer handle */
  .wiz-drawer-handle {
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 10px auto 4px;
  }

  [data-bs-theme="dark"] .wiz-drawer-handle {
    background: #4b5563;
  }

  /* Drawer header */
  .wiz-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px 10px;
    border-bottom: 1px solid #e5e7eb;
  }

  [data-bs-theme="dark"] .wiz-drawer-header {
    border-bottom-color: #374151;
  }

  .wiz-drawer-header h6 {
    margin: 0;
    font-weight: 700;
  }

  .wiz-drawer-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
  }

  [data-bs-theme="dark"] .wiz-drawer-close {
    background: #334155;
    color: #94a3b8;
  }

  /* Drawer body */
  .wiz-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
  }

  /* Drawer section label */
  .wiz-drawer-section-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin: 8px 0 6px;
  }

  [data-bs-theme="dark"] .wiz-drawer-section-label {
    color: #94a3b8;
  }

  /* Drawer items */
  .wiz-drawer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 12px;
  }

  .wiz-drawer-item-name {
    color: #475569;
  }

  [data-bs-theme="dark"] .wiz-drawer-item-name {
    color: #cbd5e1;
  }

  .wiz-drawer-item-price {
    font-weight: 600;
    color: #0f172a;
  }

  [data-bs-theme="dark"] .wiz-drawer-item-price {
    color: #f1f5f9;
  }

  .wiz-drawer-item-included {
    color: #94a3b8;
    font-style: italic;
    font-size: 11px;
  }

  [data-bs-theme="dark"] .wiz-drawer-item-included {
    color: #64748b;
  }

  /* Drawer total */
  .wiz-drawer-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 2px solid #e5e7eb;
  }

  [data-bs-theme="dark"] .wiz-drawer-total {
    border-top-color: #374151;
  }

  /* ============================================================
   * 3. WIZARD - STEP LABEL
   * ============================================================ */

  .wizard-mobile-step-label {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    padding: 8px 16px 4px;
  }

  .wizard-mobile-step-label .step-num {
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
  }

  /* ============================================================
   * 4. WIZARD - CONTENT PADDING
   * ============================================================ */

  .wizard-has-bottom-bar {
    padding-bottom: 80px; /* bottom bar height + breathing room */
  }

  /* Extra padding for internal builder which has both wizard bar + bottom nav */
  body:has(.wizard-mobile-bottom-bar:not(.no-nav)) .sw-container,
  body:has(.wizard-mobile-bottom-bar:not(.no-nav)) .bw-container {
    padding-bottom: 140px; /* wizard bar + bottom nav + breathing room */
  }

  /* ============================================================
   * 5. WIZARD - HIDE DESKTOP SIDEBAR ON MOBILE
   * Applied via d-none d-lg-block in Blade; backup rule
   * ============================================================ */

  .wizard-desktop-sidebar {
    display: none !important;
  }

  /* ============================================================
   * 6. WIZARD - OPTION ROW THUMBNAILS
   * ============================================================ */

  .option-row-photo {
    width: 44px !important;
    height: 44px !important;
  }

  /* ============================================================
   * 7. DASHBOARD - FUNNEL TO HORIZONTAL BARS
   * ============================================================ */

  body.redesign-page .wc-db-funnel-stage {
    width: 100% !important;
    border-radius: 8px !important;
  }

  /* ============================================================
   * 8. DASHBOARD - SALES TABLE HIDDEN
   * ============================================================ */

  body.redesign-page .wc-db-sales-section {
    display: none;
  }

  /* ============================================================
   * 9. DASHBOARD - RECENT ESTIMATES CARDS
   * ============================================================ */

  body.redesign-page .wc-db-recent-table thead {
    display: none;
  }

  body.redesign-page .wc-db-recent-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    gap: 4px;
  }

  /* ============================================================
   * 10. ESTIMATES SPLIT VIEW - FULL-SCREEN LIST
   * ============================================================ */

  .est-split-view {
    flex-direction: column;
    height: auto;
  }

  .est-list-panel {
    width: 100%;
    height: auto;
    max-height: none;
    border-right: none;
  }

  .est-detail-panel {
    display: none;
  }

  /* When detail is shown on mobile */
  .est-split-view.mobile-show-detail .est-list-panel {
    display: none;
  }

  .est-split-view.mobile-show-detail .est-detail-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  /* ============================================================
   * 11. ESTIMATE DETAIL - ITEMS CARD LAYOUT
   * ============================================================ */

  .est-items-table thead {
    display: none;
  }

  .est-items-table tbody tr {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle, #f1f5f9);
  }

  /* Hide less important columns */
  .est-items-table td.col-variant,
  .est-items-table td.col-discount {
    display: none;
  }

  /* ============================================================
   * 12. ESTIMATE DETAIL - ACTION BUTTONS SCROLLABLE
   * ============================================================ */

  .est-d-actions {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    white-space: nowrap;
  }

  .est-d-actions::-webkit-scrollbar {
    display: none;
  }

  /* ============================================================
   * 13. ESTIMATE DETAIL - VEHICLE DETAILS SINGLE COLUMN
   * ============================================================ */

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

  /* ============================================================
   * LANDSCAPE OVERRIDES
   * ============================================================ */

} /* end @media (max-width: 991.98px) */


/* Landscape override for drawer height */
@media (max-width: 991.98px) and (orientation: landscape) {
  .wizard-mobile-drawer {
    height: 75vh;
  }
}


/* ============================================================
 * 15. SAFE AREA SUPPORT (notched devices)
 * ============================================================ */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 991.98px) {
    .wizard-mobile-bottom-bar {
      padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .wizard-mobile-drawer {
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}
