/* =====================================================================
   Motyw „modern" — dostosowania do Joomli.

   theme-modern.css jest wiernym portem makiety i celowo go nie zmieniamy,
   żeby dało się go porównać ze źródłem. Tutaj trafia wszystko, co wynika
   ze zderzenia makiety z realnym wyjściem Joomli i Cassiopei.

   Kolejność: theme-modern.css → theme-joomla.css
   ===================================================================== */

/* =====================================================================
   SKALA TYPOGRAFICZNA

   Jedno miejsce na rozmiary tekstu dla całego serwisu. Opis skali i powody
   doboru wartości: docs/typografia.md.

   Nagłówki są płynne w przedziale 600 → 1440 px - poniżej 600 px trzymają
   minimum, powyżej 1440 px maksimum. Wszystkie pięć formuł ma ten sam
   przedział, więc nagłówki rosną równolegle i hierarchia nigdy nie odwraca
   się w połowie skalowania.

   Formuła: clamp(<minimum>, <punkt bazowy> + <współczynnik>vw, <maksimum>).
   Punkt bazowy w rem, żeby skala przeżyła zmianę rozmiaru czcionki
   w ustawieniach przeglądarki.
   ===================================================================== */
.theme-modern {
    /* --- tekst poza nagłówkami: stałe, bez clamp --- */
    --m-fs-meta:    12px;   /* metadane, badge, mikroetykiety */
    --m-fs-sm:      13px;   /* tekst drugorzędny, nagłówki tabel, daty */
    --m-fs-base:    14px;   /* PODSTAWOWY */
    --m-fs-md:      15px;   /* nawigacja, pola formularzy */
    --m-fs-lg:      16px;   /* tytuły kafelków; pola na mobile - wymóg iOS */

    /* --- nagłówki: płynne 600 → 1440 px --- */
    --m-fs-display: clamp(2rem, 1.464rem + 1.429vw, 2.75rem);     /* 32 → 44 px */
    --m-fs-h1:      clamp(1.375rem, 1.018rem + 0.952vw, 1.875rem); /* 22 → 30 px */
    --m-fs-h2:      clamp(1.1875rem, 0.964rem + 0.595vw, 1.5rem);  /* 19 → 24 px */
    --m-fs-h3:      clamp(1.0625rem, 0.929rem + 0.357vw, 1.25rem); /* 17 → 20 px */
    --m-fs-h4:      clamp(1rem, 0.911rem + 0.238vw, 1.125rem);     /* 16 → 18 px */

    /* h5 i h6 bez clamp: przy zakresie 15-16 px płynność dawałaby różnicę
       jednego piksela na całej szerokości ekranu - niewidoczną, a kosztującą
       dwie formuły do utrzymania. */
    --m-fs-h5:      0.9375rem;  /* 15 px */
    --m-fs-h6:      0.8125rem;  /* 13 px */
}

/* Interlinia nagłówków (1.2) przychodzi z Bootstrapa i jest poprawna -
   celowo jej tu nie powtarzamy. */
.theme-modern h1, .theme-modern .h1 {
    font-size: var(--m-fs-h1);
    font-weight: 600;
    letter-spacing: -.2px;
}

.theme-modern h2, .theme-modern .h2 {
    font-size: var(--m-fs-h2);
    font-weight: 500;
}

.theme-modern h3, .theme-modern .h3 {
    font-size: var(--m-fs-h3);
    font-weight: 500;
}

.theme-modern h4, .theme-modern .h4 {
    font-size: var(--m-fs-h4);
    font-weight: 500;
}

.theme-modern h5, .theme-modern .h5 {
    font-size: var(--m-fs-h5);
    font-weight: 500;
}

/* h6 jest mniejszy od tekstu podstawowego, więc bez wersalików nie czyta się
   jako nagłówek - stąd uppercase i rozstrzelenie, jak przy nagłówkach grup
   w nawigacji. */
.theme-modern h6, .theme-modern .h6 {
    font-size: var(--m-fs-h6);
    font-weight: 600;
    letter-spacing: .8px;
    text-transform: uppercase;
}

/* --- Nawigacja ---------------------------------------------------------
   W makiecie pozycje menu to <div>. U nas muszą być <a>, żeby działały
   i były dostępne z klawiatury — więc zdejmujemy podkreślenia Cassiopei. */
.theme-modern .nav-item,
.theme-modern .nav-item:hover,
.theme-modern .brand a,
.theme-modern .user-chip a {
    text-decoration: none;
}

.theme-modern .nav-item:focus-visible {
    box-shadow: var(--m-focus);
}

/* Brand w sidebarze: logo jest odnośnikiem do strony głównej */
.theme-modern .brand-text a {
    display: block;
    line-height: 0;
}

/* --- Treść komponentu --------------------------------------------------
   Cassiopeia zakłada własny kontener; u nas rolę marginesów pełni .content. */
.theme-modern .content > .container-component,
.theme-modern .content .com-content-article {
    padding: 0;
    margin: 0;
}

/* Marginesy pionowe specyficzne dla obszaru treści - waga i letter-spacing
   przychodzą ze skali. Reguły dla .content h2 nie ma, bo skala obsługuje h2
   w całym serwisie.

   font-size musi tu zostać wprost: nagłówek powitania to
   <h1 class="page-title page-welcome">, a klasa .page-title ma w szkielecie
   własny rozmiar (24 px, 20 px na mobile). Jako selektor z dwiema klasami
   (0,2,0) bije globalne .theme-modern h1 (0,1,1), więc bez tej deklaracji
   powitanie wypadałoby ze skali. Tutaj mamy (0,2,1) i wygrywamy. */
.theme-modern .content h1,
.theme-modern .content .page-header h1 {
    font-size: var(--m-fs-h1);
    margin-bottom: 1rem;
    margin-top: 1rem;
}

/* --- Ekran logowania ---------------------------------------------------
   Joomla renderuje komunikaty (błąd logowania, wygasła sesja) wewnątrz
   kolumny formularza — nadajemy im szerokość formularza i odstęp. */
.theme-modern .login-form-wrap .joomla-alert,
.theme-modern .login-form-wrap #system-message-container {
    width: 100%;
    max-width: 400px;
    margin-bottom: 16px;
}

/* Pola dokładane przez wtyczki (np. hasło jednorazowe) w stylu pozostałych */
.theme-modern .field-plugin input[type="text"],
.theme-modern .field-plugin input[type="password"],
.theme-modern .field-plugin input[type="number"] {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border: 1px solid var(--m-border);
    border-radius: var(--m-radius);
    font-size: 15px;
}

.theme-modern .field-plugin label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

/* Stopka ekranu logowania: moduł „Stopka" obok informacji o prawach */
.theme-modern .login-foot .moduletable,
.theme-modern .login-foot div {
    margin: 0;
}

/* --- Menu użytkownika w topbarze ---------------------------------------
   Wylogowanie trafiło pod awatar, bo tam użytkownik go szuka - obok
   swojego nazwiska, a nie w przeciwległym rogu ekranu. */
.theme-modern .user-box {
    position: relative;
}

.theme-modern .topbar .user-chip {
    border: 0;
    background: transparent;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    text-align: left;
}

.theme-modern .topbar .user-chip:hover {
    background: var(--m-hover);
}

.theme-modern .topbar .user-chip .ti-chevron-down {
    font-size: 16px;
    color: var(--m-muted);
}

.theme-modern .user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    min-width: 240px;
    padding: 8px;
    background: var(--m-surface);
    border: 1px solid var(--m-border);
    border-radius: var(--m-radius-lg);
    box-shadow: 0 12px 28px rgba(16, 24, 40, .12);
}

.theme-modern .user-menu[hidden] {
    display: none;
}

.theme-modern .user-menu-head {
    padding: 8px 12px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--m-divider);
}

.theme-modern .user-menu-head .user-role {
    word-break: break-all;
}

.theme-modern .user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: var(--m-radius);
    color: var(--m-text-2);
    font-size: 14px;
    text-decoration: none;
}

.theme-modern .user-menu-item i {
    font-size: 20px;
}

.theme-modern .user-menu-item:hover {
    background: var(--m-hover);
    color: var(--m-text);
}

.theme-modern .user-menu-item-danger {
    color: var(--m-red);
}

.theme-modern .user-menu-item-danger:hover {
    background: #fff1f1;
    color: var(--m-red);
}

@media (max-width: 767.98px) {
    .theme-modern .topbar .user-chip .ti-chevron-down {
        display: none;
    }
}

/* Nazwa i login jeden pod drugim - w przycisku menu są elementami <span> */
.theme-modern .topbar .user-chip .user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.theme-modern .topbar .user-chip .user-name,
.theme-modern .topbar .user-chip .user-role {
    display: block;
}

/* --- Strona startowa: kafle skrótów (moduł własny „Skróty") -------------- */
.theme-modern .start-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.theme-modern .start-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: var(--m-surface);
    border: 1px solid var(--m-border);
    border-radius: var(--m-radius-lg);
    color: var(--m-text);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s;
}

.theme-modern .start-card:hover {
    border-color: #d5d9e0;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

.theme-modern .start-card .kpi-icon {
    margin-bottom: 14px;
}

.theme-modern .start-card-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.theme-modern .start-card-desc {
    font-size: 13px;
    color: var(--m-muted);
    line-height: 1.5;
}

/* --- Strona startowa: lista nowych plików (mod_remositorymulti) ---------- */
.theme-modern .tensoft-newest {
    margin-top: 24px;
    padding: 18px 20px;
    background: var(--m-surface);
    border: 1px solid var(--m-border);
    border-radius: var(--m-radius-lg);
}

/* Tytuł karty, nie nagłówek sekcji - stąd h3, a nie h2 ze skali. Przy 1440 px
   wychodzi 20 px, czyli dokładnie tyle, ile dawała poprzednia własna formuła;
   różnica jest tylko na mobile (17 px zamiast 14, czyli zamiast rozmiaru
   akapitu). Moduł renderuje raz h2, raz h3 - zależnie od ustawień - więc
   łapiemy oba. */
.theme-modern .tensoft-newest h2,
.theme-modern .tensoft-newest h3 {
    font-size: var(--m-fs-h3);
    font-weight: 600;
    margin: 1rem 0;
    padding-left: 1rem;
}
.theme-modern .tensoft-newest table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.theme-modern .tensoft-newest td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--m-divider);
    font-size: 14px;
    vertical-align: middle;
}

.theme-modern .tensoft-newest tr:last-child td {
    border-bottom: 0;
}

.theme-modern .tensoft-newest td:last-child {
    text-align: right;
    color: var(--m-muted);
    font-size: 13px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.theme-modern .tensoft-newest a {
    color: var(--m-text);
    text-decoration: none;
    font-weight: 500;
}

.theme-modern .tensoft-newest a:hover {
    color: var(--m-primary);
}

.theme-modern .tensoft-newest img {
    width: 22px;
    height: 22px;
}

/* Moduł nowych plików rysuje własną ramkę i pasy - wewnątrz naszej karty
   dają podwójne obramowanie, więc je zdejmujemy. */
.theme-modern .tensoft-newest .rem-module,
.theme-modern .tensoft-newest .rem-table-row,
.theme-modern .tensoft-newest table,
.theme-modern .tensoft-newest tbody tr {
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

.theme-modern .tensoft-newest tbody tr td {
    background: transparent;
    border-bottom: 1px solid var(--m-divider);
}

/* --- Logo marki --------------------------------------------------------
   Nowy znak ma proporcje 252x156 (napis w dwóch wierszach), a nie 600x155
   jak poprzedni. Przy wysokości 22 px z makiety byłby nieczytelny, więc
   podnosimy ją - szerokość dobiera się sama z proporcji. */
.theme-modern .brand-text img {
    height: 64px;
    margin-top: 0;
}

.theme-modern .login-logo {
    height: 39px;
}

@media (max-width: 575.98px) {
    .theme-modern .login-logo {
        height: 46px;
    }
}
/* --- Krój pisma nagłówków ----------------------------------------------
   Cassiopeia nadaje nagłówkom font ze zmiennej --cassiopeia-font-family-headings,
   a gdy ta nie jest zdefiniowana, spada do stosu systemowego (Segoe UI, Roboto).
   Stary index.php ustawiał ją tylko przy wybranym schemacie czcionek; nowy
   schematu nie wczytuje, bo mamy własny font - więc podajemy ją wprost.

   Poppins jest hostowany lokalnie: css/fonts-poppins.css + fonts/poppins/,
   bez połączeń z Google Fonts. */
.theme-modern {
    --cassiopeia-font-family-body: var(--m-font);
    --cassiopeia-font-family-headings: var(--m-font);
}

/* Rozmiary tych nagłówków są w sekcji SKALA TYPOGRAFICZNA na górze pliku. */
.theme-modern h1, .theme-modern .h1,
.theme-modern h2, .theme-modern .h2,
.theme-modern h3, .theme-modern .h3,
.theme-modern h4, .theme-modern .h4,
.theme-modern h5, .theme-modern .h5,
.theme-modern h6, .theme-modern .h6 {
    font-family: var(--m-font);
}

/* Ścieżka kontenera na liście nowych plików: moduł › folder */
.theme-modern .tensoft-newest .rem-module-item-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--m-text-2);
}

.theme-modern .tensoft-newest .rem-path-icon {
    color: var(--m-muted);
    line-height: 1;
}

.theme-modern .tensoft-newest .rem-path-icon i {
    font-size: 17px;
}

.theme-modern .tensoft-newest .rem-path-sep {
    color: var(--m-gray-dot);
    margin: 0 2px;
}

.theme-modern .tensoft-newest .rem-module-item-container a {
    color: var(--m-text-2);
    font-weight: 400;
}

.theme-modern .tensoft-newest .rem-module-item-container a:hover {
    color: var(--m-primary);
}

/* Ikona daty na liście nowych plików */
.theme-modern .tensoft-newest .rem-date-icon {
    color: var(--m-gray-dot);
    line-height: 1;
    margin-right: 6px;
}

.theme-modern .tensoft-newest .rem-date-icon i {
    font-size: 17px;
}

.theme-modern .tensoft-newest .rem-module-item-calendar {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

/* Nagłówek ekranu logowania: odstęp od formularza, który wcześniej dawał
   usunięty podtytuł. Rozmiar (30 px, 26 px na mobile) zostaje ze szkieletu -
   to świadomie większy nagłówek dla jednego ekranu, poza skalą h1. */
.theme-modern .login-title {
    margin-bottom: 34px;
}

/* Hasło w kolumnie marki: w szkielecie ma formułę, która dobija do maksimum
   dopiero przy 3200 px, więc realnie nigdy nie przekraczała ~41 px.
   Podmieniamy na rozmiar display z naszej skali (32 → 44 px przy 1440 px).
   Selektor celowo taki sam jak w theme-modern.css - ten arkusz wczytuje się
   później, a theme-modern.css zostaje wiernym portem makiety. */
.theme-modern .brand-copy h2 {
    font-size: var(--m-fs-display);
}

/* Powitanie różni się od pozostałych h1 tylko odstępem od góry - rozmiar
   i waga przychodzą ze skali, margin-bottom z reguły .content h1 wyżej. */
.theme-modern .content h1.page-welcome {
    margin-top: 2rem;
}

/* --- Strona błędu (error.php) -------------------------------------------
   Szkielet jest ten sam co na pozostałych stronach, więc tutaj wystarczy
   sama karta z komunikatem. Kod błędu dostaje rozmiar display - to on jest
   elementem, który ma przykuć wzrok, a nie nagłówek. */
.theme-modern .error-page {
    max-width: 560px;
    margin: 4vh auto;
    padding: 32px;
    background: var(--m-surface);
    border: 1px solid var(--m-border);
    border-radius: var(--m-radius-lg);
    text-align: center;
}

.theme-modern .error-icon {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff1f1;
    color: var(--m-brand);
}

.theme-modern .error-icon i {
    font-size: var(--m-icon-lg);
    line-height: var(--m-lh-icon);
}

.theme-modern .error-code {
    display: block;
    margin-top: 16px;
    font-size: var(--m-fs-display);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.5px;
    color: var(--m-muted);
}

/* Nagłówek bierze rozmiar ze skali - zdejmujemy tylko górny margines, bo
   odstęp od kodu błędu jest już wyżej. */
.theme-modern .error-page h1.error-title {
    margin-top: 4px;
}

.theme-modern .error-text {
    margin: 0 0 24px;
    font-size: var(--m-fs-base);
    line-height: 1.6;
    color: var(--m-text-2);
}

.theme-modern .error-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.theme-modern .error-modules {
    margin-top: 24px;
}

/* Blok diagnostyczny widoczny tylko przy włączonym debugowaniu - treść jest
   techniczna, więc wyrównana do lewej i mniejszym stopniem. */
.theme-modern .error-details {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--m-divider);
    text-align: left;
    font-size: var(--m-fs-sm);
}

.theme-modern .error-details summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--m-text-2);
}

.theme-modern .error-details .error-message {
    margin: 12px 0;
    color: var(--m-text);
    word-break: break-word;
}

.theme-modern .error-details pre,
.theme-modern .error-details table {
    max-width: 100%;
    overflow: auto;
    font-size: var(--m-fs-meta);
}
