/* RESET PODSTAWOWY */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: #f5f5f5;
    color: #222;
    line-height: 1.4;
}

/* Ekran – normalne wyświetlanie */
@media screen {
    /* tu normalne style, opcjonalnie nic nie trzeba robić */
}

/* Drukowanie */
@media print {

    /* Ukryj wszystko */
    body * {
        visibility: hidden;
    }

    /* Pokaż tylko tabelę z raportem */
    #raport,
    #raport * {
        visibility: visible;
    }

    /* Ustaw tabelę w lewym górnym rogu do druku */
    #raport {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    /* Powtarzanie nagłówka na każdej stronie */
    #raport thead {
        display: table-header-group;
    }

    /* (opcjonalnie) stopka tabeli na każdej stronie */
    #raport tfoot {
        display: table-footer-group;
    }

    /* (opcjonalnie) unikaj łamania wierszy w połowie */
    #raport tr {
        page-break-inside: avoid;
    }
}

/* LINKI – ogólnie */
a {
    color: #003366;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* LINKI W TREŚCI (.content) – jednolity kolor i zawsze podkreślone */
.content a,
.content a:visited,
.content a:active {
    color: #222;              /* jak podstawowy tekst */
    text-decoration: underline;
}

/* TOPBAR */

.topbar {
    background: #003366;
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-logo {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.05em;
}

.topbar-right {
    font-size: 0.9rem;
}

.topbar-right a {
    color: #ffd54f;
    margin-left: 12px;
}

/* LAYOUT GŁÓWNY */

.layout {
    display: flex;
    min-height: calc(100vh - 48px); /* 48px ~ wysokość topbara */
}

/* SIDEBAR */

.sidebar {
    width: 220px;
    background: #e6e9ef;
    padding: 16px 10px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
    text-transform: uppercase;
}

.sidebar a {
    display: block;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #003366;
    background: transparent;
}

.sidebar a:hover {
    background: #d5dae5;
}

.sidebar a.active {
    background: #ffd54f;
    color: #000;
    font-weight: 600;
}

/* CONTENT */

.content {
    flex: 1;
    padding: 20px 28px;
}

.content-header {
    border-bottom: 3px solid #ffd54f;
    padding-bottom: 6px;
    margin-bottom: 16px;
}

.content-header h1 {
    margin: 0 0 4px 0;
    font-size: 1.4rem;
    color: #003366;
}

.content-header p {
    margin: 0;
    font-size: 0.9rem;
    color: #555;
}

/* KARTY / BLOKI */

.card {
    background: #fff;
    border-radius: 6px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* NAGŁÓWKI SEKCJI */

.section-subtitle {
    font-size: 1rem;
    color: #003366;
    margin: 18px 0 8px 0;
    font-weight: 600;
}

/* FORMULARZE */

label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    max-width: 360px;
    padding: 6px 8px;
    margin-top: 4px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

textarea {
    resize: vertical;
}

button,
input[type="submit"] {
    background: #003366;
    color: #fff;
    border-radius: 4px;
    border: none;
    padding: 8px 14px;
    font-size: 0.9rem;
    cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
    background: #00254a;
}

/* TABELE */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 6px 8px;
    border: 1px solid #ddd;
    vertical-align: top;
}

th {
    background: #f0f2f7;
    font-weight: 600;
}

/* Wyrównanie liczb w tabelach adminowych */
table td.numeric,
table th.numeric {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#raport td.numeric,
#raport th.numeric {
    text-align: right !important;
}

/* LISTA PODPOWIEDZI (WYSZUKIWARKA TOWARÓW) */

#suggestions {
    max-width: 360px;
    max-height: 220px;
    border: 1px solid #999;
    background: #fff;
    overflow-y: auto;
    margin-top: 2px;
}

#suggestions div {
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

#suggestions div:hover {
    background: #f0f2f7;
}

/* KALKULATOR + POLE ILOŚCI */

.hidden {
    display: none !important;
}

/* Wrapper pola ilości i kalkulatora */
.qty-calc-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.qty-field {
    flex: 0 0 auto;
}

/* Desktop – kalkulator obok pola ilości */
.calc-container {
    display: inline-block;
    vertical-align: top;
    margin-top: 0;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px;
    max-width: 260px;
    font-size: 0.85rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.calc-title {
    margin: 0 0 4px 0;
    font-weight: 600;
    color: #003366;
}

.calc-display input {
    width: 100%;
    padding: 4px 6px;
    margin-bottom: 6px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 0.9rem;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 6px;
}

.calc-buttons button {
    padding: 4px 0;
    font-size: 0.8rem;
}

.calc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.calc-actions button {
    flex: 1;
    min-width: 80px;
    font-size: 0.8rem;
}

/* STRONA LOGOWANIA – MOBILE FIRST */

.login-page {
    min-height: 100vh;
    background: #001a33;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.login-card {
    background: rgba(255,255,255,0.97);
    border-radius: 10px;
    padding: 20px 18px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.login-card h1 {
    margin-top: 0;
    margin-bottom: 4px;
    font-size: 1.3rem;
    color: #003366;
    text-align: center;
}

.login-card p {
    margin-top: 0;
    margin-bottom: 14px;
    font-size: 0.9rem;
    color: #555;
    text-align: center;
}

.login-logo {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: #777;
    text-transform: uppercase;
    margin-bottom: 8px;
    border-bottom: 2px solid #ffd54f;
    padding-bottom: 4px;
    text-align: center;
}

.login-error {
    color: #b00020;
    font-size: 0.85rem;
    margin-bottom: 10px;
    text-align: center;
}

/* Pola logowania i przyciski – wygodne na telefonach */
.login-card label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    margin-top: 4px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 1rem;
}

.login-card button,
.login-card input[type="submit"] {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border-radius: 6px;
}

/* Baner graficzny pod formularzem logowania/wylogowania */
.login-banner {
    display: block;
    width: 100%;
    max-width: 320px;      /* dopasowanie do szerokości login-card */
    margin: 16px auto 0 auto;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.25);
    object-fit: cover;
}

/* Obrazek pod formularzem, dopasowany do karty */
.login-illustration {
    margin-top: 10px;
    text-align: center;
}

.login-illustration img {
    max-width: 100%;
    height: auto;
    display: inline-block;
    border-radius: 4px;
}

/* RESPONSYWNOŚĆ – MOBILE (telefony / wąskie ekrany) */

@media (max-width: 768px) {

    .layout {
        flex-direction: column;
        min-height: auto;
    }

    /* SIDEBAR CAŁKOWICIE UKRYTY NA MOBILE */
    .sidebar {
        display: none;
        visibility: hidden;
        width: 0;
        padding: 0;
        margin: 0;
    }

    .content {
        padding: 10px 10px;
        width: 100%;
    }

    .card {
        padding: 10px 10px;
    }

    /* Formularze – pełna szerokość na telefonie */
    .card label {
        font-size: 0.9rem;
    }

    .card input[type="text"],
    .card input[type="password"],
    .card input[type="number"],
    .card select,
    .card textarea {
        max-width: 100%;
        width: 100%;
        font-size: 1rem;
    }

    .card button,
    .card input[type="submit"] {
        width: 100%;
        margin-top: 6px;
        font-size: 1rem;
    }

    /* Tabele – możliwość przewijania w poziomie */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        font-size: 0.8rem;
    }

    th, td {
        padding: 4px 5px;
        white-space: nowrap;
    }

    /* kalkulator – pełna szerokość na telefonie */
    .qty-calc-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .calc-container {
        display: block;
        max-width: 100%;
        margin-left: 0;
        margin-top: 8px;
    }

    .topbar {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
}

/* Ulepszenia na bardzo małych ekranach */
@media (max-width: 480px) {
    .login-page {
        padding: 8px;
    }

    .login-card {
        padding: 16px 14px;
        max-width: 100%;
        border-radius: 0; /* karta na całą szerokość */
    }

    .login-card h1 {
        font-size: 1.15rem;
    }
}
