/* style.css — shared styling for index/confirm/result + sidebar layout + icons */

:root {
  --bg: #f4f4f9;
  --text: #333;
  --card-bg: #fff;
  --border: #ddd;
  --primary: #007bff;
  --primary-dark: #0056b3;
  --muted: #6c757d;
  --success: #28a745;
  --danger: #dc3545;
  --danger-dark: #b02a37;

  /* Sidebar */
  --sidebar-bg: #f7f8fc;
  --sidebar-text: #1f2937;
  --sidebar-width: 260px;
  --sidebar-border: #e3e6ef;
}

/* Page */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;

  /* Default pages (no sidebar): keep your centered 600px layout */
  padding: 2em;
  max-width: 600px;
  margin: auto;

  background-color: var(--bg);
  color: var(--text);
}

/* ===== Layout: sidebar + content ===== */
/* When sidebar is present, add class="has-sidebar" on body */
body.has-sidebar {
  margin: 0;
  max-width: none;
  padding: 3rem 2.5rem 3rem;
  padding-left: calc(2.5rem + var(--sidebar-width));
}

/* Optional: wrap your main content in <main class="main"> ... </main> */
.main {
  max-width: 600px;
  margin: 0 auto;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;

  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);

  border-right: 1px solid var(--sidebar-border);
  box-shadow: 2px 0 10px rgba(0,0,0,0.06);
  z-index: 1000;

  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.05em;
  color: var(--sidebar-text);
}

/* Secondary sidebar header */
.sidebar-header.secondary {
  background: transparent;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-section-title {
  font-size: 1.3em;
  letter-spacing: 0.05em;
  color: var(--success);
  font-weight: 700;
}

.sidebar-section-subtitle {
  font-size: 0.9em;
  color: var(--sidebar-text);
  opacity: 0.8;
  margin-top: 4px;
}

.sidebar-section-header {
  padding: 14px 16px 6px 16px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a93a2;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0; /* no padding so items touch */
  /*
  flex: 1;
  */

  display: flex;
  flex-direction: column;
}

.sidebar-nav li { margin: 0; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;

  width: 100%;
  height: 48px; /* uniform row height */
  padding: 0 16px;

  border-radius: 0;
  text-decoration: none;
  color: var(--sidebar-text);

  border: none;
  transition: background-color 0.15s, color 0.15s;
}

/* Make sidebar a column so bottom section can stick */
.sidebar{
  display: flex;
  flex-direction: column;
  height: 100vh;            /* full height */
  overflow-y: auto;         /* allow scrolling if nav is long */

}

/* Push logout area to bottom */
.sidebar-bottom{
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
}

/* Button styling */
.sidebar-logout{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border: 1px solid var(--sidebar-border);
  background: #fff;
  color: var(--sidebar-text);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}

.sidebar-logout:hover{
  border-color: var(--primary);
}

/* Icon styling (Font Awesome) */
.sidebar-nav i {
  width: 18px;
  text-align: center;
  opacity: 0.85;
}

.sidebar-nav a.active i {
  opacity: 1;
}

/* Hover state */
.sidebar-nav a:hover {
  background: #ffffff;
}

/* Active item */
.sidebar-nav a.active {
  background: rgba(0,123,255,0.12);
  color: var(--primary-dark);
  font-weight: 600;
}

/* ===== Card / container ===== */
.container {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  padding: 2.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  max-width: 760px;
}

/* Result page centers its card in your current markup */
.container.centered { text-align: center; }

/* Inactive menu items when no active workspace */
.inactive-menu-item {
  opacity: 0.4;
  pointer-events: none;
}

/* Type */
h1 {
  color: var(--primary-dark);
  margin-top: 0;
}

p { font-size: 1.1em; }
strong { color: #000; }

/* Forms */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 1.5em;
}

select,
input[type="text"],
input[type="date"],
input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1em;
  border: 1px solid #cfd4da;
  border-radius: 6px;
  background: #fff;
}

select:focus,
input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #80bdff;
  box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}

/* Actions row */
.actions {
  margin-top: 2em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.actions.end { justify-content: flex-end; }
.actions.between { justify-content: space-between; }

/* Buttons */
.button {
  display: inline-block;
  padding: 12px 24px;
  font-size: 1em;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  border: none;
  cursor: pointer;
}

.button-primary {
  background-color: var(--primary);
  color: #fff;
}
.button-primary:hover { background-color: var(--primary-dark); }

.button-secondary {
  color: var(--muted);
  background-color: #f8f9fa;
  border: 1px solid var(--border);
}
.button-secondary:hover {
  background-color: #e2e6ea;
  color: #333;
}

/* Link-style secondary */
.button-link {
  color: var(--muted);
  text-decoration: underline;
  background: transparent;
  border: none;
  padding: 0;
}
.button-link:hover { color: #333; }

/* Tooltip icon */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--muted);
  color: #fff;
  font-size: 0.65rem;
  cursor: default;
  margin-left: 0.35rem;
  vertical-align: middle;
  opacity: 0.6;
}
.tooltip-icon:hover { opacity: 1; }

/* Result value */
.result-value {
  font-size: 2.5em;
  font-weight: bold;
  color: var(--success);
  margin: 0.5em 0;
}

/* ===== Responsive: collapse sidebar on small screens ===== */
@media (max-width: 900px) {
  body.has-sidebar {
    padding-left: 2.5rem;
    padding-top: calc(2.5rem + 56px);
  }

  .sidebar {
    height: 56px;
    width: 100%;
    right: 0;
    bottom: auto;
    flex-direction: row;
    align-items: center;
  }

  .sidebar-header {
    border-bottom: none;
    border-right: 1px solid var(--sidebar-border);
    padding: 0 14px;
    height: 100%;
    display: flex;
    align-items: center;
  }

  .sidebar-nav {
    flex-direction: row;
    gap: 8px;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
  }

  .sidebar-nav li { margin: 0; }
  .sidebar-nav a { white-space: nowrap; height: 40px; }
}

/* Step 4 */

.step4 .table-headlines {
  text-align: left;
}

.step4 table {
  border-spacing: 0;
  width: 100%;
}

.step4 td, .step4 th {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.step4 td:last-child {
  text-align: right;
  padding-right: 1rem;
  width: 4rem;
  white-space: nowrap;
}

.step4 .row-even { background-color: var(--color-surface, #f5f5f5); }

/* Category panels */
.category-panel {
  margin-bottom: 2rem;
  border: 1.5px solid #bbb;
  border-radius: 6px;
  overflow: hidden;
}
.category-panel-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.category-panel-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.category-panel-desc {
  font-size: 0.8rem;
  color: var(--muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40ch;
}
.category-panel-total {
  font-weight: 600;
  font-size: 0.9rem;
  margin-left: auto;
}
.category-panel table {
  margin-bottom: 0;
}
.category-panel-toggle {
  cursor: pointer;
  user-select: none;
}
.category-panel-chevron {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  transition: transform 0.15s ease;
  transform: rotate(0deg);
  flex-shrink: 0;
  align-self: center;
}
.category-panel.is-collapsed .category-panel-chevron {
  transform: rotate(-90deg);
}
.category-panel.is-collapsed table {
  display: none;
}
.category-panel.is-collapsed .category-panel-header {
  border-bottom: none;
}
.step4 .amounts {
  text-align: right;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  background: var(--card-bg, #fff);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.modal input, .modal select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 4px;
  font-size: 1rem;
}

.modal-description {
  font-size: 0.85rem;
  color: var(--muted, #6c757d);
  margin: 0;
  min-height: 1.2em;
}

/* Tab selector */
.tab-selector {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

/* Step 6 — Risk */

.risk-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}

.risk-card {
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.risk-card:hover {
  border-color: var(--primary);
}
.risk-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.risk-card-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.risk-card-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.rr-wrap {
  width: fit-content;
}
.rr-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.rr-label {
  font-weight: 600;
  font-size: 0.9rem;
}
.rr-display {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
  min-width: 3rem;
}
.rr-toggle {
  font-size: 0.8rem;
}
.rr-edit {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.rr-edit[hidden] { display: none; }
.rr-hint {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.rr-input-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.rr-input-row input {
  width: 6rem;
}
.rr-unit {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Step 5 */

.step5 table {
  border-spacing: 0;
  width: 100%;
}

.step5 .amounts {
  text-align: right;
}

.step5 td, .step5 th {
  padding: 0.25rem 0.75rem;
}

/* Indented items (individual P&L accounts) */
.step5 .item td:first-child {
  padding-left: 2rem;
}

/* Info box */
.info-box {
  margin-top: 1.5rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border-left: 3px solid var(--primary);
  border-radius: 0 4px 4px 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.info-box p { margin: 0; }

/* Detail/Summary view toggle */
.view-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  width: fit-content;
}
.toggle-btn {
  background: none;
  border: none;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
}
.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Summary-only Adjust links (hidden in detail mode, shown via JS) */
.summary-adjust { display: none; }

/* Bulk-action toolbar row */
.step5 .bulk-toolbar td {
  padding-top: 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.bulk-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.bulk-actions .button-link {
  font-size: 0.75rem;
}
.bulk-reset { color: var(--danger) !important; }

/* Overridden P&L line */
.step5 .has-override td:nth-child(2) {
  color: var(--primary);
}

/* Column headers */
.step5 .table-header td {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

/* Section totals */
.step5 .headline1 td {
  font-weight: 600;
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
}

/* Sub-totals and EBIT */
.step5 .headline2 td {
  font-weight: 700;
  border-top: 2px solid var(--text);
  padding-top: 0.4rem;
}

/* Main result */
.step5 .headline3 td {
  font-weight: 700;
  font-size: 1.05rem;
  border-top: 2px solid var(--text);
  border-bottom: 3px double var(--text);
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

/* Section label rows (Adjustments etc.) */
.step5 .section-label td {
  padding-top: 1rem;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Review page ===== */
.review-section {
  border: 1.5px solid #bbb;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.review-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.review-section-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.review-edit-link {
  font-size: 0.8rem;
}

.review-table {
  width: 100%;
  border-spacing: 0;
}

.review-table td {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
}

.review-table .review-label {
  color: var(--text);
}

.review-table .review-value {
  text-align: right;
  width: 10rem;
}

.review-table .amounts {
  text-align: right;
}

.review-table .review-subtotal td {
  border-top: 1px solid var(--border);
  font-weight: 600;
  padding-top: 0.5rem;
}

.review-table .review-adjustment td {
  color: var(--muted);
  font-size: 0.85rem;
  padding-left: 1.5rem;
}

.review-table .review-total td {
  border-top: 2px solid var(--text);
  font-weight: 700;
  padding-top: 0.4rem;
}

/* ===== Result / valuation panel ===== */
.valuation-panel {
  border: 1.5px solid #bbb;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 2rem;
}

.valuation-table {
  width: 100%;
  border-spacing: 0;
}

.valuation-table td {
  padding: 0.45rem 1rem;
}

.vt-label {
  color: var(--text);
}

.vt-value {
  text-align: right;
  width: 12rem;
}

.vt-muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.vt-indent {
  padding-left: 2rem;
}

.vt-divider td {
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  font-weight: 600;
}

.vt-total td {
  border-top: 2px solid var(--text);
  border-bottom: 3px double var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.vt-incomplete {
  color: var(--muted);
  font-style: italic;
}