/* HVAC Pro Toolkit - Modern Professional Styling */
/* TROOSTEN BUSINESS CORPORATION LLP */

:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --secondary: #0f172a;
  --accent: #06b6d4;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #6366f1;
  --info-light: #e0e7ff;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #38bdf8;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #0284c7;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-subtitle {
  font-size: 0.76rem;
  color: #94a3b8;
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-date-badge {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 0.78rem;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Top Navigation Tabs */
.nav-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  position: sticky;
  top: 56px;
  z-index: 40;
  box-shadow: var(--shadow-sm);
  scrollbar-width: thin;
}

.nav-bar::-webkit-scrollbar {
  height: 3px;
}
.nav-bar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 7px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-tab:hover {
  color: var(--primary);
  background-color: #f8fafc;
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background-color: #f0f9ff;
}

.tab-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 700;
  pointer-events: none;
}

.nav-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: -2px;
  pointer-events: none;
  flex-shrink: 0;
}

.tab-badge.badge-red { background: #fee2e2; color: #b91c1c; }
.tab-badge.badge-blue { background: #e0f2fe; color: #0369a1; }
.tab-badge.badge-amber { background: #fef3c7; color: #b45309; }
.tab-badge.badge-green { background: #d1fae5; color: #065f46; }

/* Main Content Area */
.main-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Section Titles */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
}

.kpi-card.kpi-blue::before { background: #0284c7; }
.kpi-card.kpi-emerald::before { background: #10b981; }
.kpi-card.kpi-amber::before { background: #f59e0b; }
.kpi-card.kpi-rose::before { background: #ef4444; }
.kpi-card.kpi-purple::before { background: #8b5cf6; }
.kpi-card.kpi-cyan::before { background: #06b6d4; }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-icon {
  font-size: 1.25rem;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--secondary);
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Cards & Content Panels */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
  gap: 22px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

/* Forms & Controls */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-control, .form-select, textarea.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-main);
  background-color: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.form-control:focus, .form-select:focus, textarea.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}
.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}
.btn-success:hover {
  background-color: #059669;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #dc2626;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.data-table th {
  background-color: #f8fafc;
  color: #475569;
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.data-table tbody tr.row-urgent {
  background-color: #fff1f2;
}

.data-table tbody tr.row-hidden {
  opacity: 0.45;
  background-color: #f1f5f9;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-green { background: #d1fae5; color: #065f46; }
.badge-blue { background: #e0f2fe; color: #075985; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-cyan { background: #cffafe; color: #155e75; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Sizing Calculator Box */
.calc-result-hero {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.calc-result-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.9;
  margin-bottom: 4px;
}

.calc-result-val {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 6px;
}

.calc-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.calc-metric-sub {
  font-size: 0.76rem;
  opacity: 0.85;
}

.calc-metric-num {
  font-size: 1.15rem;
  font-weight: 700;
}

/* Technician 7-Day Board Grid */
.tech-board {
  display: grid;
  grid-template-columns: 180px repeat(7, 1fr);
  gap: 1px;
  background-color: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tech-cell {
  background: #ffffff;
  padding: 10px 8px;
  font-size: 0.82rem;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.tech-cell-header {
  background: #f1f5f9;
  font-weight: 700;
  color: #334155;
  text-align: center;
  padding: 10px 4px;
  min-height: auto;
}

.tech-cell-name {
  font-weight: 600;
  color: #0f172a;
  align-items: flex-start;
  padding-left: 14px;
}

.tech-badge-count {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 8px;
  padding: 4px 10px;
  display: inline-block;
  margin-top: 4px;
}

.tech-cell.cell-busy {
  background: #f0fdf4;
}

/* Modal Dialog */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 820px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.25);
  border: 1px solid var(--border);
  animation: modalScale 0.2s ease-out;
}

.modal-dialog.modal-lg {
  max-width: 1040px;
}

.modal-dialog.modal-xl {
  max-width: 1180px;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--secondary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
}

.copy-bubble {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  color: #334155;
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* Printable Document Templates */
.printable-document {
  background: #ffffff;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  color: #0f172a;
  line-height: 1.5;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 18px;
  margin-bottom: 22px;
}

.doc-brand-name {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0284c7;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.doc-badge {
  background: #0f172a;
  color: #ffffff;
  padding: 6px 14px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
  display: inline-block;
}

.doc-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
  background: #f8fafc;
  padding: 16px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.doc-section-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 18px 0 10px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0f172a;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
}

.doc-table th {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  text-align: left;
}

.doc-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.doc-total-box {
  margin-left: auto;
  width: 340px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 24px;
}

.doc-total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.88rem;
}

.doc-total-row.grand-total {
  border-top: 2px solid #0f172a;
  margin-top: 6px;
  padding-top: 8px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0284c7;
}

.doc-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 14px;
}

.doc-sign-line {
  width: 240px;
  border-top: 1px dashed #64748b;
  text-align: center;
  padding-top: 6px;
  font-size: 0.82rem;
  color: #475569;
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.check-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.check-item strong {
  display: block;
  color: #334155;
  margin-bottom: 2px;
}

/* Page Break for Printable Proposal */
.print-page-break {
  page-break-after: always;
  break-after: page;
  margin-bottom: 30px;
  padding-bottom: 30px;
  border-bottom: 1px dashed #cbd5e1;
}

/* Print Specific Rules */
@media print {
  body {
    background: #ffffff;
    color: #000000;
  }
  .app-header, .nav-bar, .filter-bar, .btn, .no-print, .modal-header button, .modal-footer {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    background: none !important;
    padding: 0 !important;
  }
  .modal-dialog {
    max-width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .main-container {
    padding: 0 !important;
    max-width: 100% !important;
  }
  .printable-document {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
  .print-page-break {
    border-bottom: none !important;
    page-break-after: always !important;
    break-after: page !important;
  }
  .row-hidden {
    display: none !important;
  }
}

/* Dimmed row styling for hidden items in edit mode */
.dimmed-row {
  opacity: 0.55;
  background-color: #f8fafc !important;
}
.dimmed-row td {
  color: #94a3b8 !important;
}

/* Filter and Toggle Pills */
.col-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  user-select: none;
  transition: all 0.15s ease;
}
.col-pill:hover {
  border-color: #0284c7;
}
.col-pill.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

/* Sub tabs inside installation pane */
.sub-nav {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 20px;
  padding-bottom: 2px;
}
.sub-nav-btn {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -4px;
  border-radius: 4px 4px 0 0;
  transition: all 0.2s;
}
.sub-nav-btn:hover {
  color: #0284c7;
  background: #f0f9ff;
}
.sub-nav-btn.active {
  color: #0284c7;
  border-bottom-color: #0284c7;
  font-weight: 700;
  background: #e0f2fe;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-header {
    padding: 12px 16px;
  }
  .main-container {
    padding: 14px;
  }
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}
