/* ==========================================================================
   DESPIECES LLOPIS - INTERACTIVE MODULES CSS
   Calculator, Planilla CAD Viewer, and Mockup Customizer
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CALCULATOR MODULE (SIMULADOR DE AHORRO Y MERMAS)
   -------------------------------------------------------------------------- */
.calculator-card {
  background: linear-gradient(135deg, rgba(20, 27, 39, 0.95) 0%, rgba(13, 18, 28, 0.98) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-xl);
  padding: clamp(1.5rem, 4vw, 3rem);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(245, 158, 11, 0.08);
  position: relative;
  overflow: hidden;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--space-2xl);
  align-items: center;
}

.calc-controls {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.calc-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.calc-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calc-val-display {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary-light);
  background: rgba(245, 158, 11, 0.12);
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* Range Slider */
.calc-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #1e293b;
  outline: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.calc-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
  border: 2px solid #ffffff;
  transition: transform var(--transition-fast);
}

.calc-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Structure Type Selector Radio Pills */
.structure-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.pill-option {
  position: relative;
}

.pill-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pill-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.75rem 0.5rem;
  background: var(--bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pill-option input[type="radio"]:checked + .pill-label {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--color-primary);
  color: var(--text-main);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.pill-icon {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

/* Results Display Box */
.calc-results-panel {
  background: rgba(10, 14, 23, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
}

.calc-results-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-secondary-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.comparison-bars {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comp-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.comp-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.comp-bar-val {
  font-family: var(--font-mono);
  font-weight: 700;
}

.comp-track {
  width: 100%;
  height: 10px;
  background: #1e293b;
  border-radius: 5px;
  overflow: hidden;
}

.comp-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.comp-fill.red {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.comp-fill.green {
  background: linear-gradient(90deg, #10b981, #34d399);
}

/* Big Savings Highlights */
.savings-highlight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-glass-border);
}

.savings-card {
  background: rgba(18, 25, 38, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.savings-num {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--color-primary-light);
  line-height: 1.1;
}

.savings-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   2. INTERACTIVE PLANILLA DE DESPIECE VIEWER
   -------------------------------------------------------------------------- */
.planilla-viewer {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.planilla-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(10, 14, 23, 0.95);
  border-bottom: 1px solid var(--bg-glass-border);
  flex-wrap: wrap;
  gap: 1rem;
}

.element-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.element-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.element-tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.element-tab-btn.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--color-primary);
  color: var(--color-primary-light);
}

.view-mode-toggle {
  display: flex;
  background: #0f172a;
  border-radius: var(--radius-sm);
  padding: 0.2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.view-toggle-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.view-toggle-btn.active {
  background: var(--color-secondary);
  color: #ffffff;
}

/* Planilla Main Content Grid */
.planilla-content-grid {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  min-height: 440px;
}

.rebar-drawing-pane {
  background: radial-gradient(circle at center, #0f172a 0%, #070a10 100%);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--bg-glass-border);
  position: relative;
}

.drawing-watermark {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: rgba(56, 189, 248, 0.4);
}

.rebar-svg-stage {
  width: 100%;
  max-width: 380px;
  height: 240px;
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.25));
}

.shape-legend {
  margin-top: 1.5rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Planilla Table Pane */
.rebar-table-pane {
  padding: 1.5rem;
  overflow-x: auto;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}

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

.planilla-table th {
  background: rgba(13, 18, 28, 0.8);
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--bg-glass-border);
  font-family: var(--font-mono);
}

.planilla-table td {
  padding: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.planilla-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
}

.planilla-table .pos-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-primary);
  font-weight: 700;
}

.table-summary-bar {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 2px solid var(--bg-glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
}

.total-weight-box {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.total-weight-box .label {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.total-weight-box .val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-primary-light);
}

/* BVBS CNC Code View Pane */
.bvbs-code-pane {
  display: none;
  background: #06090e;
  padding: 2rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #38bdf8;
  line-height: 1.7;
  overflow-x: auto;
  border-top: 1px solid var(--bg-glass-border);
}

.bvbs-code-pane.active {
  display: block;
}

.bvbs-line-num {
  color: #475569;
  user-select: none;
  margin-right: 1.5rem;
}


/* Responsive adjustments for interactive modules */
@media (max-width: 900px) {
  .calc-grid,
  .planilla-content-grid {
    grid-template-columns: 1fr;
  }

  .rebar-drawing-pane {
    border-right: none;
    border-bottom: 1px solid var(--bg-glass-border);
  }

  .structure-pills {
    grid-template-columns: repeat(2, 1fr);
  }
}
