* { box-sizing: border-box; }
body { font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; margin: 30px; background: #f5f5f5; color: #333; }
.container { max-width: 1200px; margin: auto; background: white; padding: 25px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
h2 { color: #333; margin-bottom: 20px; }

/* Topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid #eee; flex-wrap: wrap; gap: 10px; }
.topbar-left { display: flex; align-items: center; gap: 15px; }
.topbar-right { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.btn-small { 
    padding: 6px 14px; 
    border: none; 
    border-radius: 6px; 
    font-size: 12px; 
    cursor: pointer; 
    text-decoration: none; 
    display: inline-block; 
    font-weight: 500; 
}
.btn-small:hover { opacity: 0.85; }
.btn-refresh, .btn-logout { background: white; color: #333; border: 1px solid #999;}
.cache-info { font-size: 11px; color: #999; }

/* Alert */
.alert { padding: 15px 20px; border-radius: 8px; margin-bottom: 20px; font-weight: 500; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Filtry */
.filters-panel { background: #f8f9fa; padding: 20px; border-radius: 8px; margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 15px; align-items: center; }
.search-box { flex: 1; min-width: 240px; }
.search-box input { width: 100%; padding: 12px 15px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.search-box input:focus { outline: none; border-color: #28a745; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group label { font-size: 13px; color: #555; font-weight: 500; }
.filter-group select { padding: 10px 15px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; background: white; cursor: pointer; }
.filter-group select:focus { outline: none; border-color: #28a745; }
.checkbox-wrapper { display: flex; align-items: center; gap: 10px; padding: 10px 15px; background: white; border-radius: 6px; border: 1px solid #ddd; cursor: pointer; }
.checkbox-wrapper:hover { background: #f0f0f0; }
.checkbox-wrapper input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }
.checkbox-wrapper label { cursor: pointer; margin: 0; }
.results-info { color: #666; font-size: 13px; margin-left: auto; padding: 10px 15px; background: #e9ecef; border-radius: 6px; }

/* Tabela */
table { width: 100%; border-collapse: collapse; margin-bottom: 100px; }
th { background: #343a40; color: white; text-align: left; padding: 14px 12px; font-size: 12px; cursor: pointer; }
th:hover { background: #495057; }
td { padding: 14px 12px; border-bottom: 1px solid #eee; }
tbody tr:hover { background: #f8f9fa; }

/* Zaznaczony wiersz w koszyku */
#productsBody tr.selected { background-color: #f0fff4 !important; }

/* Produkt */
.prod-info { font-size: 14px; font-weight: 600; color: #0056b3; margin-bottom: 4px; }
.prod-meta { font-size: 11px; color: #999; }
.stock-tag { background: #28a745; color: white; padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; display: inline-block; }
.stock-tag.zero { background: #dc3545; }
.price-tag { font-weight: bold; color: #28a745; font-size: 15px; }

/* Formularz klienta */
.client-header { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.client-header input { flex: 1; min-width: 200px; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.client-header input:focus { outline: none; border-color: #28a745; }

/* Kolumna Zamów */
.qty-wrapper { display: flex; align-items: center; justify-content: center; gap: 6px; }

.qty-input {
    width: 60px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
}
.qty-input:focus { outline: none; border-color: #28a745; }

.btn-add-cart {
    width: 38px;
    height: 38px;
    border: 2px solid #28a745;
    border-radius: 8px;
    background: #f0fff4;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.1s ease, background-color 0.1s ease;
}
.btn-add-cart:hover { 
    background: #d4edda; 
}
.btn-add-cart:active,
.btn-add-cart.clicked { 
    transform: scale(0.85); 
    background: #28a745;
}

/* Ukryj badge - już niepotrzebny */
.added-badge {
    display: none !important;
}

.no-stock { color: #999; }

/* Koszyk floating */
.floating-action { position: fixed; bottom: 30px; right: 50px; z-index: 1000; text-align: right; }

.cart-summary {
    display: none;
    background: #333;
    color: white;
    padding: 14px 28px;
    border-radius: 25px;
    margin-bottom: 10px;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.cart-summary .cart-icon { font-size: 18px; margin-right: 8px; }
.cart-summary .cart-items { color: #ffc107; font-weight: bold; font-size: 16px; }
.cart-summary .cart-price { color: #28a745; font-weight: bold; font-size: 16px; }
.cart-summary .cart-divider { color: #666; margin: 0 10px; }

.submit-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 16px 40px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(40,167,69,0.4);
}
.submit-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(40,167,69,0.5); }
.submit-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; box-shadow: none; }

/* Brak wyników */
.no-results { text-align: center; padding: 40px; color: #666; font-size: 16px; display: none; }

/* Responsywność */
@media (max-width: 768px) {
    body { margin: 15px; }
    .container { padding: 15px; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .filters-panel { flex-direction: column; align-items: stretch; }
    .search-box { min-width: 100%; }
    .results-info { margin-left: 0; text-align: center; }
    .floating-action { bottom: 20px; right: 20px; left: 20px; text-align: center; }
    .submit-btn { width: 100%; border-radius: 25px; }
    .cart-summary { width: 100%; text-align: center; }
    .client-header { flex-direction: column; }
    .client-header input { min-width: 100%; }
    table { font-size: 12px; }
    th, td { padding: 10px 8px; }
}

/* Info o zalogowanym użytkowniku */
.logged-user-info {
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #333;
    padding: 20px 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
}

.logged-user-avatar {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
}

.logged-user-details {
    flex: 1;
}

.logged-user-name {
    font-size: 20px;
    font-weight: bold;
    text-transform: capitalize;
}

.logged-user-address {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 6px;
}

.logged-user-contact {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
}

.logged-user-extra {
    text-align: right;
    border-left: 1px solid #ccc;
    padding-left: 20px;
}

.logged-user-nip,
.logged-user-client-id {
    font-size: 13px;
    color: #444;
    margin-bottom: 5px;
}

.logged-user-nip strong,
.logged-user-client-id strong {
    color: #222;
}


.btn-clear {
    background: #6c757d;
    color: white;
}

.btn-clear:hover {
    background: #5a6268;
}

/** PAGINACJA GORA - zakomentowana w index.php**/
.pagination-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
}

.pagination-info button:disabled {
    background: #ccc !important;
    cursor: not-allowed;
}

.pagination-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 100px;
}

.pagination-bottom button:disabled {
    background: #ccc !important;
    cursor: not-allowed;
}

.filters-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
}

@media (max-width: 1200px) {
    .filters-row {
        flex-wrap: wrap;
    }
}

.btn-icon {
    width: 42px;
    height: 42px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    border-color: #0077da;
    background: #e6f2ff;
}

.btn-icon.active {
    background: #0077da;
    border-color: #0077da;
    color: white;
}

.btn-icon-danger:hover {
    border-color: #dc3545;
    background: #ffe6e6;
}

.site-footer {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 13px;
    border-top: 1px solid #eee;
    margin-top: 20px;
}

.footer-link-gray {
    color: #666;
    text-decoration: none;
}

.footer-link-gray:hover {
    text-decoration: underline;
}

.footer-link-blue {
    color: #1D438A;
    text-decoration: none;
}

.footer-link-blue:hover {
    text-decoration: underline;
}

/* ===== WERSJA MOBILNA ===== */
@media (max-width: 768px) {
    body { 
        margin: 10px; 
    }
    
    .container {
        padding: 10px;
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    table {
        table-layout: fixed;
        width: 100%;
        word-wrap: break-word;
    }
    
    /* Topbar */
    .topbar { 
        flex-direction: column; 
        align-items: stretch;
        gap: 10px;
    }
    
    .topbar-left { 
        justify-content: center; 
    }
    
    .topbar-left h2 {
        font-size: 18px;
    }
    
    .topbar-right { 
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .topbar-right .btn-small {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .cache-info {
        display: none;
    }
    
    /* Panel użytkownika */
    .logged-user-info {
        flex-direction: column;
        text-align: center;
        padding: 15px;
        gap: 10px;
    }
    
    .logged-user-extra {
        border-left: none;
        border-top: 1px solid #ccc;
        padding-left: 0;
        padding-top: 10px;
        text-align: center;
    }
    
    .logged-user-name {
        font-size: 16px;
    }
    
    /* Filtry */
    .filters-panel {
        padding: 10px;
        overflow: hidden;
    }
    
    .filters-row {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        max-width: 100%;
    }
    
    .filters-row .search-box {
        flex: 1 1 100%;
    }
    
    .filters-row .search-box input {
        width: 100%;
        padding: 8px 10px;
        font-size: 12px;
        box-sizing: border-box;
    }
    
    .filters-row select {
        flex: 1;
        min-width: 0;
        width: auto !important;
        font-size: 10px !important;
        padding: 6px 4px !important;
        box-sizing: border-box;
    }
    
    .filters-row label {
        font-size: 9px;
        padding: 6px 6px;
        background: white;
        border: 1px solid #ddd;
        border-radius: 6px;
        white-space: nowrap;
    }
    
    .filters-row label input {
        width: 12px !important;
        height: 12px !important;
    }
    
    #quickOrder {
        font-size: 9px !important;
        padding: 6px 6px !important;
        white-space: nowrap;
    }
    
    #clearFilters {
        font-size: 9px !important;
        padding: 6px 6px !important;
        white-space: nowrap;
    }
    
    /* Tabela */
    table {
        font-size: 12px;
        margin-bottom: 80px;
    }
    
    th, td {
        padding: 8px 5px;
    }
    
    th {
        font-size: 10px;
    }
    
    .prod-info {
        font-size: 12px;
    }
    
    .prod-meta {
        font-size: 9px;
        line-height: 1.4;
    }
    
    .stock-tag {
        padding: 3px 8px;
        font-size: 10px;
    }
    
    .price-tag {
        font-size: 12px;
    }
    
    .qty-wrapper {
        flex-direction: column;
        gap: 4px;
    }
    
    .qty-input {
        width: 50px;
        padding: 6px;
        font-size: 12px;
    }
    
    .btn-add-cart {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .no-stock {
        font-size: 10px;
    }
    
    /* Paginacja */
    .pagination-bottom {
        padding: 15px;
        margin-bottom: 80px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .pagination-bottom button {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    #pageInfo {
        font-size: 12px;
        width: 100%;
        text-align: center;
        order: -1;
    }
    
    /* Koszyk floating - PŁYWAJĄCY */
    .floating-action {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 10px 15px;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.15);
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }
    
    .cart-summary {
        padding: 8px 12px;
        font-size: 11px;
        border-radius: 15px;
        margin-bottom: 0;
    }
    
    .submit-btn {
        padding: 12px 20px;
        font-size: 13px;
        border-radius: 25px;
        white-space: nowrap;
    }
    
    /* Modal szybkiego zamawiania */
    #quickOrderModal > div {
        margin: 15px;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    #quickOrderModal h3 {
        font-size: 16px;
    }
    
    #quickOrderModal textarea {
        font-size: 12px;
    }
    
    #quickOrderModal button {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    /* Stopka */
    .site-footer {
        font-size: 11px;
        padding: 15px 10px;
        line-height: 1.6;
        margin-bottom: 70px;
    }
}

/* ===== BARDZO MAŁE EKRANY ===== */
@media (max-width: 480px) {
    .topbar-left h2 {
        font-size: 16px;
    }
    
    .logged-user-avatar {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .logged-user-name {
        font-size: 14px;
    }
    
    .logged-user-address,
    .logged-user-contact {
        font-size: 11px;
    }
    
    .prod-meta {
        font-size: 8px;
    }
    
    th:nth-child(2),
    td:nth-child(2) {
        width: 50px;
    }
    
    th:nth-child(3),
    td:nth-child(3) {
        width: 60px;
    }
    
    .submit-btn {
        padding: 10px 15px;
        font-size: 12px;
    }
}