/* BuildFlow HVAC Suite (V1.0) - High-Density Compact Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
  --primary-color: #0284c7;
  --primary-hover: #0369a1;
  --bg-dark: #0f172a;
  --surface-dark: #1e293b;
  --border-dark: #334155;
}

* {
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  box-sizing: border-box;
}

html, body {
  direction: rtl;
  text-align: right;
  background-color: #f8fafc;
  color: #0f172a;
  overflow-x: hidden !important;
  max-width: 100vw;
  margin: 0;
  padding: 0;
}

body.dark {
  background-color: #0b1120;
  color: #f1f5f9;
}

/* Custom Scrollbar (Slim) */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.dark ::-webkit-scrollbar-thumb {
  background: #334155;
}

/* Hide Number Input Spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

/* Glassmorphism Cards */
.glass-panel {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(226, 232, 240, 0.9);
}
.dark .glass-panel {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(30, 41, 59, 0.8);
}

/* Phase Transitions & Apple Spring Physics */
@keyframes phaseSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.phase-animate {
  animation: phaseSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Tap Feedback for Mobile Touch */
.tap-bounce {
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.tap-bounce:active {
  transform: scale(0.96);
}

/* No Scrollbar Utility */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Wizard Badge Styling (Compact & Wrap-Friendly) */
.step-badge {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
.step-badge.active {
  background-color: #0284c7 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}
.step-badge.completed {
  background-color: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}
.dark .step-badge.completed {
  background-color: rgba(6, 78, 59, 0.3);
  color: #6ee7b7;
  border-color: #065f46;
}

/* Sleek Mobile Micro-Progress Bar & Segments */
.mobile-stepper-dash {
  height: 3px;
  border-radius: 9999px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.mobile-stepper-dash.active {
  background: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}
.mobile-stepper-dash.completed {
  background: #10b981;
}
.mobile-stepper-dash.pending {
  background: rgba(51, 65, 85, 0.5);
}

/* Mobile Bottom Cockpit Dock - Sleek Floating Glass */
.mobile-dock {
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
}

/* Design Tokens: Mobile Button Architecture */
.hvac-btn-primary {
  min-height: 44px;
  height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.15s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hvac-btn-primary:active {
  transform: scale(0.96);
}

.hvac-btn-success {
  min-height: 44px;
  height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  color: #ffffff;
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.15s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hvac-btn-success:active {
  transform: scale(0.96);
}

.hvac-btn-secondary {
  min-height: 40px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(71, 85, 105, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hvac-btn-secondary:hover {
  background: rgba(51, 65, 85, 0.95);
  color: #ffffff;
}
.hvac-btn-secondary:active {
  transform: scale(0.96);
}

.hvac-btn-danger {
  min-height: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  color: #fda4af;
  background: rgba(159, 18, 57, 0.35);
  border: 1px solid rgba(225, 29, 72, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
  cursor: pointer;
  touch-action: manipulation;
}
.hvac-btn-danger:hover {
  background: rgba(159, 18, 57, 0.6);
  color: #ffffff;
}
.hvac-btn-danger:active {
  transform: scale(0.96);
}

.hvac-btn-action {
  min-height: 40px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hvac-btn-action:active {
  transform: scale(0.96);
}

/* Room Containment & Tab Strip */
.room-tab-item {
  height: 40px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  touch-action: manipulation;
}
.room-tab-item.active {
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 3px 12px rgba(2, 132, 199, 0.45);
}
.room-tab-item.inactive {
  background: rgba(30, 41, 59, 0.85);
  color: #94a3b8;
  border-color: rgba(51, 65, 85, 0.6);
}
.room-tab-item.inactive:hover {
  background: rgba(51, 65, 85, 0.95);
  color: #f1f5f9;
}

/* Room Executive Overview Tile (Multi-Room Grid) */
.room-executive-tile {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 16px;
  padding: 12px 14px;
  transition: all 0.2s ease;
}
.room-executive-tile:hover {
  border-color: rgba(14, 165, 233, 0.6);
  background: rgba(30, 41, 59, 0.9);
}

/* Modal Backdrop */
.modal-overlay {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
}

/* Slide-Over Materials Drawer */
.materials-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  z-index: 60;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.2);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}
.dark .materials-drawer {
  background: #0f172a;
  border-right: 1px solid #334155;
}
.materials-drawer.open {
  transform: translateX(0);
}
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Live Capacity Glow & Badges */
.capacity-pill {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(16, 185, 129, 0.12));
  border: 1px solid rgba(14, 165, 233, 0.3);
}
.dark .capacity-pill {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(16, 185, 129, 0.15));
  border-color: rgba(14, 165, 233, 0.4);
}

/* Schematic Duct Speed Indicators */
.duct-node-optimal {
  border-color: #10b981;
  background-color: rgba(16, 185, 129, 0.08);
}
.duct-node-warning {
  border-color: #f59e0b;
  background-color: rgba(245, 158, 11, 0.08);
}
.duct-node-danger {
  border-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.08);
}
.duct-critical-run {
  box-shadow: 0 0 0 2px #f97316;
}

/* Room Accordion & Quick-Jump Ergonomics */
.room-quick-pill {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.room-quick-pill:hover {
  transform: translateY(-1px);
}
.room-accordion-body {
  transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
}
.room-accordion-collapsed {
  display: none;
}

/* Print Mode Engine (Certified Submittal & BOQ Print Engine) */
@page {
  size: A4 portrait;
  margin: 12mm 10mm 15mm 10mm;
}

@media print {
  /* Hide non-printable navigation and modal controls */
  header, nav, .no-print, .wizard-nav, #materials-modal, #materials-drawer, .drawer-backdrop,
  #memo-modal, #memo-modal-backdrop, #guide-modal, #guide-modal-backdrop, .no-print * {
    display: none !important;
  }

  /* Reset document flow and colors for pure crisp monochrome output */
  html, body, .print-container, main {
    background: #ffffff !important;
    color: #0f172a !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    font-size: 11pt !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Neutralize dark-mode classes during print */
  .dark, .dark * {
    background-color: transparent !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
    box-shadow: none !important;
  }

  .glass-panel {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }

  /* Page-break avoidance rules to prevent table and section dissection */
  .print-break-avoid, tr, .submittal-section, .signature-block, .boq-category-block {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* Always repeat table headers on new pages */
  thead {
    display: table-header-group !important;
  }

  tr {
    page-break-inside: avoid !important;
  }

  /* Ensure tables use full width and clean borders */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 8.5pt !important;
  }

  th, td {
    border: 1px solid #e2e8f0 !important;
    padding: 4px 6px !important;
  }

  th {
    background-color: #f8fafc !important;
    color: #1e293b !important;
    font-weight: bold !important;
  }

  /* Page break before each major technical submittal section */
  .print-page-break {
    break-before: page !important;
    page-break-before: always !important;
  }
}
