/* ============================================================
   RAMME-BEREGNER — Stylesheet
   ============================================================ */

/* Reset & base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f4f0;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: #1a1a1a;
  color: #f5f4f0;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 17px;
  font-weight: 500;
}

.header-tabs {
  display: flex;
  gap: 4px;
}

.tab-btn {
  height: 30px;
  padding: 0 14px;
  border: 1px solid #444;
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
}

.tab-btn.active {
  background: #fff;
  color: #1a1a1a;
  border-color: #fff;
}

.tab-btn:hover:not(.active) {
  border-color: #777;
  color: #eee;
}

/* ── Views ── */
.view {
  display: none;
}

.view.active {
  display: flex;
}

/* ── Calculator layout ── */
#view-calc {
  min-height: calc(100vh - 52px);
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  width: 100%;
}

/* ── Sidebar ── */
.sidebar {
  background: #fff;
  border-right: 1px solid #e8e6e0;
  padding: 1.5rem;
  overflow-y: auto;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #888;
  text-transform: uppercase;
  margin-bottom: 10px;
  margin-top: 1.25rem;
}

.section-label:first-child {
  margin-top: 0;
}

/* ── Unit buttons ── */
.unit-row {
  display: flex;
  gap: 6px;
  margin-bottom: 1.25rem;
}

.unit-btn {
  flex: 1;
  height: 30px;
  border: 1px solid #d8d6d0;
  border-radius: 6px;
  background: transparent;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
}

.unit-btn.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

/* ── Cards ── */
.card {
  background: #faf9f7;
  border: 1px solid #e8e6e0;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

/* ── Form fields ── */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.field label {
  font-size: 12px;
  color: #888;
}

.field input[type="number"],
.field input[type="text"] {
  height: 36px;
  border: 1px solid #d8d6d0;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 15px;
  background: #fff;
  color: #1a1a1a;
  width: 100%;
  transition: border-color 0.12s;
}

.field input:focus {
  outline: none;
  border-color: #1a1a1a;
}

.field input::placeholder {
  color: #bbb;
}

.hint {
  font-size: 11px;
  color: #aaa;
  margin-top: 8px;
  line-height: 1.5;
}

.warning {
  font-size: 12px;
  color: #c0392b;
  margin-top: 8px;
  display: none;
}

/* ── Toggle switch ── */
.sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  inset: 0;
  background: #d8d6d0;
  border-radius: 18px;
  cursor: pointer;
  transition: 0.2s;
}

.slider-toggle::before {
  content: '';
  position: absolute;
  height: 12px;
  width: 12px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + .slider-toggle {
  background: #1a1a1a;
}

.toggle input:checked + .slider-toggle::before {
  transform: translateX(14px);
}

/* ── Save area ── */
.save-area {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e8e6e0;
}

.save-name-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.save-name-row input {
  flex: 1;
  height: 36px;
  border: 1px solid #d8d6d0;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 14px;
  background: #fff;
  color: #1a1a1a;
}

.save-name-row input:focus {
  outline: none;
  border-color: #1a1a1a;
}

.save-feedback {
  font-size: 12px;
  color: #4a9c6d;
  min-height: 18px;
}

/* ── Buttons ── */
.btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid #d8d6d0;
  background: #fff;
  color: #1a1a1a;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn:hover {
  background: #f5f4f0;
}

.btn.primary {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

.btn.primary:hover {
  background: #333;
}

.btn.danger {
  color: #c0392b;
  border-color: #eecdc8;
}

.btn.danger:hover {
  background: #fdf0ee;
}

/* ── Main results area ── */
.main {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.results-section {
  background: #fff;
  border: 1px solid #e8e6e0;
  border-radius: 12px;
  padding: 1.25rem;
}

.results-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #888;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.metric {
  background: #f5f4f0;
  border-radius: 8px;
  padding: 0.875rem 1rem;
}

.metric .m-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
}

.metric .m-value {
  font-size: 20px;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1.1;
}

.metric .m-sub {
  font-size: 11px;
  color: #aaa;
  margin-top: 3px;
}

/* ── Cut list table ── */
.cut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 0.5rem;
}

.cut-table th {
  text-align: left;
  font-weight: 500;
  color: #888;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid #e8e6e0;
}

.cut-table td {
  padding: 10px 8px 10px 0;
  border-bottom: 1px solid #f0eeea;
  color: #444;
  vertical-align: middle;
}

.cut-table tr:last-child td {
  border-bottom: none;
}

.piece-wrap {
  margin: 6px 0 2px;
}

.total-box {
  background: #f5f4f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.total-box .t-label {
  font-size: 12px;
  color: #888;
}

.total-box .t-value {
  font-size: 15px;
  font-weight: 500;
  color: #1a1a1a;
}

.diagram-wrap {
  background: #fff;
  border: 1px solid #e8e6e0;
  border-radius: 12px;
  padding: 1.25rem;
}

.empty {
  text-align: center;
  padding: 3rem 2rem;
  color: #aaa;
  font-size: 14px;
  background: #fff;
  border: 1px solid #e8e6e0;
  border-radius: 12px;
  line-height: 2;
}

/* ── Archive view ── */
#view-archive {
  flex-direction: column;
  padding: 1.5rem;
  background: #f5f4f0;
  min-height: calc(100vh - 52px);
}

.archive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.archive-header h2 {
  font-size: 16px;
  font-weight: 500;
}

.archive-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: #aaa;
  font-size: 14px;
  background: #fff;
  border: 1px solid #e8e6e0;
  border-radius: 12px;
  line-height: 2;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.archive-card {
  background: #fff;
  border: 1px solid #e8e6e0;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  transition: border-color 0.12s;
}

.archive-card:hover {
  border-color: #bbb;
}

.archive-card .ac-name {
  font-size: 15px;
  font-weight: 500;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.archive-card .ac-details {
  font-size: 12px;
  color: #666;
  line-height: 1.7;
}

.archive-card .ac-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f0eeea;
}

.ac-badge {
  display: inline-block;
  font-size: 10px;
  background: #f0eeea;
  color: #888;
  border-radius: 4px;
  padding: 2px 7px;
  margin-bottom: 8px;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid #e8e6e0;
  }
}

/* ── Sprogskifter ── */
.lang-row {
  display: flex;
  gap: 4px;
}

.lang-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid #444;
  border-radius: 5px;
  background: transparent;
  color: #aaa;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  letter-spacing: 0.03em;
}

.lang-btn.active {
  background: #fff;
  color: #1a1a1a;
  border-color: #fff;
}

.lang-btn:hover:not(.active) {
  border-color: #777;
  color: #eee;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
