/* ==========================================================================
   ARENCOS Construction & Energy Cost Estimator - Unified Master Stylesheet
   ========================================================================== */

/* 1. Global Reset & Main Outer Container */
.estimator-wrapper,
.estimator-wrapper * {
  box-sizing: border-box;
}

.estimator-wrapper {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 36px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
  overflow: hidden;
}

/* 2. Header & Title Badges */
.badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0284c7;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.estimator-header {
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 20px;
  margin-bottom: 28px;
}

.estimator-header h2 {
  margin: 4px 0 8px 0;
  font-size: 1.75rem;
  color: #0f172a;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.estimator-header p {
  margin: 0;
  color: #64748b;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* 3. Form Input Sections */
.calc-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  transition: border-color 0.2s ease;
}

.calc-section:hover {
  border-color: #cbd5e1;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.sec-num {
  background: #0f172a;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.calc-section h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #0f172a;
  font-weight: 600;
}

/* 4. Form Controls & Grid System */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.input-group {
  display: flex;
  flex-direction: column;
}

.input-group.full-width {
  grid-column: 1 / -1;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.input-group input, 
.input-group select {
  width: 100%;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  font-size: 0.95rem;
  color: #0f172a;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  text-overflow: ellipsis;
}

.input-group input:focus, 
.input-group select:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* 5. Results & Financial Breakdown Container (Dark Blue Panel) */
.results-container {
  margin-top: 32px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.3);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
  padding-bottom: 14px;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.results-header h3 {
  margin: 0;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 600;
}

.currency-tag {
  font-size: 0.75rem;
  background: #1e293b;
  color: #38bdf8;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  white-space: nowrap;
}

/* 6. Desktop Breakdown Table */
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
}

.breakdown-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #1e293b;
  font-size: 0.92rem;
  color: #cbd5e1;
}

.breakdown-table .text-right {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1rem;
  white-space: nowrap;
}

.breakdown-table tr.subtotal-row td {
  border-top: 2px solid #334155;
  border-bottom: 2px solid #334155;
  color: #ffffff;
  font-size: 1rem;
  padding: 12px 8px;
}

.breakdown-table tr.grand-total-row td {
  border-bottom: none;
  padding-top: 18px;
  color: #38bdf8;
  font-size: 1.35rem;
}

/* ==========================================================================
   Responsive Mobile Adjustments
   ========================================================================== */

/* Tablet View (< 640px) */
@media (max-width: 640px) {
  .estimator-wrapper {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .estimator-header h2 {
    font-size: 1.35rem;
  }

  .calc-section {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* Smartphone View & Dark Blue Panel Responsiveness (< 600px) */
@media (max-width: 600px) {
  .results-container {
    padding: 16px 12px;
    margin-top: 20px;
    border-radius: 8px;
    width: 100%;
    max-width: 100%;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* Structural transformation to stop horizontal scrolling */
  .breakdown-table, 
  .breakdown-table tbody, 
  .breakdown-table tr {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  .breakdown-table tr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #1e293b;
    width: 100%;
  }

  .breakdown-table tr.subtotal-row {
    margin-top: 8px;
    padding: 10px 0;
    border-top: 2px solid #334155;
    border-bottom: 2px solid #334155;
  }

  .breakdown-table tr.grand-total-row {
    padding-top: 12px;
    border-bottom: none;
  }

  .breakdown-table td {
    display: block;
    padding: 0;
    border: none;
    font-size: 0.85rem;
  }

  .breakdown-table td:first-child {
    padding-right: 12px;
    line-height: 1.3;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .breakdown-table .text-right {
    text-align: right;
    font-size: 0.95rem;
    flex-shrink: 0;
  }

  .breakdown-table tr.grand-total-row td {
    font-size: 1.1rem;
  }
}