@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-dark: #0f172a;       
    --primary-light: #1e293b;      
    --accent: #3b82f6;             
    --accent-hover: #2563eb;       
    --bg-body: #f1f5f9;            
    --bg-card: #ffffff;            
    --text-main: #1e293b;          
    --text-muted: #64748b;         
    --border: #e2e8f0;             
    --danger-bg: #fef2f2; --danger-text: #ef4444; --danger-border: #fecaca;
    --warning-bg: #fffbeb; --warning-text: #d97706; --warning-border: #fcd34d;
    --success-bg: #f0fdf4; --success-text: #16a34a; --success-border: #bbf7d0;
}

* { box-sizing: border-box; }

body { 
    margin: 0; padding: 0; 
    font-family: 'Inter', sans-serif; 
    height: 100vh; 
    overflow: hidden; /* Ukrywamy paski przeglądarki, przewijamy wewnątrz kontenerów */
    background-color: var(--bg-body); 
    color: var(--text-main);
}

/* ========================================= */
/* --- UKŁAD GŁÓWNY (SIDEBAR + CONTENT) --- */
/* ========================================= */

.app-container { display: flex; width: 100%; height: 100%; }

/* --- SIDEBAR (NAPRAWIONY + KOMPAKTOWY) --- */
.sidebar { 
    width: 260px; /* Trochę węższy */
    background-color: var(--primary-dark); 
    color: white; 
    display: flex; 
    flex-direction: column; 
    padding: 15px; /* Mniejszy padding ogólny */
    flex-shrink: 0; 
    box-shadow: 4px 0 24px rgba(0,0,0,0.05);
    z-index: 100;
    
    /* FIX: Niezależne przewijanie menu */
    height: 100vh;
    overflow-y: auto; 
    overflow-x: hidden;
}

/* Estetyczny, cienki suwak dla menu */
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

.brand { 
    font-size: 22px; font-weight: 800; margin-bottom: 25px; /* Mniejszy odstęp */
    color: white; text-decoration: none; display: flex; 
    align-items: center; gap: 10px; letter-spacing: -0.5px;
    flex-shrink: 0; 
    padding-left: 5px;
}

.menu-category {
    font-size: 10px; text-transform: uppercase; color: #64748b; 
    margin-top: 15px; margin-bottom: 5px; /* Mniejsze odstępy kategorii */
    font-weight: 700; letter-spacing: 0.5px; padding-left: 10px; 
}

.menu-item { 
    padding: 10px 12px; /* Mniejsze kafelki menu */
    color: #94a3b8; text-decoration: none; 
    border-radius: 8px; display: flex; align-items: center; gap: 12px; 
    font-size: 14px; /* Mniejsza czcionka */
    font-weight: 500; transition: all 0.2s; margin-bottom: 2px;
    flex-shrink: 0;
}
.menu-item:hover { background: rgba(255,255,255,0.08); color: white; transform: translateX(3px); }
.menu-item.active { background: var(--accent); color: white; font-weight: 600; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4); }
.menu-icon { font-size: 16px; width: 20px; text-align: center; }

.user-profile { 
    margin-top: auto; /* Dopycha do dołu */
    padding-top: 15px; 
    border-top: 1px solid rgba(255,255,255,0.1); 
    display: flex; align-items: center; gap: 10px; 
    flex-shrink: 0;
    padding-bottom: 10px;
}
.avatar { 
    width: 38px; height: 38px; background: var(--accent); border-radius: 10px; 
    display: flex; align-items: center; justify-content: center; 
    font-weight: 700; color: white; font-size: 16px; 
}

/* --- MAIN CONTENT --- */
.main-content { 
    flex: 1; 
    overflow-y: auto; /* Przewijanie treści głównej */
    padding: 30px 40px; 
    background: var(--bg-body); 
    height: 100vh;
}

.header-section { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.page-title h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -1px; color: var(--text-main); }
.page-title p { margin: 5px 0 0 0; color: var(--text-muted); font-size: 14px; }

/* --- CARDS & GRID --- */
.card { 
    background: var(--bg-card); padding: 25px; border-radius: 12px; 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02), 0 2px 4px -1px rgba(0,0,0,0.02); 
    border: 1px solid var(--border); margin-bottom: 20px; transition: transform 0.2s;
}
.card:hover { border-color: #cbd5e1; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05); }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 30px; }

/* --- FORMS --- */
label { display: block; font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; margin-top: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select { 
    width: 100%; padding: 12px 14px; border: 1px solid var(--border); 
    border-radius: 8px; font-size: 14px; background: #f8fafc; 
    transition: all 0.2s ease; color: var(--text-main); box-sizing: border-box;
}
input:focus { border-color: var(--accent); outline: none; background: #fff; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }
input.pin-input { font-size: 32px; letter-spacing: 10px; text-align: center; font-family: monospace; font-weight: bold; background: white; }

/* --- BUTTONS --- */
.btn { 
    border: none; border-radius: 8px; padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer; 
    transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn-primary { background: var(--primary-dark); color: white; box-shadow: 0 4px 6px rgba(15, 23, 42, 0.1); }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-2px); }
.btn-small { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn-test { background: #e0f2fe; color: #0284c7; border: 1px solid #bae6fd; }
.btn-test:hover { background: #bae6fd; }
.btn-delete { color: #ef4444; text-decoration: none; font-weight: 600; padding: 6px 10px; font-size: 13px; }
.btn-delete:hover { background: #fef2f2; border-radius: 6px; }

/* --- TABLES --- */
table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 10px; }
th { text-align: left; color: var(--text-muted); padding: 14px; border-bottom: 2px solid var(--border); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; background: #fdfdfd; }
td { padding: 14px; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; font-size: 14px; }
tr:hover td { background: #f8fafc; }

.badge { padding: 5px 8px; border-radius: 6px; font-family: 'Monaco', monospace; font-weight: 600; font-size: 12px; border: 1px solid transparent; }
.badge-gray { background: #f1f5f9; color: var(--text-main); border-color: #cbd5e1; }
.badge-blue { background: #e0f2fe; color: #0284c7; border-color: #bae6fd; }

/* --- LOGIN SCREEN --- */
.split-screen { display: flex; height: 100vh; width: 100%; }
.left-panel { flex: 1; background-color: var(--primary-dark); color: white; display: flex; flex-direction: column; justify-content: center; padding: 80px; position: relative; overflow: hidden; }
.left-panel::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 60%); animation: pulse 10s infinite; }
.right-panel { flex: 1; background: white; display: flex; justify-content: center; align-items: center; }
.auth-box { width: 100%; max-width: 400px; padding: 30px; }
.logo-text { font-size: 22px; font-weight: 800; color: var(--primary-dark); margin-bottom: 30px; display: block; text-decoration: none; }
.logo-text span { color: var(--accent); }
.tabs { display: flex; margin-bottom: 25px; border-bottom: 2px solid var(--border); }
.tab { flex: 1; padding: 12px; cursor: pointer; text-align: center; font-weight: 600; color: var(--text-muted); transition: 0.2s; font-size: 14px; }
.tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); margin-bottom: -2px; }
.hidden { display: none; }

.alert { padding: 14px; border-radius: 10px; margin-bottom: 20px; border: 1px solid transparent; font-size: 13px; }
.alert.error { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.alert.success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }

/* --- DELIVERY GRID --- */
.delivery-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 5px; }
.delivery-card { cursor: pointer; position: relative; }
.delivery-card input { position: absolute; opacity: 0; cursor: pointer; }
.card-content { display: flex; align-items: center; padding: 12px; border: 2px solid #e2e8f0; border-radius: 8px; background: white; transition: all 0.2s; }
.card-content .icon { font-size: 20px; margin-right: 12px; }
.card-content .details { display: flex; flex-direction: column; }
.card-content .title { font-weight: 700; font-size: 13px; color: #334155; }
.card-content .price { font-size: 11px; color: #166534; font-weight: 600; }
.delivery-card input:checked + .card-content { border-color: #166534; background-color: #f0fdf4; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }

@media (min-width: 768px) { .delivery-grid { grid-template-columns: 1fr 1fr; } }

.delivery-card:active .card-content { transform: scale(0.95); background-color: #f0fdf4; border-color: #166534; }
.delivery-grid:has(input:checked) .delivery-card { transition: all 0.3s ease; }
.delivery-grid:has(input:checked) .delivery-card:not(:has(input:checked)) .card-content { opacity: 0.5; filter: grayscale(100%); background-color: #f8fafc; border-color: #e2e8f0; }
.delivery-grid .delivery-card input:checked + .card-content { opacity: 1 !important; filter: none !important; transform: scale(1.02); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); z-index: 10; }

/* ========================================================= */
/* --- RESPONSYWNOŚĆ (TABLETY I TELEFONY) --- */
/* ========================================================= */

/* Hamburger siedzi w LEWYM gornym rogu — prawy nalezy do dzwonka
   powiadomien (#pw-dzwonek w base.html, top/right 14px). Nie przenosic
   go na prawo, bo przyciski naloza sie na siebie na telefonie. */
.mobile-nav-toggle {
    display: none;
    position: fixed; top: 14px; left: 14px; right: auto; z-index: 9999;
    background: #1e293b; color: white; border: none;
    width: 46px; height: 46px; padding: 0;
    align-items: center; justify-content: center; line-height: 1;
    border-radius: 12px; cursor: pointer; font-size: 22px; box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 8000; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* Breakpoint dla tabletów i telefonów */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%); transition: transform 0.3s ease-in-out;
        z-index: 9000; width: 260px; height: 100vh; box-shadow: 5px 0 15px rgba(0,0,0,0.2);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; padding: 60px 15px 15px 15px; width: 100%; }
    .mobile-nav-toggle { display: inline-flex; }
    /* ten sam skok rozmiaru co #pw-dzwonek w base.html */
    @media (max-width: 600px) { .mobile-nav-toggle { width: 42px; height: 42px; top: 10px; left: 10px; } }
    body.nav-open .mobile-nav-toggle { display: none; }
    .cards-grid, .grid-container, .dashboard-stats, .pallet-grid { grid-template-columns: 1fr !important; }
    
    .table-responsive { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 20px; }
    table { font-size: 13px; min-width: 600px; }
    th, td { padding: 10px 8px; }
    
    .header-section { flex-direction: column; align-items: flex-start; gap: 10px; }
    .header-section .btn { width: 100%; }
    
    .split-screen { flex-direction: column; height: auto; min-height: 100vh; }
    .left-panel { display: none; }
    .right-panel { padding: 20px; }
}