/* ── Albums / CD / DVD Calculator ─────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; margin: 0; }

:root {
  --forest:      #1c3010;
  --forest-mid:  #2a6a1a;
  --forest-light:#e8f0e4;
  --border:      #d0dcc8;
  --border-light:#e8eee4;
  --text:        #1a2a1a;
  --text-mid:    #4a6a4a;
  --text-muted:  #7a8a7a;
  --bg:          #f2f4f0;
  --white:       #ffffff;
  --error:       #dc2626;
  --error-bg:    #fef2f2;
  --success:     #16a34a;
  --highlight:   #fefce8;
  --accent:      #4a2a8a;
  --accent-light:#f0ecf8;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  line-height: 1.5;
}

/* ═══ LAYOUT ═════════════════════════════════════════════ */
.calc-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.calc-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: row; overflow: hidden;
  max-width: 1400px; margin: 0 auto; width: 100%;
}

/* ═══ SIDEBAR / FORM ════════════════════════════════════ */
.calc-sidebar {
  width: 370px; flex-shrink: 0; min-height: 0;
  background: var(--white);
  border-right: 2px solid var(--border);
  overflow-y: scroll;
  scrollbar-width: thin;
  scrollbar-color: var(--border) #f0f2f0;
}
.sidebar-scroll { padding: 1rem 1rem 0; }

.sidebar-section {
  background: var(--forest-light);
  border-radius: 8px;
  padding: .7rem .85rem .85rem;
  margin-bottom: .5rem;
  border: 1px solid var(--border);
}
.section-eyebrow {
  font-size: .62rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--forest-mid); margin-bottom: .55rem;
}

.field { margin-bottom: .55rem; }
.field-label {
  display: block; font-size: .78rem; font-weight: 600;
  color: #2a4a2a; margin-bottom: .2rem; line-height: 1.3;
}
.field-row { display: flex; gap: .5rem; align-items: flex-end; }
.field-row .field { flex: 1; min-width: 0; }

.form-input {
  width: 100%; padding: .42rem .65rem;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-size: .87rem; background: var(--white); color: var(--text);
  transition: border-color .12s, background .12s, box-shadow .12s;
  -moz-appearance: textfield;
}
.form-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.form-input:focus {
  outline: none; border-color: var(--forest-mid);
  box-shadow: 0 0 0 3px rgba(42,106,26,.12);
}

/* Checkbox */
.checkbox-label {
  display: flex; align-items: center; gap: .45rem; cursor: pointer;
  font-size: .78rem; font-weight: 600; color: #2a4a2a;
  padding-top: 1.5rem;
}
.form-checkbox {
  width: 15px; height: 15px;
  accent-color: var(--forest-mid); flex-shrink: 0; cursor: pointer;
}

/* Disc add/remove rows */
.disc-row { margin-bottom: .4rem; }
.disc-remove-btn {
  background: none; border: none; color: #dc2626;
  font-size: .9rem; cursor: pointer; padding: .3rem;
}
.add-row-btn {
  display: inline-block; padding: .3rem .75rem;
  background: transparent; border: 1.5px dashed var(--border);
  border-radius: 6px; font-size: .78rem; font-weight: 600;
  color: var(--forest-mid); cursor: pointer;
  transition: background .12s, border-color .12s;
}
.add-row-btn:hover { background: #e0f0d8; border-color: var(--forest-mid); }

/* Additional items grid */
.extras-grid { display: flex; flex-direction: column; gap: .3rem; }
.extra-item-label {
  display: flex; align-items: center; gap: .5rem;
  font-size: .82rem; cursor: pointer; padding: .25rem 0;
}
.extra-item-name { font-weight: 600; color: var(--text); }
.extra-item-price { font-size: .72rem; color: var(--text-muted); margin-left: auto; }

/* Sticky footer */
.sidebar-footer {
  position: sticky; bottom: 0; z-index: 5;
  padding: .75rem 1rem;
  border-top: 2px solid var(--border-light);
  background: var(--white);
}
.sidebar-footer .field { margin-bottom: .5rem; }
.sidebar-footer .field-label { font-size: .75rem; }

.calc-btn {
  width: 100%; padding: .72rem;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-size: .95rem; font-weight: 700; cursor: pointer;
  transition: background .15s, transform .1s; letter-spacing: .02em;
}
.calc-btn:hover  { background: #3a1a6a; }
.calc-btn:active { transform: translateY(1px); }
.calc-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ═══ RESULTS PANEL ════════════════════════════════════ */
.calc-results {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 1.25rem 1.5rem 2rem;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

.results-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 300px; color: var(--text-muted); text-align: center;
}
.results-placeholder p { font-size: .95rem; margin: 0; }
.results-placeholder-icon { font-size: 3rem; margin-bottom: .75rem; opacity: .3; }

.results-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 200px; gap: .75rem;
  color: var(--text-muted); font-size: .9rem;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results-error {
  background: var(--error-bg);
  border: 2px solid #fca5a5; border-radius: 10px;
  padding: 1rem 1.25rem; color: #991b1b;
  font-size: .88rem; line-height: 1.6;
  display: none; margin-bottom: 1rem;
  white-space: pre-wrap; word-break: break-word;
}

/* Quote summary strip */
.result-summary {
  background: var(--accent);
  color: #fff; border-radius: 10px;
  padding: .7rem 1rem; margin-bottom: 1.25rem;
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem;
}
.quote-code-badge {
  font-family: 'SF Mono', 'Fira Mono', 'Consolas', monospace;
  font-size: 1rem; font-weight: 700; letter-spacing: .02em;
  padding: .3rem .7rem; background: rgba(255,255,255,.12);
  border-radius: 6px;
}
.quote-chip {
  font-size: .75rem; padding: .2rem .55rem;
  border-radius: 4px; background: rgba(255,255,255,.15);
}

/* Quote code box */
.quote-code-box {
  display: none; margin-bottom: 1rem;
  padding: .5rem .75rem;
  background: var(--accent-light);
  border: 1.5px solid #d0c8e4;
  border-radius: 8px;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: .85rem; color: var(--accent);
}

/* Section titles */
.result-section-title {
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-mid);
  margin: 1.1rem 0 .65rem; padding-bottom: .3rem;
  border-bottom: 1.5px solid var(--border-light);
}

/* Component breakdown table */
.component-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: .83rem;
  border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden;
}
.component-table thead th {
  background: #edf2ea; font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-mid);
  padding: .5rem .7rem; border-bottom: 2px solid var(--border); text-align: left;
}
.component-table thead th.num { text-align: right; }
.component-table tbody td {
  padding: .4rem .7rem; border-bottom: 1px solid var(--border-light);
  font-variant-numeric: tabular-nums;
}
.component-table tbody tr:last-child td { border-bottom: none; }
.component-table tbody tr:nth-child(even) td { background: #fafbf8; }
.component-table td.num { text-align: right; }
.component-table tfoot td {
  padding: .55rem .7rem; background: var(--forest-light);
  border-top: 2px solid var(--border); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.component-table tfoot td.num { text-align: right; }

/* Price table */
.price-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: .84rem;
  border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden;
}
.price-table thead { background: #edf2ea; }
.price-table th {
  font-size: .67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mid); padding: .55rem .7rem;
  text-align: left; border-bottom: 2px solid var(--border); white-space: nowrap;
}
.price-table th.num, .price-table td.num { text-align: right; }
.price-table td {
  padding: .45rem .7rem; border-bottom: 1px solid var(--border-light);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.price-table tr:last-child td { border-bottom: none; }
.price-table tbody tr:nth-child(even) td { background: #fafbf8; }
.price-table tbody tr:hover td { background: #f0f5ee; }
.price-table tr.highlighted td { background: var(--highlight) !important; }
.price-table tr.highlighted td:first-child {
  border-left: 3px solid #ca8a04;
  padding-left: calc(.7rem - 3px);
}
.price-table th.total, .price-table td.total {
  color: #14532d; font-weight: 700; background: #f0fdf4;
}
.price-table tr:hover td.total,
.price-table tr.highlighted td.total { background: #dcfce7 !important; }

.price-table th.total-top,
.price-table td.total-top { color: #1e3a5f; }
.price-table th.profit-top,
.price-table td.profit-top { color: #1e3a5f; }

.price-table th.total-ip,
.price-table td.total-ip { color: #5b21b6; }
.price-table th.profit-ip,
.price-table td.profit-ip { color: #5b21b6; }

.price-table td.muted { color: var(--text-muted); font-size: .8rem; }

.cost-only-table { margin-bottom: 1rem; }

.ref-tag {
  display: inline-block; margin-left: .35rem;
  font-size: .62rem; font-weight: 700;
  background: #ca8a04; color: #fff;
  padding: .1rem .4rem; border-radius: 3px;
  vertical-align: middle;
}

/* Copy rows */
.copy-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .55rem; }
.copy-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-mid);
  min-width: 60px; flex-shrink: 0;
}
.copy-box { display: flex; gap: .4rem; flex: 1; }
.copy-box input {
  flex: 1; font-family: 'SF Mono','Fira Mono',monospace; font-size: .75rem;
  padding: .38rem .6rem;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: #f8fbf6; color: var(--text);
}
.copy-btn {
  flex-shrink: 0; padding: .38rem .7rem;
  background: var(--forest-light); border: 1.5px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: .77rem; font-weight: 600;
  color: var(--text-mid); transition: background .12s, color .12s;
}
.copy-btn:hover  { background: #d0e8c0; color: var(--forest); }
.copy-btn.copied { background: #dcfce7; color: var(--success); border-color: #bbf7d0; }

/* Description boxes */
.desc-box { display: flex; gap: .5rem; align-items: flex-start; }
.desc-box textarea {
  flex: 1;
  font-family: 'SF Mono','Fira Mono',monospace;
  font-size: .8rem; line-height: 1.6;
  padding: .5rem .7rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: #f8fbf6; color: var(--text);
  resize: vertical;
}
.desc-box .copy-btn { align-self: flex-start; margin-top: .1rem; }

/* Footer total row in component table */
.component-table tfoot .total-row td { background: #fef5e8; }

/* Nav divider in admin header */
.nav-divider {
  color: rgba(255,255,255,.2);
  margin: 0 .2rem;
}

@media (max-width: 860px) {
  .calc-page    { height: auto; overflow: visible; }
  .calc-body    { flex-direction: column; overflow: visible; }
  .calc-sidebar { width: 100%; overflow-y: visible; border-right: none; border-bottom: 2px solid var(--border); }
  .sidebar-footer { position: static; }
  .calc-results { overflow: visible; min-height: unset; }
}
