/* =========================================
   1. RESET I ZMIENNE
   ========================================= */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg-body: #F2F2F7;
    --bg-surface: #FFFFFF;
    --text-primary: #1C1C1E;
    --text-secondary: #8E8E93;
    --accent-blue: #0071E3;
    --accent-orange: #FF9500;
    --border: #D1D1D6;
    --radius: 12px;
}

body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Helvetica, sans-serif;
    background-color: var(--bg-body); color: var(--text-primary);
    height: 100vh; overflow: hidden; display: grid;
    grid-template-columns: 1fr 420px;
}

/* =========================================
   2. LEWA KOLUMNA (MENU)
   ========================================= */
.col-menu {
    overflow-y: auto; padding: 0 30px 100px 30px; /* Więcej paddingu na dole */
    border-right: 1px solid var(--border); position: relative; height: 100vh;
}

.top-bar {
    position: sticky; top: 0; background: rgba(242, 242, 247, 0.95);
    backdrop-filter: blur(10px); z-index: 10; padding: 20px 0 15px 0;
    border-bottom: 1px solid #E5E5EA; display: flex; flex-direction: column; gap: 15px;
}
.top-row-controls { display: flex; justify-content: space-between; align-items: center; }

.date-nav { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.date-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--accent-blue); padding: 0 5px; }
.date-display { cursor: pointer; border-bottom: 1px dotted #999; }

.mode-switch { background: #E5E5EA; padding: 3px; border-radius: 8px; display: inline-flex; }
.mode-btn {
    border: none; background: transparent; padding: 6px 16px; border-radius: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-secondary); cursor: pointer;
}
.mode-btn.active { background: #FFFFFF; color: #000; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.mode-btn[data-mode="dom"].active { color: var(--accent-blue); }
.mode-btn[data-mode="kin"].active { color: var(--accent-orange); }

.search-container { width: 100%; position: relative; }
.search-input {
    width: 100%; padding: 12px 15px 12px 40px; border-radius: 10px; border: 1px solid #D1D1D6;
    background: #FFFFFF; font-size: 15px;
}
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #8E8E93; }

.category-section { margin-bottom: 20px; }
.section-header {
    font-size: 18px; font-weight: 700; padding: 12px 15px; background: #FFF; border-radius: 10px;
    cursor: pointer; display: flex; justify-content: space-between; margin-bottom: 10px;
}
.section-content { display: none; padding-top: 5px; }
.category-section.open .section-content { display: block; }
.arrow-icon { font-size: 12px; color: #999; transition: transform 0.2s; }
.category-section.open .arrow-icon { transform: rotate(180deg); }

.meals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; }

.card {
    background: var(--bg-surface); border-radius: var(--radius); padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); border: 2px solid transparent;
    cursor: pointer; transition: transform 0.1s; display: flex; flex-direction: column;
    min-height: 150px; position: relative; justify-content: space-between;
}
.card.sel-dom { border-color: var(--accent-blue); background: #F0F8FF; }
.card.sel-kin { border-color: var(--accent-orange); background: #FFF5E0; }
.card.sel-both { border-color: #333; }
.card.disabled { display: none; }

.card-name { font-size: 15px; font-weight: 700; line-height: 1.3; margin-bottom: 10px; }
.card-kcal { font-size: 18px; font-weight: 800; margin-bottom: 5px; }
.card-macros { display: flex; gap: 5px; }
.pill { font-size: 11px; padding: 3px 6px; background: #F2F2F7; border-radius: 4px; display: flex; gap: 3px; align-items: center; font-weight: 600; color: #555; }
.p-dot { width: 6px; height: 6px; border-radius: 50%; }
.ind-wrapper { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }
.ind { width: 8px; height: 8px; border-radius: 50%; display: none; }
.card.sel-dom .ind.d { display: block; background: var(--accent-blue); }
.card.sel-kin .ind.k { display: block; background: var(--accent-orange); }
.card.sel-both .ind { display: block; }
.card.sel-both .ind.d { background: var(--accent-blue); }
.card.sel-both .ind.k { background: var(--accent-orange); }

/* =========================================
   3. PRAWA KOLUMNA (KOSZYK - DESKTOP)
   ========================================= */
.col-cart {
    background: var(--bg-surface); display: flex; flex-direction: column; height: 100vh;
    border-left: 1px solid var(--border); box-shadow: -5px 0 20px rgba(0,0,0,0.03);
    position: relative; z-index: 20; width: 100%;
}
.cart-header { padding: 20px; border-bottom: 1px solid #E5E5EA; background: #FAFAFA; }
.pg-group { margin-bottom: 8px; }
.pg-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.pg-track { height: 8px; background: #E5E5EA; border-radius: 4px; overflow: hidden; }
.pg-fill { height: 100%; transition: width 0.3s; }
.cart-content { flex: 1; overflow-y: auto; padding: 15px; }
.cart-item { padding: 10px; border: 1px solid #F0F0F0; border-radius: 10px; margin-bottom: 8px; background: #FFF; }
.ci-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.ci-name { font-weight: 700; font-size: 14px; }
.ci-remove { border: none; background: none; font-size: 18px; color: #CCC; cursor: pointer; padding: 5px; }
.ci-remove:hover { color: red; }
.ci-badges { display: inline-flex; gap: 3px; margin-left: 5px; }
.bdg { font-size: 10px; padding: 2px 5px; border-radius: 3px; color: white; font-weight: 700; }
.bg-d { background: var(--accent-blue); } .bg-k { background: var(--accent-orange); }
.ci-tbl { width: 100%; font-size: 12px; border-collapse: collapse; }
.ci-tbl td { padding: 2px 0; border-bottom: 1px dashed #EEE; }
.t-d { color: var(--accent-blue); } .t-k { color: var(--accent-orange); }
.cart-footer { padding: 20px; border-top: 1px solid #E5E5EA; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: #FAFAFA; }
.btn { padding: 12px; border: none; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 13px; }
.btn-dark { background: #1C1C1E; color: white; }
.btn-light { background: #FFF; border: 1px solid #CCC; color: black; }

/* Ukryte na Desktopie */
.mobile-bar, .close-cart-btn, .cart-overlay { display: none !important; }

/* =========================================
   4. RWD - WERSJA MOBILNA (POPRAWIONA)
   ========================================= */
@media (max-width: 900px) {
    body { display: block; overflow-y: auto; height: auto; padding-bottom: 100px; }
    
    .col-menu { width: 100%; height: auto; border-right: none; padding: 15px; overflow: visible; }
    .top-bar { position: static; padding-bottom: 10px; }
    
    .search-input { font-size: 16px; } /* Żeby iPhone nie zoomował przy pisaniu */

    /* KOSZYK JAKO PEŁNY EKRAN (FULL SCREEN MODAL) */
    .col-cart {
        display: none; /* Domyślnie ukryty */
        position: fixed;
        top: 0; left: 0;
        width: 100%; height: 100%; /* Pełny ekran */
        background: white;
        z-index: 5000; /* Najwyższy możliwy */
        border: none;
        box-shadow: none;
        /* Ważne dla scrollowania wewnątrz modala */
        overflow: hidden; 
    }
    
    /* Klasa dodawana przez JS, żeby pokazać koszyk */
    .col-cart.mobile-visible {
        display: flex !important;
    }

    /* PASEK MOBILNY (Fixed bottom) */
    .mobile-bar {
        display: flex !important;
        position: fixed; bottom: 20px; left: 5%; width: 90%;
        background: #1C1C1E; color: white;
        padding: 15px 20px; border-radius: 16px;
        justify-content: space-between; align-items: center;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3);
        z-index: 1000; 
        cursor: pointer;
    }
    .mb-info { font-size: 12px; display: flex; flex-direction: column; }
    .mb-kcal { font-size: 16px; font-weight: 700; }
    .mb-btn { background: white; color: black; padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 13px; }

    /* PRZYCISK ZAMKNIĘCIA (FIXED) */
    .close-cart-btn {
        display: flex !important;
        justify-content: center; align-items: center;
        position: fixed; /* FIXED = zawsze w tym samym miejscu ekranu */
        top: 20px; right: 20px;
        width: 44px; height: 44px;
        background: #F2F2F7; border: 1px solid #CCC;
        border-radius: 50%;
        font-size: 28px; color: #333; line-height: 1;
        z-index: 6000; /* Nad koszykiem */
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    /* Nagłówek w koszyku mobilnym */
    .cart-header {
        padding-top: 80px; /* Miejsce na przycisk X */
    }
}

/* =========================================
   5. PDF & DRUK
   ========================================= */
.pdf-mode {
    background: white !important;
    padding: 20px !important;
    width: 100% !important;
    font-family: Arial, sans-serif !important;
}
.pdf-mode .cart-item { padding: 5px 0 !important; margin-bottom: 5px !important; border-bottom: 1px solid #000 !important; background: none !important; border-radius: 0 !important; page-break-inside: avoid; }
.pdf-mode .ci-head { margin-bottom: 2px !important; }
.pdf-mode .ci-name { font-size: 11pt !important; font-weight: bold !important; color: #000 !important; }
.pdf-mode .ci-remove, .pdf-mode .ci-badges { display: none !important; }
.pdf-mode .print-layout { display: flex; gap: 15px; }
.pdf-mode .p-ing { width: 45%; font-size: 8pt !important; line-height: 1.2; }
.pdf-mode .p-ins { width: 55%; font-size: 8pt !important; text-align: justify; line-height: 1.2; }
.pdf-mode .ci-tbl td { padding: 1px 0 !important; border-bottom: 1px dotted #ccc !important; }
.pdf-mode .t-d, .pdf-mode .t-k { color: #000 !important; font-weight: normal !important; }

/* MODAL */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 7000; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: white; width: 500px; max-height: 80vh; border-radius: 16px; padding: 25px; display: flex; flex-direction: column; }
.shop-dates { display: flex; gap: 10px; margin-bottom: 15px; background: #F5F5F7; padding: 10px; border-radius: 8px; }
.date-input { border: 1px solid #CCC; padding: 8px; border-radius: 6px; flex: 1; }
.modal-body { overflow-y: auto; flex: 1; margin-bottom: 15px; }
.shop-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #EEE; }