/* ===============================
   RESET + ZÁKLAD
================================ */

:root {
    --bg-app: #f5f7fa;
    --bg-card: #ffffff;

    --blue-50:  #f1f7f9;
    --blue-200: #749dc8;
    --blue-500: #0a61c9;
    --blue-700: #064089;
    --blue-900: #07326a;

    --text-main: #1f2933;
    --text-muted: #6b7280;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    line-height: 1.4;
}

h1, h2, h3 {
    margin-top: 0;
    font-weight: 600;
}

button {
    cursor: pointer;
    border: none;
    background: #1f4e79;
    color: #fff;
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 14px;
}

button:hover {
    background: #163b5c;
}

input, select {
    padding: 6px 8px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

input[type="number"] {
    text-align: right;
}



/* ===== HEADER ===== */

.top-bar {
    background: linear-gradient(
        180deg,
        #0a3f78,   
        #06305e 
    );
}

.top-bar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 32px;

    display: flex;
    align-items: center;
}


.brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    height: 80px;        
    width: auto;
    display: block;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25));
}



/* ===== MENU ===== */

.main-nav {
    margin-left: auto;
    margin-right: 16px;

    display: flex;
    align-items: center;
    gap: 22px;             

    background: none;    
    padding: 0;
}

.main-nav button {
    background: none;
    border: none;

    padding: 6px 8px;      
    line-height: 1.3;    
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.035em;

    color: #e6eef7;
    cursor: pointer;

    border-radius: 4px;
    transition:
        color 0.15s ease,
        background 0.15s ease;
}

/* Hover – jen lehký náznak */
.main-nav button:hover {
    background: rgba(255,255,255,0.10);
}

/* Aktivní stránka */
.main-nav button.active {
    background: rgba(255,255,255,0.18);
    color: #ffffff;
}


/* ===== AUTH BUTTON (CTA) ===== */

.auth-btn {
    background: var(--blue-500);
    color: #ffffff;

    border: none;
    padding: 7px 16px;

    font-size: 0.85rem;
    font-weight: 600;

    border-radius: 6px;     /* NE pilulka */
    cursor: pointer;

    transition: background 0.2s ease;
}

.auth-btn:hover {
    background: var(--blue-700);
}


.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    padding: 20px;
    width: 320px;
    border-radius: 8px;
}

/* ===============================
   UTILITIES
================================ */

.hidden {
    display: none !important;
}

/* ===============================
   LAYOUT
================================ */

.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: calc(100vh - 56px);
}

.sidebar {
    background: #ffffff;
    border-right: 1px solid #ddd;
    padding: 20px;
}

.content {
    padding: 20px 24px;
}

#auth-section input {
    margin-right: 8px;
}

#save-status {
    font-size: 13px;
    color: #666;
}

/* ===============================
   SEKCE
================================ */

section {
    background: var(--bg-card);
    padding: 16px 18px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

section h2 {
    margin-bottom: 10px;
    font-size: 18px;
}

/* ===============================
   POPISY / HINTY
================================ */

.hint {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

/* ===============================
   TABULKY (OBECNÉ)
================================ */

.table {
    width: 100%;
}

.table-header {
    display: grid;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    border-bottom: 1px solid #ddd;
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.table-row {
    min-width: 0;
    display: grid;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.table-row input,
.table-row select {
    min-width: 0;
    width: 100%;
}

.table-row button {
    background: #c62828;
    padding: 6px 10px;
}

.table-row button:hover {
    background: #9e1f1f;
}

.table-row .asset-lock {
    display: inline-block;
    width: 30px;
    height: 30px;
}

/* ===============================
   GRIDY JEDNOTLIVÝCH TABULEK
================================ */

.incomes-grid {
    grid-template-columns: 1.5fr 1fr 1fr 1.2fr 1fr 0.7fr auto;
}

.expenses-grid {
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
}

.assets-grid {
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
}

.liabilities-grid {
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
}

.investments-grid {
    grid-template-columns:
        2fr
        1fr
        1fr
        1fr
        1fr
        1fr
        1fr
        1fr
        1fr
        1fr
        auto;
}
/* === ŽIVOTNÍ UDÁLOSTI === */

.event-block {
  border: 1px solid #ddd;
  padding: 8px;
  margin-bottom: 12px;
  background: #fff;
}

/* hlavička události */
.event-header {
  display: grid;
  grid-template-columns: 2fr 1fr auto 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.event-header input[type="number"] {
  width: 100%;
}

/* seznam akcí */
.event-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* jedna akce */
.event-action-row {
  display: grid;
  grid-template-columns:
    1.2fr   /* target */
    1.2fr   /* operation */
    1.4fr   /* selector */
    1fr     /* value */
    32px    /* + */
    32px;   /* - */
  gap: 6px;
  align-items: center;
}

.event-action-row select,
.event-action-row input {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
}

.event-action-row button {
  height: 28px;
  width: 28px;
  padding: 0;
  font-size: 16px;
  cursor: pointer;
}

.event-action-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* selector schovaný když není potřeba */
.event-action-row select.selector {
  display: none;
}

/* když je selector aktivní */
.event-action-row select.selector:not([style*="display: none"]) {
  display: block;
}


/* ===============================
   Vývoj majetku v čase – tabulka
================================ */

.results-extended {
  margin-top: 32px;
}

.results-extended h2 {
  margin-bottom: 16px;
}

/* Základ tabulky */
.results-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

/* Hlavička */
.results-table thead th {
  padding: 8px 12px;
  font-weight: 600;
  text-align: right;
  border-bottom: 2px solid #ddd;
  white-space: nowrap;
}

.results-table thead th:first-child {
  text-align: left;
}

/* Buňky */
.results-table td {
  padding: 6px 12px;
  vertical-align: middle;
  white-space: nowrap;
}

.results-table td:first-child {
  text-align: left;
}

/* Čísla doprava */
.results-table td:not(:first-child) {
  text-align: right;
}

/* ===============================
   Sekce (Cashflow / Majetek / …)
================================ */
.results-table tr.section td {
  padding-top: 16px;
  padding-bottom: 6px;
  font-weight: 600;
  border-top: 1px solid #ddd;
  background: #f8f9fb;
}

/* ===============================
   Zvýraznění součtů
================================ */
.results-table tr.highlight td {
  font-weight: 600;
  border-top: 1px solid #e0e0e0;
}

.results-table tr.strong td {
  font-size: 15px;
}

/* ===============================
   Jemné odsazení podřádků
================================ */
.results-table tr.investment-row td:first-child,
.results-table tr.asset-row td:first-child {
  padding-left: 24px;
  font-weight: 400;
}

/* ===============================
   Hover – lepší čitelnost
================================ */
.results-table tbody tr:not(.section):hover td {
  background: #f3f6fa;
}

.results-table .section td {
  font-weight: bold;
  background: #f5f5f5;
}

/* === Expandable rows (hlavní řádky) === */
.expandable-row td:first-child {
  cursor: pointer;
  position: relative;
  padding-left: 26px; /* místo na šipku */
  user-select: none;
}

.expandable-row td:first-child::before {
  content: "▶";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #666;
  transition: transform 0.2s ease;
}

.expandable-row.expanded td:first-child::before {
  transform: translateY(-50%) rotate(90deg);
}

/* === Detail rows (rozbalené řádky) === */
.detail-row td:first-child {
  padding-left: 40px;
  color: #444;
  font-size: 0.95em;
}

.detail-row .hidden {
  display: none;
}

.expandable-row:hover {
  background-color: #f6f6f6;
}

.expandable-row:hover td {
  background-color: #f9f9f9;
}

.inline-growth {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.growth-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.growth-percent {
  max-width: 68px;
}

.growth-age {
  max-width: 55px;
}

.growth-remove {
  background: #d32f2f;
  max-width: 30px;
  max-height: 30px;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
}

.add-growth-phase {
  align-self: flex-start;
  font-size: 12px;
  padding: 2px 6px;
}


/* ===============================
   GRAF
================================ */

canvas {
    width: 1000px;
    height: 420px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
}

/* ===============================
   FORMULÁŘE
================================ */

label {
    display: inline-flex;
    flex-direction: column;
    margin-right: 16px;
    font-size: 14px;
}

label input {
    margin-top: 4px;
}

#detail-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
}

/* TRACK */
#detail-slider::-webkit-slider-runnable-track {
  height: 6px;
  background: #ddd;
  border-radius: 3px;
}

#detail-slider::-moz-range-track {
  height: 6px;
  background: #ddd;
  border-radius: 3px;
}

/* FILLED část (jen Firefox umí nativně) */
#detail-slider::-moz-range-progress {
  height: 6px;
  background: #1f4e79;
  border-radius: 3px;
}

/* THUMB */
#detail-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: #1f4e79;
  cursor: pointer;
  margin-top: -7px;   /* centrování kuličky */
}

#detail-slider::-moz-range-thumb {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: #1f4e79;
  cursor: pointer;
}


/* ===============================
   RESPONSIVE
================================ */

@media (max-width: 1100px) {

    .layout {
        grid-template-columns: 1fr;
    }

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

    .table-header,
    .table-row {
        font-size: 12px;
    }
}

@media (max-width: 800px) {

    .table-header {
        display: none;
    }

    .table-row {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px;
        border: 1px solid #eee;
        border-radius: 6px;
    }

    .table-row button {
        justify-self: flex-end;
    }
}
