/* style.css — jednoduchý čistý dizajn */
:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1c2430;
    --muted: #68737f;
    --border: #d9dee4;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --error-bg: #fdecec;
    --error-text: #b3261e;
    --success-bg: #e7f6ec;
    --success-text: #1a7f37;
    --radius: 10px;
}

/* nočný režim — prepína assets/theme.js cez data-theme na <html> */
:root[data-theme="dark"] {
    --bg: #0f141b;
    --card: #1a212b;
    --text: #e6eaf0;
    --muted: #96a0ac;
    --border: #2c3644;
    --primary: #3b82f6;
    --primary-hover: #2f6fe0;
    --error-bg: #3a1d1c;
    --error-text: #f2938c;
    --success-bg: #15301f;
    --success-text: #5fce85;
}
:root[data-theme="dark"] .badge-pending { background: #3a2f14; color: #e2b04a; }
:root[data-theme="dark"] input[type="file"].input { color-scheme: dark; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* --- layout --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; }
.topbar nav { display: flex; gap: 0.25rem; }
.topbar nav a {
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
}
.topbar nav a:hover { background: var(--bg); color: var(--text); }
.topbar nav a.active { background: var(--bg); color: var(--primary); font-weight: 600; }

.container { max-width: 640px; margin: 2rem auto; padding: 0 1rem; }
.container-wide { max-width: 1200px; }
.container-form { max-width: 1100px; margin: 1.25rem auto; }

/* dvojstĺpcový formulár — vľavo údaje, vpravo správa */
.form-grid {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 0 2rem;
    align-items: stretch;
}
.form-col { min-width: 0; }
.form-col-message { display: flex; flex-direction: column; }
.field.field-grow { flex: 1; display: flex; flex-direction: column; }
.field.field-grow textarea { flex: 1; min-height: 220px; }
@media (max-width: 860px) {
    .form-grid { grid-template-columns: 1fr; }
    .field.field-grow textarea { min-height: 180px; }
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.card h1, .card h2 { margin-top: 0; }

/* --- login --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card { width: min(360px, 92vw); text-align: center; }
.pin-input { text-align: center; font-size: 1.4rem; letter-spacing: 0.4em; }

/* --- formulár --- */
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field small { display: block; margin-top: 0.25rem; }

.input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font: inherit;
    color: inherit;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: var(--primary);
}
textarea.input { resize: vertical; }

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    cursor: pointer;
}

/* výber typu podpisu */
.sig-level {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
}
.sig-level > span { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.radio {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin: 0.35rem 0;
    cursor: pointer;
    font-size: 0.92rem;
}
.radio input { margin-top: 0.2rem; }

/* prepínač témy */
.theme-btn {
    font-size: 1rem;
    line-height: 1;
    padding: 0.4rem 0.55rem;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.login-theme { position: fixed; top: 1rem; right: 1rem; }

.muted { color: var(--muted); }
code { background: var(--bg); padding: 0.1em 0.35em; border-radius: 5px; font-size: 0.9em; }

/* --- tlačidlá --- */
.btn {
    display: inline-block;
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-block { width: 100%; margin-top: 0.5rem; }
.btn-small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }

/* --- hlásenia --- */
.alert {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    white-space: pre-line;
}
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

/* --- kroky spracovania --- */
.steps {
    list-style: none;
    padding: 0;
    margin: 1.25rem 0 0;
    border-top: 1px solid var(--border);
}
.steps li {
    padding: 0.55rem 0 0.55rem 1.9rem;
    position: relative;
    color: var(--muted);
}
.steps li::before {
    content: "○";
    position: absolute;
    left: 0.35rem;
}
.steps li.running { color: var(--text); }
.steps li.running::before { content: "◔"; color: var(--primary); }
.steps li.done { color: var(--success-text); }
.steps li.done::before { content: "●"; color: var(--success-text); }
.steps li.failed { color: var(--error-text); }
.steps li.failed::before { content: "✕"; color: var(--error-text); }

/* --- potvrdzovacia obrazovka --- */
.done-card {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
    padding: 2.5rem 2rem;
}
.done-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success-text);
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.done-summary {
    margin: 1.25rem 0 1.5rem;
    text-align: left;
    border-top: 1px solid var(--border);
}
.done-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}
.done-label { color: var(--muted); white-space: nowrap; }
.done-row span:last-child { text-align: right; overflow-wrap: anywhere; }
.done-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* --- história --- */
.search-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search-row .input { flex: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td {
    text-align: left;
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }
/* obchodné meno, príjemca a ZIP sa zalamujú, nech tabuľka nescrolluje */
td:nth-child(2), td:nth-child(3), td:nth-child(5) {
    white-space: normal;
    overflow-wrap: anywhere;
}
/* užšie okno: skry CC a veľkosť */
@media (max-width: 1100px) {
    th:nth-child(4), td:nth-child(4),
    th:nth-child(6), td:nth-child(6) { display: none; }
}
/* ešte užšie: skry aj názov ZIP-u (odvodený z obchodného mena) */
@media (max-width: 900px) {
    th:nth-child(5), td:nth-child(5) { display: none; }
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}
.row-actions { display: flex; gap: 0.35rem; align-items: center; }
.inline-form { display: inline; margin: 0; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
}
.btn-icon:hover { color: var(--primary); border-color: var(--primary); background: var(--bg); }
.btn-icon-danger:hover { color: var(--error-text); border-color: var(--error-text); background: var(--error-bg); }

.badge-sent { background: var(--success-bg); color: var(--success-text); }
.badge-failed { background: var(--error-bg); color: var(--error-text); }
.badge-pending { background: #fff4e0; color: #9a6b00; }
