/* 
 * style.css — Arkusz stylów dla modułu Zebra In (katalog/zebin)
 * Wersja: v1.8.0 (2026-09-25)
 * Formatowanie i hierarchia typograficzna w stylu katalog/stare
 */

:root {
    --bg-page: #f9fafb;
    --bg-card: #ffffff;
    --bg-secondary: #f3f4f6;
    --border-color: #e5e7eb;
    --border-subtle: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --color-primary: #0284c7;
    --color-primary-hover: #0369a1;
    --color-primary-light: #e0f2fe;
    --color-success: #15803d;
    --color-success-light: #dcfce7;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.6rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.logo-icon {
    color: var(--color-primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    font-size: 0.725rem;
    font-weight: 500;
    border-radius: 4px;
}

.badge-subtle {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}

.badge-success {
    background-color: var(--color-success-light);
    color: var(--color-success);
}

/* Search bar */
.search-bar {
    flex: 1;
    max-width: 380px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.45rem 2rem 0.45rem 2.1rem;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    color: var(--text-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.search-clear {
    position: absolute;
    right: 0.6rem;
    background: none;
    border: none;
    font-size: 1.15rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* Header actions & stats */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.stats-badge {
    font-size: 0.775rem;
    color: var(--text-secondary);
    background: #f3f4f6;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.1s ease;
}

.btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-outline {
    background-color: #ffffff;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

.btn-secondary {
    background-color: #1e293b;
    color: #ffffff;
}
.btn-secondary:hover {
    background-color: #0f172a;
}

.btn-ghost {
    background: none;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background-color: #f3f4f6;
}

.btn-sm {
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
}

/* Main Container */
.main-container {
    max-width: 1400px;
    margin: 1rem auto;
    padding: 0 1rem;
}

/* Card */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-title h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.775rem;
    color: var(--text-secondary);
}

.filter-date {
    padding: 0.25rem 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.775rem;
}

/* Filtr uniwersalny (kombinacje substringów) — w tej samej linii co daty */
.filter-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 340px;
}

.filter-search-icon {
    position: absolute;
    left: 0.5rem;
    color: var(--text-muted);
    pointer-events: none;
}

.filter-search {
    width: 100%;
    padding: 0.25rem 1.6rem 0.25rem 1.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.775rem;
    color: var(--text-primary);
    background: #ffffff;
}

.filter-search:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.filter-search-clear {
    position: absolute;
    right: 0.35rem;
    background: none;
    border: none;
    font-size: 1.05rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}

/* Tabela główna — wzorowana na katalog/stare */
.table-responsive {
    overflow-x: auto;
}

/* Wszystkie tabele: nagłówek przyklejony, nie chowa się przy przewijaniu */
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: #f9fafb;
    box-shadow: inset 0 -1px 0 var(--border-color);
}

/* Przewijana tabela z przyklejonym nagłówkiem (modal dostawy) */
.table-scroll {
    overflow: auto;
}

/* Główna lista dostaw — własny obszar przewijania, żeby nagłówek został pod belką */
.table-scroll-main {
    max-height: calc(100vh - 185px);
    overflow: auto;
}

/* Podświetlenie wyszukiwanych substringów — oczojebny cyan */
mark.hl {
    background-color: #00ffff !important;
    color: #000000 !important;
    padding: 0 1px;
    border-radius: 2px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Tracking: możliwość zaznaczenia tekstu + przycisk kopiowania */
.tracking-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tracking-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    color: var(--text-secondary);
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

.selectable {
    user-select: text;
    -webkit-user-select: text;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 4px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-copy:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.btn-copy.copied {
    color: var(--color-success);
    border-color: var(--color-success);
    background: var(--color-success-light);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.data-table th {
    background-color: #f9fafb;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.725rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.45rem 0.65rem;
    border-bottom: 2px solid #000000;
    white-space: nowrap;
}

.data-table td {
    padding: 5px 0.65rem; /* pion zredukowany o ~2px (było 0.45rem ≈ 7.2px) */
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
    white-space: nowrap;
}

/* Kolumny */
.th-toggle { width: 28px; padding: 0.45rem 0.2rem !important; }
.th-delivery { width: 130px; }
.th-wyslano { width: 85px; }
.th-kurier { width: 85px; }
.th-typ { width: 85px; }
.th-lpn { width: 65px; }
.th-kartony { width: 75px; }
.th-pozycji { width: 65px; }
.th-sztuk { width: 85px; }
.th-serials { width: 105px; }
.th-akcje { width: 100px; }

.pkg-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    font-size: 0.725rem;
    font-weight: 600;
    text-transform: uppercase;
}

.pkg-pallet {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.pkg-carton {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.data-table tbody tr:nth-child(even) {
    background-color: var(--bg-secondary);
}

.data-table tbody tr:hover {
    background-color: #e5e7eb;
    cursor: pointer;
}

.row-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.row-toggle-btn.expanded {
    transform: rotate(90deg);
}

.expanded-row-container {
    background-color: #ffffff;
    padding: 0.75rem 1rem 0.75rem 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.lpn-box {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 6px;
}

.lpn-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.775rem;
}

.lpn-header-left {
    display: flex;
    align-items: center;
}

.lpn-header-gap {
    width: 28px;
    display: inline-block;
}

.btn-print-lpn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 3px 6px;
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.725rem;
    transition: all 0.15s ease;
}

.btn-print-lpn:hover {
    background-color: #f1f5f9;
    color: var(--color-primary);
    border-color: #cbd5e1;
}

.lpn-items-table {
    display: table;
    table-layout: fixed;
    width: auto;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-family: inherit;
}

.lpn-item-row {
    display: table-row;
    line-height: 1.6;
}

.lpn-item-row {
    cursor: pointer;
    user-select: none;
}

.lpn-item-row:hover {
    background-color: #f0f9ff;
}

.lpn-item-row.selected {
    background-color: #dbeafe;
    box-shadow: inset 3px 0 0 var(--color-primary);
}

.lpn-bullet-col {
    display: table-cell;
    width: 16px;
    color: var(--text-muted);
    vertical-align: middle;
    text-align: center;
}

.lpn-part-col {
    display: table-cell;
    width: 250px; /* Sztywna, stała szerokość kolumny Part Number dla każdej dostawy */
    font-weight: 600;
    color: var(--text-primary);
    vertical-align: middle;
    padding-right: 12px;
    white-space: nowrap;
}

.lpn-qty-col {
    display: table-cell;
    text-align: right;
    width: 75px; /* Sztywna, stała szerokość kolumny ilości/SN */
    vertical-align: middle;
    padding-right: 20px;
    white-space: nowrap;
}

.lpn-po-col {
    display: table-cell;
    color: var(--text-muted);
    font-size: 0.75rem;
    vertical-align: middle;
    white-space: nowrap;
}

.sn-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-success-light);
    color: var(--color-success);
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    border: 1px solid #bbf7d0;
}

.qty-plain {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.po-tag {
    font-family: monospace;
    font-size: 0.75rem;
    color: #4b5563;
    background: #f3f4f6;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    margin-right: 4px;
}

.code-badge {
    font-family: monospace;
    font-size: 0.775rem;
    font-weight: 600;
    background-color: #e2e8f0;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    color: #0f172a;
}

.carrier-tag {
    font-weight: 600;
    font-size: 0.75rem;
    color: #1e293b;
    text-transform: uppercase;
}

.lpn-tag {
    display: inline-flex;
    padding: 0.15rem 0.4rem;
    background: #e2e8f0;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-dialog {
    position: relative;
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
}

.modal-xl { max-width: 1050px; }
.modal-lg { max-width: 780px; }

.modal-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.35rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 0.5rem;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

/* Upload dropzone */
.upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-sm);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    background: #f9fafb;
}

.upload-dropzone:hover {
    border-color: var(--color-primary);
    background-color: var(--color-primary-light);
}

.upload-status {
    margin-top: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.upload-status.success {
    background-color: var(--color-success-light);
    color: #15803d;
}

.upload-status.error {
    background-color: #fee2e2;
    color: #b91c1c;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-xs { font-size: 0.7rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-4 { margin-bottom: 0.75rem; }
.py-8 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.hidden { display: none !important; }

/* ─── STYLE DLA WYDRUKU (ZMNIEJSZONA CZCIONKA) ───────── */
.print-only {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }
    .print-only, .print-only * {
        visibility: visible;
    }
    .print-only {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 10px;
        background: #ffffff;
        color: #000000;
        font-family: Arial, sans-serif;
        font-size: 8pt; /* Zmniejszona czcionka */
        line-height: 1.25;
    }

    .print-header {
        border-bottom: 1.5px solid #000000;
        padding-bottom: 6px;
        margin-bottom: 8px;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
    }

    .print-title {
        font-size: 13pt;
        font-weight: bold;
    }

    /* Trzy linie informacyjne o nośniku (LPN) — na lekko szarym tle */
    .print-lpn-info {
        background-color: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        padding: 5px 10px;
        border-radius: 3px;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 8px;
    }

    .print-table th, .print-table td {
        border: 1px solid #444;
        padding: 4px 6px;
        font-size: 7.5pt;
        vertical-align: top;
    }

    .print-table th {
        background-color: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-weight: bold;
        text-transform: uppercase;
    }

    /* Gruba linia oddzielająca kolejne artykuły */
    .print-part-row > td {
        border-top: 2.5px solid #000000 !important;
    }

    .print-table tr:first-child.print-part-row > td {
        border-top: 1px solid #444 !important;
    }

    /* Kolejne nośniki LPN na wydruku — bez nowej strony, tylko odstęp (2-3 linie) */
    .print-lpn-section {
        page-break-inside: auto;
    }

    /* Układ sekcji numerów seryjnych w 3 kolumnach: numer i kod obok siebie, spora przerwa */
    .print-sn-row-cell {
        background-color: #fafafa;
        padding: 6px 10px !important;
        border-top: 1px dashed #777 !important;
        border-bottom: 2.5px solid #000000 !important;
    }

    .print-sn-grid-3 {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        column-gap: 24px; /* Spora przerwa pomiędzy 3 kolumnami */
        row-gap: 6px;
        margin-top: 5px;
    }

    .print-sn-chip {
        display: flex;
        flex-direction: row; /* Numer i kod kreskowy OBOK siebie */
        align-items: center;
        justify-content: flex-start;
        border: 1px solid #777;
        padding: 3px 8px;
        background: #ffffff;
        page-break-inside: avoid;
        gap: 8px; /* Odstęp pomiędzy numerem a kodem */
        min-width: 0; /* pozwala komórce siatki się zwęzić, zamiast wypychać układ */
        overflow: hidden;
        box-sizing: border-box;
    }

    /* Kod w chipsie nigdy nie wychodzi poza komórkę */
    .print-sn-chip svg {
        max-width: 100%;
        height: auto;
        flex: 0 1 auto;
    }

    /* Kody kreskowe (JsBarcode) — nie rozciągają się, stała wysokość */
    .jsbarcode-item,
    .jsbarcode-qty,
    .jsbarcode-po,
    .jsbarcode-sn,
    .jsbarcode-lpn {
        display: inline-block;
        vertical-align: middle;
    }

    .print-sn-text {
        font-size: 7.5pt;
        font-family: monospace;
        font-weight: bold;
        white-space: nowrap;
    }

    .print-sn-barcode {
        height: 20px;
        display: inline-block;
        flex: 1;
        max-width: 130px;
    }

    .print-po-item {
        margin-bottom: 4px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
}
