/* ============================================
   ADMIN PANEL - Organic & Earthy Theme
   Kiedy Smieci - Administration Styles
   ============================================ */

/* CSS Variables - Light Mode */
:root {
    --bg-primary: #F9F7F2;
    --bg-card: #FFFFFF;
    --color-primary: #2E7D32;
    --text-primary: #37474F;
    --text-secondary: #607D8B;
    --text-muted: #90A4AE;
    --border-color: #EBE4D8;
}

/* CSS Variables - Dark Mode */
.dark {
    --bg-primary: #1A2E1A;
    --bg-card: #2D3F2D;
    --color-primary: #66BB6A;
    --text-primary: #F5F5F0;
    --text-secondary: #E8F5E9;
    --text-muted: #A5D6A7;
    --border-color: #3D5A3D;
}

/* Auto Dark Mode - respects system preference (WCAG 2.1 AAA) */
@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        --bg-primary: #1A2E1A;
        --bg-card: #2D3F2D;
        --color-primary: #66BB6A;
        --text-primary: #F5F5F0;
        --text-secondary: #E8F5E9;
        --text-muted: #A5D6A7;
        --border-color: #3D5A3D;
    }
}

/* Focus-visible for accessibility (WCAG 2.1 AA) */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Accessibility - Reduced Motion (WCAG 2.1 AAA) */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Mobile inputs - minimum 16px font to prevent iOS zoom */
@media (max-width: 768px) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Base Typography */
body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* iOS Blur Effect */
.ios-blur {
    background: rgba(249, 247, 242, 0.9);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.dark .ios-blur {
    background: rgba(26, 46, 26, 0.9);
}

/* iOS Card Style */
.ios-card {
    background: var(--bg-card);
    border-radius: 1rem;
    box-shadow: 0 4px 20px -2px rgba(46, 125, 50, 0.08);
    border: 1px solid var(--border-color);
}
.dark .ios-card {
    background: var(--bg-card);
}

/* Calendar Day Cell */
.day-cell {
    min-height: 52px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    border-radius: 8px;
}
.day-cell:hover {
    transform: scale(1.03);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.day-cell.empty {
    background: transparent;
    cursor: default;
}
.day-cell.empty:hover {
    transform: none;
    box-shadow: none;
}
.dark .day-cell:not(.empty) {
    background: var(--bg-card); /* Was hardcoded #2C2C2E */
}

/* Waste Type Badge */
.type-badge {
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
}
@media (max-width: 768px) {
    .type-badge { font-size: 8px; padding: 2px 4px; }
}

/* Month Grid Layout */
.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

/* Month Header */
.month-header {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    padding: 6px 2px;
    color: #8E8E93;
}
.dark .month-header {
    color: var(--text-muted);
}

/* Modal Overlay */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal.active { display: flex; }

/* Modal Overlay - Dark Mode (visibility fix) */
.dark .modal {
    background: rgba(0, 0, 0, 0.7);
}

/* Modal Content */
.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}
.dark .modal-content {
    background: var(--bg-card); /* Was hardcoded #2C2C2E */
}
@media (max-width: 640px) {
    .modal-content {
        padding: 16px;
        border-radius: 12px;
        max-width: 95vw;
    }
}

/* Fraction Selection Button */
.frakcja-btn {
    padding: 14px 18px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: 3px solid transparent;
}
.frakcja-btn:hover { transform: scale(1.02); }
.frakcja-btn.active {
    border-color: white;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.3);
}

/* Year View Grid */
.year-view {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
@media (max-width: 1200px) { .year-view { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .year-view { grid-template-columns: repeat(2, 1fr); } } /* iPad breakpoint */
@media (max-width: 640px) { .year-view { grid-template-columns: 1fr; } } /* Small phones */

/* Image Preview */
.img-preview {
    max-height: 600px;
    cursor: zoom-in;
    border-radius: 12px;
}

/* Tab Button */
.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
    min-height: 44px;
}
.tab-btn:hover { background: rgba(0,0,0,0.05); }
.dark .tab-btn:hover { background: rgba(255,255,255,0.08); }

/* Apple HIG - Touch Targets */
button, a { min-height: 44px; -webkit-tap-highlight-color: transparent; }
button:active { transform: scale(0.98); }

/* ============================================
   MOBILE OPTIMIZATION - Admin Panel
   ============================================ */

/* Mobile Header */
@media (max-width: 768px) {
    /* Header layout */
    header .container > div {
        flex-wrap: wrap;
        gap: 12px;
    }

    /* Logo section */
    header .container > div > div:first-child {
        flex: 1;
        min-width: 150px;
    }

    /* Nav buttons - horizontal scroll */
    header .container > div > div:last-child {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    header .container > div > div:last-child::-webkit-scrollbar {
        display: none;
    }

    /* Smaller nav buttons on mobile */
    header .container > div > div:last-child a,
    header .container > div > div:last-child button {
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* Hide text on very small screens */
    header .container > div > div:last-child a span,
    header .container > div > div:last-child button span {
        display: none;
    }
}

@media (max-width: 640px) {
    /* Header - only icons on very small screens */
    header .container > div > div:last-child a,
    header .container > div > div:last-child button {
        padding: 10px;
        gap: 0;
    }

    /* Hide text labels */
    header .container > div > div:last-child a:not([aria-label]) {
        font-size: 0;
    }
    header .container > div > div:last-child a i,
    header .container > div > div:last-child button i {
        width: 20px;
        height: 20px;
    }
}

/* Mobile Navigation Tabs */
@media (max-width: 768px) {
    nav .container > div {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    nav .container > div::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 8px 14px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* Mobile Main Content */
@media (max-width: 768px) {
    main.container {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Cards */
    .ios-card {
        padding: 16px;
        border-radius: 16px;
    }

    /* Section titles */
    .ios-card h2 {
        font-size: 18px;
    }

    /* Day cells - bigger touch targets */
    .day-cell {
        min-height: 60px;
        padding: 4px;
    }
}

/* Mobile Modal */
@media (max-width: 640px) {
    .modal-content {
        padding: 20px;
        border-radius: 20px;
        max-width: 95vw;
        margin: 16px;
    }

    .frakcja-btn {
        padding: 12px 14px;
        font-size: 14px;
    }
}

/* Mobile Rejon Select */
@media (max-width: 768px) {
    select[name="rejon"] {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        border-radius: 12px;
    }
}

/* ============================================
   PRINT STYLES - Admin Panel
   ============================================ */
@media print {
    /* Hide UI elements */
    .modal,
    .modal-content,
    button,
    .tab-btn,
    .frakcja-btn,
    nav,
    header,
    footer {
        display: none !important;
    }

    /* Reset backgrounds and colors */
    body {
        background: white !important;
        color: black !important;
    }

    .ios-card,
    .day-cell {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }

    .dark {
        --bg-primary: white !important;
        --bg-card: white !important;
        --text-primary: black !important;
    }

    /* Year view print layout */
    .year-view {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Ensure text is readable */
    .type-badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Page settings */
    @page {
        margin: 10mm;
        size: A4 landscape;
    }
}
