/* ============================================
   Estimation & Costing — Page-Specific Styles
   ============================================ */

/* ---------- Unit Color Variables ---------- */
:root {
  --unit1: #facc15;
  --unit2: #00f5ff;
  --unit3: #f97316;
  --unit4: #00ff88;
  --unit5: #a78bfa;
  --unit6: #fb7185;
  --unit7: #60a5fa;
  --est-bg-dark: #0d1117;
  --est-bg-card: #111827;
  --est-border: rgba(255, 255, 255, 0.06);
}

/* ---------- Layout: Sidebar + Main ---------- */
.est-layout {
  display: flex;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

.est-sidebar {
  position: sticky;
  top: calc(var(--nav-height, 64px) + 50px);
  width: 240px;
  min-width: 240px;
  height: calc(100vh - var(--nav-height, 64px) - 50px);
  overflow-y: auto;
  padding: 20px 16px 20px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.est-sidebar::-webkit-scrollbar {
  width: 4px;
}

.est-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.est-sidebar h4 {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 0.65rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted, #555);
  margin: 20px 0 8px;
  padding-left: 8px;
}

.est-sidebar h4:first-child {
  margin-top: 0;
}

.est-sidebar a {
  display: block;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--text-secondary, #8892b0);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.est-sidebar a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
  border-left-color: var(--neon-cyan, #00f5ff);
}

.est-sidebar a.active-link {
  color: var(--neon-cyan, #00f5ff);
  border-left-color: var(--neon-cyan, #00f5ff);
  background: rgba(0, 245, 255, 0.06);
}

.est-main {
  flex: 1;
  min-width: 0;
  padding: 24px 0 60px 24px;
}

/* ---------- Unit Section ---------- */
.unit-section {
  margin-bottom: 60px;
  scroll-margin-top: 130px;
}

.unit-header {
  position: relative;
  padding: 32px;
  margin-bottom: 32px;
  border-radius: 16px;
  background: var(--est-bg-card);
  border: 1px solid var(--est-border);
  overflow: hidden;
}

.unit-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.unit-section[data-unit="1"] .unit-header::before {
  background: var(--unit1);
}

.unit-section[data-unit="2"] .unit-header::before {
  background: var(--unit2);
}

.unit-section[data-unit="3"] .unit-header::before {
  background: var(--unit3);
}

.unit-section[data-unit="4"] .unit-header::before {
  background: var(--unit4);
}

.unit-section[data-unit="5"] .unit-header::before {
  background: var(--unit5);
}

.unit-section[data-unit="6"] .unit-header::before {
  background: var(--unit6);
}

.unit-section[data-unit="7"] .unit-header::before {
  background: var(--unit7);
}

.unit-header h2 {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 1.6rem;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.unit-section[data-unit="1"] .unit-header h2 {
  color: var(--unit1);
}

.unit-section[data-unit="2"] .unit-header h2 {
  color: var(--unit2);
}

.unit-section[data-unit="3"] .unit-header h2 {
  color: var(--unit3);
}

.unit-section[data-unit="4"] .unit-header h2 {
  color: var(--unit4);
}

.unit-section[data-unit="5"] .unit-header h2 {
  color: var(--unit5);
}

.unit-section[data-unit="6"] .unit-header h2 {
  color: var(--unit6);
}

.unit-section[data-unit="7"] .unit-header h2 {
  color: var(--unit7);
}

.unit-header p {
  color: var(--text-secondary, #8892b0);
  font-size: 0.95rem;
  max-width: 600px;
}

/* ---------- Formula Cards (Estimation) ---------- */
.est-card {
  background: var(--est-bg-card);
  border: 1px solid var(--est-border);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  scroll-margin-top: 130px;
}

.est-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.est-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.unit-section[data-unit="1"] .est-card::before {
  background: var(--unit1);
}

.unit-section[data-unit="2"] .est-card::before {
  background: var(--unit2);
}

.unit-section[data-unit="3"] .est-card::before {
  background: var(--unit3);
}

.unit-section[data-unit="4"] .est-card::before {
  background: var(--unit4);
}

.unit-section[data-unit="5"] .est-card::before {
  background: var(--unit5);
}

.unit-section[data-unit="6"] .est-card::before {
  background: var(--unit6);
}

.unit-section[data-unit="7"] .est-card::before {
  background: var(--unit7);
}

.est-card__title {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 1rem;
  letter-spacing: 1px;
  margin-bottom: 16px;
  color: var(--text-primary, #e6f1ff);
}

.est-card__subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary, #8892b0);
  margin: 16px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---------- Formula Display Blocks ---------- */
.formula-block {
  background: var(--est-bg-dark);
  border: 1px solid var(--est-border);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 12px 0;
  text-align: center;
  overflow-x: auto;
}

.formula-block .katex {
  font-size: 1.1rem;
}

.formula-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
}

.formula-row .formula-block {
  flex: 1;
  min-width: 250px;
}

.formula-label {
  font-size: 0.75rem;
  color: var(--text-muted, #555);
  margin-bottom: 6px;
  font-weight: 500;
}

.formula-desc {
  font-size: 0.85rem;
  color: var(--text-secondary, #8892b0);
  margin: 6px 0 0;
  line-height: 1.5;
}

.where-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.where-list li {
  font-size: 0.85rem;
  color: var(--text-secondary, #8892b0);
  padding: 3px 0;
  padding-left: 16px;
  position: relative;
}

.where-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--neon-cyan, #00f5ff);
}

/* ---------- BOQ Tables ---------- */
.boq-table-wrapper {
  overflow-x: auto;
  margin: 16px 0;
  border-radius: 10px;
  border: 1px solid var(--est-border);
}

.boq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 600px;
}

.boq-table thead {
  background: rgba(255, 255, 255, 0.04);
}

.boq-table th {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted, #555);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--est-border);
}

.boq-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--est-border);
  color: var(--text-secondary, #8892b0);
  vertical-align: middle;
}

.boq-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary, #e6f1ff);
}

.boq-table tfoot td {
  font-weight: 700;
  color: var(--neon-cyan, #00f5ff);
  border-top: 2px solid var(--neon-cyan, #00f5ff);
}

/* Neon-accented BOQ number inputs */
.boq-table input[type="number"] {
  width: 80px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--est-border);
  border-radius: 4px;
  color: var(--text-primary, #e6f1ff);
  font-size: 0.8rem;
  text-align: right;
}

.boq-table input[type="number"]:focus {
  outline: none;
  border-color: var(--neon-cyan, #00f5ff);
  box-shadow: 0 0 6px rgba(0, 245, 255, 0.2);
}

/* ---------- Interactive Calculator Panels ---------- */
.calc-panel {
  background: var(--est-bg-card);
  border: 1px solid var(--est-border);
  border-radius: 12px;
  padding: 24px;
  margin: 20px 0;
  position: relative;
  overflow: hidden;
}

.calc-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--neon-cyan, #00f5ff), var(--unit1));
}

.calc-panel__title {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: var(--neon-cyan, #00f5ff);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.calc-panel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calc-field label {
  font-size: 0.75rem;
  color: var(--text-muted, #555);
  font-weight: 500;
}

.calc-field input,
.calc-field select {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--est-border);
  border-radius: 6px;
  color: var(--text-primary, #e6f1ff);
  font-size: 0.85rem;
  font-family: var(--font-body, 'Inter', sans-serif);
  transition: border-color 0.3s ease;
}

.calc-field input:focus,
.calc-field select:focus {
  outline: none;
  border-color: var(--neon-cyan, #00f5ff);
  box-shadow: 0 0 8px rgba(0, 245, 255, 0.15);
}

.calc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: linear-gradient(135deg, rgba(0, 245, 255, 0.15), rgba(0, 245, 255, 0.05));
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: 8px;
  color: var(--neon-cyan, #00f5ff);
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 0.75rem;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.calc-btn:hover {
  background: rgba(0, 245, 255, 0.2);
  box-shadow: 0 0 16px rgba(0, 245, 255, 0.2);
  transform: translateY(-1px);
}

.calc-result {
  margin-top: 16px;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--est-border);
  border-radius: 8px;
  min-height: 50px;
}

.calc-result__label {
  font-size: 0.75rem;
  color: var(--text-muted, #555);
  margin-bottom: 4px;
}

.calc-result__value {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 1.4rem;
  color: var(--neon-cyan, #00f5ff);
  text-shadow: 0 0 10px rgba(0, 245, 255, 0.3);
}

.calc-result__breakdown {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary, #8892b0);
  line-height: 1.8;
}

/* ---------- SVG Animation Containers ---------- */
.svg-container {
  width: 100%;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--est-bg-dark);
  border: 1px solid var(--est-border);
  border-radius: 10px;
  margin: 16px 0;
  overflow: hidden;
  position: relative;
}

.svg-container svg {
  max-width: 100%;
  height: auto;
}

/* ---------- Chart Containers ---------- */
.chart-container {
  width: 100%;
  max-width: 500px;
  margin: 16px auto;
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
}

/* ---------- Info Glossary Cards ---------- */
.info-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.info-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--est-border);
  border-radius: 10px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.info-card:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.info-card__term {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 0.8rem;
  letter-spacing: 1px;
  color: var(--unit1);
  margin-bottom: 8px;
}

.info-card__def {
  font-size: 0.85rem;
  color: var(--text-secondary, #8892b0);
  line-height: 1.5;
}

.info-card__formula {
  margin-top: 10px;
  padding: 10px;
  background: var(--est-bg-dark);
  border-radius: 6px;
  text-align: center;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.4s ease;
}

.info-card.expanded .info-card__formula {
  max-height: 200px;
  padding: 12px;
}

/* ---------- Tender Checklist ---------- */
.tender-checklist {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  counter-reset: tender;
}

.tender-checklist li {
  counter-increment: tender;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--est-border);
  color: var(--text-secondary, #8892b0);
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.tender-checklist li::before {
  content: counter(tender);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(0, 245, 255, 0.1);
  border: 1px solid rgba(0, 245, 255, 0.2);
  border-radius: 50%;
  color: var(--neon-cyan, #00f5ff);
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

.tender-checklist li:hover {
  color: var(--text-primary, #e6f1ff);
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- Maintenance Interval Table ---------- */
.maint-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.8rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--est-border);
}

.maint-table th {
  padding: 10px 12px;
  background: rgba(251, 113, 133, 0.1);
  color: var(--unit6);
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 0.65rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: left;
  border-bottom: 1px solid var(--est-border);
}

.maint-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--est-border);
  color: var(--text-secondary, #8892b0);
}

.maint-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- Step-by-step Problem Solver ---------- */
.problem-block {
  background: var(--est-bg-card);
  border: 1px solid var(--est-border);
  border-radius: 12px;
  padding: 28px;
  margin: 20px 0;
}

.problem-block__title {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 0.9rem;
  color: var(--unit7);
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.problem-block__given {
  background: rgba(96, 165, 250, 0.06);
  border-left: 3px solid var(--unit7);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
  font-size: 0.85rem;
  color: var(--text-secondary, #8892b0);
  line-height: 1.7;
}

.step {
  margin: 16px 0;
  padding-left: 16px;
  border-left: 2px solid var(--est-border);
}

.step__label {
  font-family: var(--font-head, 'Orbitron', sans-serif);
  font-size: 0.75rem;
  color: var(--unit7);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* ---------- Card Footer Actions ---------- */
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--est-border);
}

.card-actions button {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--est-border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary, #8892b0);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-actions button:hover {
  border-color: var(--neon-cyan, #00f5ff);
  color: var(--neon-cyan, #00f5ff);
  background: rgba(0, 245, 255, 0.05);
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .est-sidebar {
    width: 200px;
    min-width: 200px;
  }
}

@media (max-width: 900px) {
  .est-sidebar {
    display: none;
  }

  .est-main {
    padding-left: 0;
  }

  .calc-panel__grid {
    grid-template-columns: 1fr;
  }

  .info-cards {
    grid-template-columns: 1fr;
  }

  .formula-row {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .est-card {
    padding: 16px;
  }

  .unit-header {
    padding: 20px;
  }

  .unit-header h2 {
    font-size: 1.1rem;
  }

  .boq-table {
    font-size: 0.75rem;
  }
}