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

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    color: #1f2937;
    background: #f3f4f6;
    line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0 0 0.6rem 0; font-weight: 600; color: #111827; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; border-bottom: 2px solid #e5e7eb; padding-bottom: 0.4rem; margin-top: 1.2rem; }
h3 { font-size: 1.05rem; color: #374151; }
p { margin: 0.3rem 0; }

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Boot loader ---------- */
.boot-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: #6b7280;
}
.boot-spinner {
    width: 40px; height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Razmak na dnu da fiksna traka sa "Pokreni proracun" ne prekriva footer ni poslednji sadrzaj */
    padding-bottom: 76px;
}

.app-header {
    background: #1e3a8a;
    color: #fff;
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.app-header h1 { color: #fff; margin: 0; font-size: 1.25rem; font-weight: 600; }
.app-header .subtitle { color: #c7d2fe; font-size: 0.85rem; margin-top: 2px; }
.header-actions { display: flex; gap: 0.6rem; align-items: center; }

.app-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.app-footer {
    padding: 0.7rem 1.5rem;
    background: #e5e7eb;
    color: #6b7280;
    text-align: center;
    font-size: 0.8rem;
}

/* ---------- Cards ---------- */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 1.2rem 1.4rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 1.2rem;
}

.grid-2col {
    display: grid;
    grid-template-columns: minmax(380px, 1fr) minmax(420px, 2fr);
    gap: 1.2rem;
    align-items: start;
}
@media (max-width: 1000px) {
    .grid-2col { grid-template-columns: 1fr; }
}

/* ---------- Forms ---------- */
.form-section {
    margin-bottom: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.form-row.full {
    grid-template-columns: 1fr;
}

.form-field {
    display: flex;
    flex-direction: column;
}

.form-field label {
    font-size: 0.8rem;
    color: #4b5563;
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.form-field .hint {
    font-size: 0.72rem;
    color: #9ca3af;
    margin-top: 0.15rem;
}

input[type="text"], input[type="number"], select, textarea {
    padding: 0.45rem 0.55rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 0.92rem;
    background: #fff;
    width: 100%;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.radio-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.2rem;
}
.radio-group label {
    flex: 1;
    padding: 0.55rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    font-size: 0.88rem;
    background: #fff;
    color: #4b5563;
    transition: all 0.15s;
}
.radio-group input[type="radio"] { display: none; }
.radio-group input[type="radio"]:checked + span {
    color: #fff;
}
.radio-group label.selected {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.radio-group label:hover:not(.selected) {
    background: #f3f4f6;
}

/* ---------- Buttons ---------- */
.btn {
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 5px;
    font-size: 0.92rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }
.btn-large { padding: 0.8rem 1.5rem; font-size: 1rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.8rem; }

/* Dugme "Pokreni proracun" — fiksna traka zakacena za dno ekrana (viewport),
   uvek vidljiva bez obzira na skrol, da bude klikabilna u svakom trenutku. */
.run-sticky {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 500;
    display: flex;
    justify-content: center;
    padding: 0.7rem 1.5rem;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}
/* Dugme unutar fiksne trake — ograniceno na razumnu sirinu i centrirano */
.run-sticky > button {
    max-width: 520px;
}

/* ---------- Result panel ---------- */
.peak-headline {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #fff;
    padding: 1rem 1.2rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.peak-headline .label { font-size: 0.8rem; color: #c7d2fe; }
.peak-headline .value { font-size: 2rem; font-weight: 700; line-height: 1.1; margin: 0.2rem 0; }
.peak-headline .meta { font-size: 0.85rem; color: #dbeafe; }

.kv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.kv-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}
.kv-table td:first-child { color: #6b7280; }
.kv-table td:last-child { text-align: right; font-weight: 600; color: #111827; }

.share-bar {
    height: 22px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    background: #f3f4f6;
    margin-top: 0.4rem;
}
.share-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
}
.share-solar { background: #f59e0b; }
.share-internal { background: #10b981; }
.share-transmission { background: #6366f1; }

.share-legend {
    display: flex;
    gap: 0.9rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: #4b5563;
}
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 0.3rem;
    vertical-align: middle;
}

/* ---------- Charts ---------- */
.chart-wrapper {
    margin-top: 0.5rem;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1rem;
}
.tab {
    padding: 0.55rem 1rem;
    cursor: pointer;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.9rem;
}
.tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}
.tab:hover:not(.active) { color: #374151; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal-card {
    background: #fff;
    border-radius: 8px;
    max-width: 760px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.6rem 2rem;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.modal-close {
    position: absolute;
    top: 0.6rem;
    right: 0.8rem;
    border: none;
    background: transparent;
    font-size: 1.6rem;
    color: #6b7280;
    cursor: pointer;
}
.modal-close:hover { color: #111827; }

/* ---------- Misc ---------- */
.muted { color: #6b7280; font-size: 0.85rem; }
.warn-banner {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    color: #78350f;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
}
.error-banner {
    background: #fee2e2;
    border-left: 3px solid #dc2626;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    color: #7f1d1d;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
}
.success-banner {
    background: #d1fae5;
    border-left: 3px solid #059669;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    color: #064e3b;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.lang-switch {
    display: inline-flex;
    background: rgba(255,255,255,0.15);
    border-radius: 5px;
    overflow: hidden;
}
.lang-switch button {
    background: transparent;
    color: #c7d2fe;
    border: none;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}
.lang-switch button.active {
    background: #fff;
    color: #1e3a8a;
}
.lang-switch button:not(.active):hover { background: rgba(255,255,255,0.2); }

.month-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.4rem;
    margin-top: 0.2rem;
}
.month-grid button {
    padding: 0.45rem 0;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #4b5563;
}
.month-grid button.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.month-grid button:hover:not(.active) { background: #f9fafb; }

.peak-row-month {
    background: #fef3c7 !important;
    font-weight: 700;
}

table.simple {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    margin-top: 0.4rem;
}
table.simple th, table.simple td {
    padding: 0.45rem 0.55rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}
table.simple th {
    background: #f9fafb;
    color: #4b5563;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
table.simple td.num { text-align: right; font-variant-numeric: tabular-nums; }
