/* ============================================
   ROOFCALC PRO — Calculator Component Styles
   ============================================ */

/* ---------- Calculator Layout ---------- */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-2xl);
  align-items: start;
}

.calc-main {
  min-width: 0;
}

.calc-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + var(--space-xl));
}

/* ---------- Calculator Form ---------- */
.calc-form {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.calc-form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(245,158,11,0.3) 50%, transparent 100%);
}

.calc-form-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.calc-form-header .form-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.calc-form-header h3 {
  font-size: 1.2rem;
}

.calc-form-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Form Groups ---------- */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  font-family: var(--font-heading);
}

.form-group label .label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

select.form-control option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Input with unit suffix */
.input-with-unit {
  position: relative;
}

.input-with-unit .form-control {
  padding-right: 3.5rem;
}

.input-with-unit .unit {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  pointer-events: none;
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: var(--space-sm) 0;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-check label {
  margin: 0;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Range slider */
.form-range {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-card);
  outline: none;
  appearance: none;
  cursor: pointer;
}

.form-range::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
}

.form-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---------- Results Panel ---------- */
.results-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-base);
}

.results-panel.has-results {
  border-color: rgba(20, 184, 166, 0.3);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.results-header h3 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.1rem;
}

.results-header .results-icon {
  font-size: 1.2rem;
}

/* Primary result */
.result-primary {
  text-align: center;
  padding: var(--space-xl) 0;
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.result-primary .result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.result-primary .result-value {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--success);
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.result-primary .result-range {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Result details grid */
.result-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.result-item {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.result-item .item-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.result-item .item-value {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.result-item .item-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Result breakdown table */
.result-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
}

.result-table th,
.result-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.result-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-table td {
  color: var(--text-primary);
}

.result-table td:last-child {
  text-align: right;
  font-weight: 600;
  font-family: var(--font-heading);
}

.result-table tr:last-child td {
  border-bottom: none;
  color: var(--success);
  font-weight: 700;
}

/* Cost breakdown bar */
.cost-bar {
  margin-bottom: var(--space-lg);
}

.cost-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: var(--space-xs);
}

.cost-bar-label span:first-child {
  color: var(--text-secondary);
}

.cost-bar-label span:last-child {
  color: var(--text-primary);
  font-weight: 600;
}

.cost-bar-track {
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}

.cost-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--gradient-accent);
}

.cost-bar-fill.success {
  background: var(--gradient-success);
}

/* Results placeholder */
.results-placeholder {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  color: var(--text-muted);
}

.results-placeholder .placeholder-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.results-placeholder p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Related Calculators ---------- */
.related-calcs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.related-calc-card {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
  text-decoration: none;
  display: block;
}

.related-calc-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.related-calc-card .calc-emoji {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.related-calc-card h4 {
  font-size: 0.95rem;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.related-calc-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Content Section ---------- */
.content-section {
  max-width: 800px;
}

.content-section h2 {
  font-size: 1.5rem;
  margin-bottom: var(--space-lg);
}

.content-section h3 {
  font-size: 1.15rem;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.content-section p {
  margin-bottom: var(--space-md);
  line-height: 1.8;
}

.content-section ul {
  padding-left: var(--space-xl);
  margin-bottom: var(--space-md);
}

.content-section ul li {
  position: relative;
  padding: var(--space-xs) 0;
  color: var(--text-secondary);
  list-style: none;
}

.content-section ul li::before {
  content: '▸';
  color: var(--accent);
  position: absolute;
  left: calc(var(--space-xl) * -1);
}

.formula-box {
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  overflow-x: auto;
}

/* ---------- Pitch Diagram ---------- */
.pitch-diagram {
  width: 100%;
  max-width: 300px;
  margin: var(--space-lg) auto;
  position: relative;
}

.pitch-diagram svg {
  width: 100%;
  height: auto;
}

/* ---------- Glossary ---------- */
.glossary-search {
  max-width: 500px;
  margin: 0 auto var(--space-2xl);
  position: relative;
}

.glossary-search .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.glossary-search .form-control {
  padding-left: 3rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.glossary-alpha-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-2xl);
}

.glossary-alpha-nav a {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.glossary-alpha-nav a:hover,
.glossary-alpha-nav a.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.glossary-letter {
  margin-bottom: var(--space-2xl);
}

.glossary-letter h3 {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border-accent);
  display: inline-block;
}

.glossary-term {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  transition: border-color var(--transition-fast);
}

.glossary-term:hover {
  border-color: var(--border-hover);
}

.glossary-term h4 {
  font-size: 1rem;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.glossary-term p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

.glossary-term .term-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Sidebar Widgets ---------- */
.sidebar-widget {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.sidebar-widget h4 {
  font-size: 0.95rem;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: color var(--transition-fast);
}

.sidebar-link:hover {
  color: var(--accent);
}

.sidebar-link .link-emoji {
  font-size: 1rem;
  width: 24px;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .calc-layout {
    grid-template-columns: 1fr;
  }

  .calc-sidebar {
    position: static;
  }

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

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .result-details {
    grid-template-columns: 1fr;
  }

  .related-calcs {
    grid-template-columns: 1fr;
  }

  .calc-form {
    padding: var(--space-lg);
  }

  .results-panel {
    padding: var(--space-lg);
  }

  .result-primary .result-value {
    font-size: 2rem;
  }
}
