/* MAM ZAPISANE — arkusz stylów interfejsu panelu superadmina. */

:root {
    --bg:        #f4f6f9;
    --surface:   #ffffff;
    --border:    #e2e6ec;
    --text:      #1f2933;
    --muted:     #67707b;
    --danger:    #c8332b;
    --danger-d:  #a5271f;
    --ok:        #1f7a44;
    /* Kolor wiodący: deepskyblue — przyciemniony dla czytelnego kontrastu
       białego tekstu na wypełnionym tle (przyciski funkcyjne, nagłówki modali). */
    --primary:       #0ea1d2;
    --primary-d:     #0b7ea8;
    --accent:        #0ea1d2;
    --accent-d:      #0b7ea8;
    --accent-border: #086383;
    --radius:    9px;
    --shadow:    0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
    --control-h: 34px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); }

code {
    font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: rgba(15, 23, 42, .06);
    padding: 1px 5px;
    border-radius: 4px;
}

.muted { color: var(--muted); }

/* ---------- Ekran logowania -------------------------------------- */

body.auth {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth__card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 26px 30px;
}

.auth__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
}

.auth__logo-img {
    display: block;
    max-width: 240px;
    max-height: 72px;
    width: auto;
    height: auto;
}

.auth__name { font-weight: 700; font-size: 17px; }
.auth__title { font-size: 16px; margin: 0 0 14px; }
.auth__foot { color: var(--muted); font-size: 13px; margin-top: 16px; }

/* ---------- Układ aplikacji ------------------------------------- */

.app__shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 234px;
    flex-shrink: 0;
    background: #222;
    color: #cdd7e4;
    display: flex;
    flex-direction: column;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 16px;
    min-height: 56px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar__logo-img {
    display: block;
    max-width: 100%;
    max-height: 46px;
    width: auto;
    height: auto;
}

.sidebar__name { font-weight: 700; color: #fff; font-size: 15px; }

.sidebar__nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }

.navitem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    color: #cdd7e4;
    text-decoration: none;
    font-size: 14px;
}

.navitem:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.navitem.is-active { background: var(--accent); color: #fff; }
.navitem__icon {
    width: 30px;
    flex-shrink: 0;
    text-align: center;
    font-size: 26px;
    line-height: 1;
    filter: grayscale(1);
    opacity: .75;
}
.navitem.is-active .navitem__icon { opacity: 1; }
.navitem--disabled { opacity: .5; cursor: default; }
.navitem__tag {
    margin-left: auto;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #8fa1b8;
}

.app__main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 22px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.topbar__toggle {
    display: none;
    border: 0;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
}

.topbar__title { font-size: 17px; margin: 0; }

.topbar__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar__username { font-size: 13px; color: var(--muted); }

@media (max-width: 560px) {
    .topbar__username { display: none; }
}

/* Pasek narzędzi zakładki — przyciski + pola wyszukiwania w jednym,
   segmentowym pasku u góry treści zakładki. */
.toolbar {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    min-height: 42px;
    background: #dde1e7;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 18px;
}

.toolbar--card-top {
    margin: -20px -22px 14px;
    border-radius: var(--radius) var(--radius) 0 0;
    border: none;
    border-bottom: 1px solid var(--border);
}

.toolbar__title {
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
}

.toolbar__actions { display: flex; align-items: stretch; margin-left: auto; }
.toolbar__group { display: flex; align-items: stretch; }

.toolbar__input {
    margin: 6px 4px;
    padding: 0 10px;
    border: none;
    border-left: 1px solid #c6ccd4;
    border-right: 1px solid #c6ccd4;
    border-radius: 5px;
    background: #fff;
    font: inherit;
    color: var(--text);
    width: 86px;
}
.toolbar__input:focus { outline: none; background: #eef4ff; }
.toolbar__input--wide { width: 200px; }

.toolbar__btn {
    display: inline-flex;
    align-items: center;
    height: 100%;
    margin: 0;
    padding: 0 16px;
    border: none;
    border-left: 1px solid #c6ccd4;
    border-right: 1px solid #c6ccd4;
    background: linear-gradient(to bottom, #e3e6eb, #d3d7dd);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.toolbar__btn:hover { background: linear-gradient(to bottom, #aab1bd, #c7cdd6); }
.toolbar__btn:active { background: linear-gradient(to bottom, #99a1ae, #b8bfc9); }

/* Klawisze funkcyjne (prowadzące do edycji/zapisu) — kolor wiodący. */
.toolbar__btn--accent {
    color: #fff;
    border-left: 1px solid var(--accent-border);
    border-right: 1px solid var(--accent-border);
    background: linear-gradient(to bottom, #3fb6de, var(--accent));
}
.toolbar__btn--accent:hover { background: linear-gradient(to bottom, #0c86ae, #0a6c8c); }
.toolbar__btn--accent:active { background: linear-gradient(to bottom, #096e8f, var(--accent-d)); }

@media (max-width: 720px) {
    .toolbar,
    .toolbar__actions,
    .toolbar__group {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar__actions { margin-left: 0; width: 100%; }
    .toolbar__title { padding: 10px 16px; }

    .toolbar__input {
        width: auto;
        margin: 8px 10px;
        padding: 12px 10px;
        border: 1px solid #c6ccd4;
    }

    .toolbar__btn {
        width: 100%;
        justify-content: center;
        margin: 0;
        padding: 12px 16px;
        border-left: none;
        border-right: none;
        border-top: 1px solid #c6ccd4;
    }
    .toolbar__btn--accent { border-top-color: var(--accent-border); }
}

/* Zawartość modułu wypełnia całą dostępną szerokość; węższe bloki (np.
   formularze) ograniczamy klasą .card--narrow. */
.content { padding: 22px; width: 100%; }

/* ---------- Karty --------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 18px;
}

.card--narrow { max-width: 480px; }
.card__title { font-size: 16px; margin: 0 0 12px; }
.card__lead { color: var(--muted); margin: 0 0 16px; }

/* ---------- Formularze ---------------------------------------- */

.form { display: flex; flex-direction: column; gap: 13px; }
.form__row { display: flex; flex-direction: column; gap: 5px; }
.form__label { font-size: 13px; font-weight: 600; }
.form__hint { font-weight: 400; color: var(--muted); }

.form__input {
    font: inherit;
    line-height: 1.4;
    padding: 8px 10px;
    border: 1px solid #cbd2db;
    border-radius: 7px;
    background: #fff;
    width: 100%;
    min-height: 39px;
}

.form__input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 161, 210, .18);
}

.form__input.is-invalid,
.form__input:user-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(200, 51, 43, .15);
}

.form__check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.form__check.is-invalid { color: var(--danger-d); }
.form__check.is-invalid input { outline: 2px solid var(--danger); outline-offset: 2px; }
.form__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.form__actions--confirm { justify-content: space-between; }

.btn--right { margin-left: auto; }

.name { font-weight: 700; }
a.name { color: var(--text); text-decoration: none; }
a.name:hover { color: var(--primary); }

/* ---------- Przyciski ---------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 600;
    padding: 8px 15px;
    border-radius: 7px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
}

.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-d); }
.btn--ghost { background: #fff; border-color: #cbd2db; color: var(--text); }
.btn--ghost:hover { background: #f1f3f6; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-d); }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-d); }
.btn--sm { padding: 5px 10px; font-size: 13px; }
.btn--block { width: 100%; text-align: center; margin-top: 4px; }

/* ---------- Tabele ----------------------------------------- */

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th, .table td {
    text-align: left;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
}

.table tbody tr:hover { background: #f7f9fc; }

.table th.col-actions,
.table td.col-actions {
    width: 1px;
    white-space: nowrap;
    text-align: right;
    padding-right: 0;
}

.table__actions { white-space: nowrap; }
.table__actions .btn + .btn,
.table__actions .inline-form + .btn { margin-left: 6px; }
.table__actions .inline-form { margin-left: 6px; }
.inline-form { display: inline; }

/* Etykieta statusu (pill) — wypełnione tło, biała czcionka. */
.tag {
    display: inline-block;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(15, 23, 42, .08);
    color: var(--muted);
    white-space: nowrap;
}

.tag--aktywny    { background: var(--ok); color: #fff; }
.tag--nieaktywny { background: var(--danger-d); color: #fff; }

/* ---------- Statystyki pulpitu ---------------------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat__value { font-size: 24px; font-weight: 700; }
.stat__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Komunikaty ---------------------------------- */

.alert {
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}

.alert--success { background: #e7f6ec; color: var(--ok); border-color: #b7e0c6; }
.alert--info { background: #e5f6fc; color: var(--primary-d); border-color: #b9e4f2; }
.alert--error { background: #fdecec; color: var(--danger-d); border-color: #f3c2c2; }

/* ---------- Paginacja ---------------------------------- */

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    font-size: 13px;
    flex-wrap: wrap;
}

.pager__info { color: var(--muted); }
.pager__links { display: flex; gap: 4px; }

.pager__link {
    display: inline-block;
    min-width: 30px;
    text-align: center;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
}

.pager__link.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager__gap { padding: 5px 4px; color: var(--muted); }

/* ---------- Modal ------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 7vh 16px 16px;
}

.modal[hidden] { display: none; }

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}

.modal__dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    max-height: 86vh;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 12px 44px rgba(15, 23, 42, .28);
    overflow: hidden;
}

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
}

.modal__title { margin: 0; font-size: 16px; font-weight: 600; }

.modal__x {
    background: none;
    border: 0;
    font-size: 22px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    color: var(--muted);
}

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

/* Okno w kolorze wiodącym — nagłówek na deepskyblue, biały tytuł/X.
   Domyślne dla wszystkich okien modalnych (edycja/zapis/usuwanie). */
.modal--accent .modal__head { background: var(--accent); border-bottom-color: var(--accent-d); }
.modal--accent .modal__title { color: #fff; }
.modal--accent .modal__x { color: rgba(255, 255, 255, .8); }
.modal--accent .modal__x:hover { color: #fff; }

.modal__body { padding: 18px; overflow-y: auto; }
.modal__body > .card,
.modal__body > .card--narrow { border: 0; box-shadow: none; padding: 0; margin: 0; max-width: none; }

body.modal-open { overflow: hidden; }

/* ---------- Nakładka „przetwarzanie" ------------------ */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .38);
}

.overlay[hidden] { display: none; }

.overlay__spinner {
    width: 46px;
    height: 46px;
    border: 4px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: overlay-spin .75s linear infinite;
}

@keyframes overlay-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .overlay__spinner { animation-duration: 2s; }
}
