/* -- Zmienne globalne -- */
:root { 
    --bg-color: #f4f4f9; --text-color: #333; --header-color: #222; 
    --primary-color: #28a745; 
    --primary-hover: #218838; 
    --form-bg: #fff; --border-color: #ddd; 
    --table-header-bg: #e9ecef; --table-row-even-bg: #f8f9fa; 
    --danger-color: #dc3545; --danger-hover: #c82333; 
    --edit-color: #ffc107; --edit-hover: #e0a800; 
    --pdf-color: #6c757d; --pdf-hover: #5a6268;
    --success-color: #28a745;
    --secondary-color: #6c757d;
    --dark-color: #343a40;
    
    --info-color: #5bc0de;
    --navy-color: #0a3c7d;
    
    --info-color-bg: rgba(91, 192, 222, 0.1);
    --edit-color-bg: rgba(255, 193, 7, 0.1);
    --navy-color-bg: rgba(10, 60, 125, 0.1);
    --primary-color-bg: rgba(40, 167, 69, 0.1);
    --danger-color-bg: rgba(220, 53, 69, 0.1);
}
@media (prefers-color-scheme: dark) { 
    :root { 
        --bg-color: #181818; 
        --text-color: #e0e0e0; --header-color: #f5f5f5; 
        --primary-color: #40c057; 
        --primary-hover: #37b24d; 
        --form-bg: #1e1e1e; --border-color: #444; 
        --table-header-bg: #2c2c2c; --table-row-even-bg: #252525;
        
        --info-color: #5bc0de;
        --navy-color: #4d7cbf;

        --info-color-bg: rgba(91, 192, 222, 0.15);
        --edit-color-bg: rgba(255, 193, 7, 0.15);
        --navy-color-bg: rgba(77, 124, 191, 0.15);
        --primary-color-bg: rgba(64, 192, 87, 0.15);
        --danger-color-bg: rgba(220, 53, 69, 0.15);
    }
    .btn-edit { color: #1f2328 !important; } 
    .modal-content { background-color: var(--form-bg); } 
    .close-button { color: #aaa; } .close-button:hover { color: white; }
    input[type="date"]::-webkit-calendar-picker-indicator,
    input[type="month"]::-webkit-calendar-picker-indicator { filter: invert(1); }
    .vacation-label {
        color: rgba(255, 255, 255, 0.15) !important;
        text-shadow: 0 0 1px rgba(0, 0, 0, 0.5) !important;
    }
    .form-group-checkbox label { color: #bbb; }
}

/* -- Style globalne -- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
    line-height: 1.6; margin: 0; padding: 0;
    background-color: var(--bg-color); color: var(--text-color);
    display: flex; flex-direction: column;
}
.content-wrapper { max-width: 1400px; margin: 0 auto; width: 100%; padding: 20px; flex: 1 0 auto; }
h1, h2, h3, h4 { color: var(--header-color); }
hr { border: none; border-top: 1px solid var(--border-color); margin: 40px 0; }
a { color: var(--primary-color); text-decoration: none; }
button, .btn, input[type="submit"] {
    background-color: var(--primary-color); color: white; padding: 10px 15px;
    border: none; border-radius: 5px; cursor: pointer; font-size: 0.9em;
    text-decoration: none; display: inline-block; text-align: center;
    transition: background-color 0.2s; font-family: inherit; line-height: inherit;
}
button:hover, .btn:hover, input[type="submit"]:hover { background-color: var(--primary-hover); }
.btn-edit { background-color: var(--edit-color); color: #212529; } .btn-edit:hover { background-color: var(--edit-hover); }
.btn-danger { background-color: var(--danger-color); } .btn-danger:hover { background-color: var(--danger-hover); }
.btn-secondary { background-color: var(--secondary-color); } .btn-secondary:hover { background-color: var(--pdf-hover); }
.btn-sm { padding: 5px 10px; font-size: 0.8em; }
input:not([type="submit"]), select, textarea {
    width: 100%; padding: 10px; margin-bottom: 10px; border-radius: 5px;
    border: 1px solid var(--border-color); box-sizing: border-box;
    background-color: var(--bg-color); color: var(--text-color);
    font-family: inherit; font-size: 1em;
}
input[type="color"] { padding: 5px; height: 40px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-top: 20px; }
.form-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 15px; 
    align-items: start;
}
.input-with-addon {
    display: flex;
    align-items: center;
    gap: 10px;
}
.input-with-addon input {
    margin-bottom: 0;
}
.input-with-addon span {
    white-space: nowrap;
}


/* -- Powiadomienia -- */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 320px;
    width: 90%;
}
.notification {
    background-color: var(--form-bg);
    color: var(--text-color);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 5px solid;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.notification.show {
    opacity: 1;
    transform: translateX(0);
}
.notification.success {
    border-left-color: var(--success-color);
}
.notification.error {
    border-left-color: var(--danger-color);
}
.notification-content {
    flex-grow: 1;
}
.notification-close {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.6;
    font-size: 1.5em;
    line-height: 1;
    padding: 0 0 0 15px;
    cursor: pointer;
    transition: opacity 0.2s;
}
.notification-close:hover {
    opacity: 1;
}


/* -- Główna aplikacja -- */
.top-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 20px; gap: 15px; }
.header-logo-title { display: flex; align-items: center; gap: 15px; text-decoration: none; color: inherit; }
.header-logo { height: 40px; width: auto; }
.user-menu { position: relative; }
.dropdown-toggle { background: none; border: none; color: var(--text-color); cursor: pointer; font-size: 1em; padding: 5px; }
.dropdown-toggle:hover { background-color: var(--table-row-even-bg); }
.dropdown-arrow { font-size: 0.7em; margin-left: 5px; }
.dropdown-menu { display: none; position: absolute; top: 100%; right: 0; background-color: var(--form-bg); border: 1px solid var(--border-color); border-radius: 5px; min-width: 180px; z-index: 1001; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.dropdown-menu.show { display: block; }
.dropdown-menu a { display: block; padding: 10px 15px; color: var(--text-color); }
.dropdown-menu a:hover { background-color: var(--table-row-even-bg); }
.app-footer { text-align: center; padding: 20px; border-top: 1px solid var(--border-color); color: #888; font-size: 0.9em; flex-shrink: 0; }
.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; }

/* ========================================= */
/* POCZĄTEK ZMIAN - STYLE WYSZUKIWARKI MOBILNEJ */
/* ========================================= */
.search-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}
#search-form {
    flex-grow: 1;
    position: relative;
}
#back-to-calendar-btn {
    flex-shrink: 0;
    padding: 8px 12px;
}
/* ======================================= */
/* KONIEC ZMIAN                            */
/* ======================================= */


/* -- Style dla okien modalnych -- */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); }
.modal-content { background-color: var(--form-bg); margin: 5% auto; padding: 20px; border: 1px solid var(--border-color); border-radius: 8px; width: 90%; max-width: 700px; position: relative; z-index: 1001; }
.close-button { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }
.close-button:hover, .close-button:focus { color: var(--text-color); text-decoration: none; }
.changelog-content h4 { margin-top: 20px; margin-bottom: 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
.app-footer a { text-decoration: underline; cursor: pointer; }

/* Wyszukiwarka klienta w modalu */
.client-search-group {
    position: relative;
}
.search-results-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--form-bg);
    border: 1px solid var(--border-color);
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1002;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.search-results-dropdown .result-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}
.search-results-dropdown .result-item:last-child {
    border-bottom: none;
}
.search-results-dropdown .result-item:hover {
    background-color: var(--table-row-even-bg);
}
.search-results-dropdown .result-item small {
    color: var(--pdf-color);
    display: block;
    font-size: 0.9em;
}


/* -- Style dla terminarza -- */
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.calendar-nav h2 { margin: 0; text-align: center;}
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.calendar-day { position: relative; border-right: 1px solid var(--border-color); background-color: var(--form-bg); }
.calendar-day:last-child { border-right: none; }
.calendar-day:hover { background-color: var(--border-color); cursor: pointer; }
.calendar-header { padding: 10px; background-color: var(--table-header-bg); text-align: center; font-weight: bold; border-bottom: 1px solid var(--border-color); }
.day-number { font-size: 1.5em; }
.day-name { font-size: 0.8em; color: var(--pdf-color); }
.holiday-name { display: block; font-size: 0.7em; color: var(--danger-hover); font-weight: normal; margin-top: 5px; }
.calendar-body { padding: 10px; min-height: 400px; display: flex; flex-direction: column; gap: 10px; }
.weekend-day { background-color: var(--table-row-even-bg); }
.vacation-day { background-color: rgba(220, 53, 69, 0.1) !important; position: relative; overflow: hidden; }
.vacation-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-15deg); font-size: 2.5em; font-weight: 900; color: rgba(0, 0, 0, 0.08); z-index: 1; pointer-events: none; text-transform: uppercase; }

.termin-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.2s ease-in-out;
}

.termin-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.termin-toggle-done {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background-color: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: transparent;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s ease-in-out;
}

.termin-toggle-done:hover {
    background-color: rgba(255,255,255,0.4);
    transform: scale(1.1);
}

.termin-toggle-done:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}

.termin-toggle-done:active {
    transform: scale(0.9);
}

.termin-toggle-done.done {
    color: #fff;
    background-color: rgba(0,0,0,0.2);
}

.termin-card.done {
    opacity: 0.6;
}

.termin-card.done .termin-title {
    text-decoration: line-through;
}

.termin-card.done .termin-toggle-done:hover {
    background-color: rgba(0,0,0,0.35);
}

.zlecenie-card { background: var(--form-bg); border: 1px solid var(--border-color); border-radius: 5px; padding: 10px; font-size: 0.9em; text-align: left; width: 100%; color: var(--text-color); border-left-width: 5px; border-left-style: solid; cursor: pointer; position: relative; }
.zlecenie-card:hover { border-color: var(--primary-color); background-color: var(--table-row-even-bg); }
.zlecenie-card strong { display: block; margin-bottom: 5px; }
.zlecenie-card small { display: block; color: var(--pdf-color); margin-bottom: 5px; }
.zlecenie-details { font-size: 0.85em; color: var(--pdf-color); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-color); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 5px 10px; }
.zlecenie-details .creator-info {
    margin-left: auto;
}
.zlecenie-card .zlecenie-koszt { margin: 8px 0 0; font-size: 1.1em; font-weight: bold; text-align: right; }
.car-status-toggle { 
    position: absolute; 
    top: 5px; 
    right: 5px; 
    background: transparent; 
    padding: 0;
    font-size: 1.4em;
    line-height: 1; 
    border: none; 
    border-radius: 50%; 
    width: 40px;
    height: 40px; 
    color: var(--text-color); 
    opacity: 0.2; 
    filter: grayscale(1); 
    z-index: 3; 
    display: flex;
    justify-content: center;
    align-items: center;
}
.car-status-toggle.active { opacity: 1; filter: none; }
.car-status-toggle:hover { background-color: var(--border-color); opacity: 1; filter: none; }

/* Kolory statusów */
.status-umowione, .status-przyjete { border-left-color: var(--info-color); background-color: var(--info-color-bg); }
.status-w-trakcie { border-left-color: var(--edit-color); background-color: var(--edit-color-bg); }
.status-do-odbioru { border-left-color: var(--navy-color); background-color: var(--navy-color-bg); }
.status-zakonczone { border-left-color: var(--primary-color); background-color: var(--primary-color-bg); }
.status-anulowane { border-left-color: var(--danger-color); background-color: var(--danger-color-bg); text-decoration: line-through; opacity: 0.7; }
.status-dealer {
    background-color: var(--primary-color);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
    display: inline-block;
    line-height: 1.2;
}


/* Style dla siatki miesięcznej */
.calendar-grid-month { display: grid; grid-template-columns: auto repeat(7, 1fr); border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.calendar-header-month { text-align: center; padding: 10px; background-color: var(--table-header-bg); font-weight: bold; border-bottom: 1px solid var(--border-color); }
.calendar-day-month { position: relative; border-right: 1px solid var(--border-color); border-top: 1px solid var(--border-color); min-height: 120px; background-color: var(--form-bg); }
.calendar-day-month:hover { background-color: var(--border-color); cursor: pointer; }
.calendar-day-month .calendar-header { padding: 5px; font-weight: bold; text-align: left; display: flex; }
.zlecenia-count-desktop { font-size: 0.8em; color: var(--pdf-color); font-weight: bold; margin-left: auto; }
.calendar-day-month.not-current-month { background-color: var(--table-row-even-bg); color: var(--pdf-color); }
.public-holiday { background-color: rgba(220, 53, 69, 0.1) !important; }
.public-holiday .day-number { color: var(--danger-hover); font-weight: bold; }
.calendar-body-month { padding: 0 5px 5px 5px; display: flex; flex-direction: column; gap: 5px; }
.zlecenie-card-month { font-size: 0.8em; padding: 5px; border-left-width: 3px; border-left-style: solid; border-radius: 3px; cursor: pointer; color: var(--text-color); display: flex; align-items: center; gap: 5px;}
.car-status-indicator { font-size: 0.8em; opacity: 0.2; filter: grayscale(1); }
.car-status-indicator.active { opacity: 1; filter: grayscale(0); }

/* Styl dla aktualnego dnia */
.current-day .calendar-header { color: var(--edit-color); }
.mobile-month-day.current-day { background-color: var(--edit-color); color: #212529; font-weight: bold; }

/* Panel Administratora i tabele */
.table-container { overflow-x: auto; background: var(--form-bg); border: 1px solid var(--border-color); border-radius: 8px; }
.styled-table { width: 100%; border-collapse: collapse; }
.styled-table th, .styled-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.styled-table thead tr { background-color: var(--table-header-bg); }
.styled-table tbody tr:hover { background-color: var(--table-row-even-bg); }
.actions-container {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

/* Lista pojazdów klienta */
.vehicles-row td {
    padding: 0 !important;
    background-color: var(--table-row-even-bg);
}
.vehicles-container {
    padding: 15px;
}
.vehicles-container h4 {
    margin-top: 0;
}

/* Dodatkowe style dla strony statystyk */
.stats-month-selector-label { cursor: pointer; padding: 5px 15px; border-radius: 5px; transition: background-color 0.2s ease; text-align: center; }
.stats-month-selector-label:hover { background-color: var(--border-color); }
.stats-month-selector-label h2 { margin: 0; font-size: 1.5em; color: var(--header-color); }
.page-header .calendar-nav { flex-grow: 1; justify-content: center; gap: 15px; }
.page-header .calendar-nav .btn { font-size: 1.5em; padding: 0 15px; }
.chart-wrapper { position: relative; height: 40vh; max-height: 450px; }

/* -- Style mobilne -- */
.mobile-only { display: none; }
@media (max-width: 768px) {
    .desktop-only { display: none; }
    .mobile-only { display: block; } 

    .content-wrapper { padding: 10px; }
    .page-header { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "nav nav" "switcher add" "search search"; gap: 10px; align-items: center; }
    .calendar-nav { grid-area: nav; display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 0; }
    .calendar-nav h2 { font-size: 1.1em; text-align: center; margin: 0 5px; flex-shrink: 1; white-space: normal; }
    
    body.view-week .calendar-grid { display: flex; flex-direction: column; gap: 10px; border: none; }
    body.view-week .calendar-day { border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; }
    body.view-week .calendar-header { flex-wrap: wrap; padding: 0; text-align: left; border-bottom: 1px solid var(--border-color); margin-bottom: 12px; padding-bottom: 8px; background: none; }
    body.view-week .day-name { font-size: 1.1em; font-weight: bold; color: var(--header-color); }
    body.view-week .calendar-body { min-height: auto; padding: 0; gap: 12px; }
    
    .mobile-bottom-nav { display: flex; justify-content: space-between; margin-top: 20px; }

    .calendar-grid-month.mobile-only { 
        display: grid; 
        grid-template-columns: repeat(7, 1fr);
        gap: 2px; 
        padding: 5px;
    }
    .calendar-header-month.mobile-day-name { font-size: 0.8em; padding-bottom: 5px; text-align: center; font-weight: bold; color: var(--pdf-color); }
    .mobile-month-day { 
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative; 
        aspect-ratio: 1 / 1; 
        border-radius: 50%; 
        padding: 0;
    }
    .mobile-month-day .day-number { font-size: 0.9em; }
    
    .zlecenia-count-badge {
        position: absolute;
        top: 2px;
        right: 2px;
        width: 18px;
        height: 18px;
        font-size: 0.8em;
        font-weight: bold;
        line-height: 1;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: var(--primary-color);
        color: white;
        border: 2px solid var(--bg-color);
        box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }
    @media (prefers-color-scheme: dark) {
        .zlecenia-count-badge {
             border-color: var(--bg-color);
        }
    }

    /* Poprawki mobilne dla statystyk */
    .stats-month-selector-label h2 { font-size: 1.1em; }
    .page-header .calendar-nav { flex-wrap: nowrap; }
    .chart-wrapper { height: 300px; }
    .form-grid { grid-template-columns: 1fr; }

    /* Poprawki mobilne dla tabel (responsywna tabela) */
    .styled-table thead { display: none; }
    .styled-table tr { display: block; border: 1px solid var(--border-color); border-radius: 5px; margin-bottom: 15px; }
    .styled-table td { 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        text-align: right; 
        padding: 10px 15px; 
        border-bottom: 1px solid var(--table-header-bg); 
    }
    .styled-table td:last-child { border-bottom: none; }
    .styled-table td::before { 
        content: attr(data-label); 
        font-weight: bold; 
        text-align: left; 
        margin-right: auto; 
        padding-right: 15px;
        color: var(--header-color);
        flex-shrink: 0;
    }
    .styled-table td.actions-container { padding: 5px 15px; justify-content: flex-end; }
    .styled-table td.actions-container::before { display: none; }
}

/* -- Style dla stron autoryzacji (Logowanie, Rejestracja) -- */
.auth-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-body .content-wrapper {
    max-width: 100%;
    width: auto;
    padding: 0;
    margin: 0;
    flex: 0 1 auto;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 30px;
    background-color: var(--form-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    text-align: center;
}

@media (prefers-color-scheme: dark) {
    .auth-container {
        box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
}

.auth-logo {
    max-height: 60px;
    width: auto;
    margin-bottom: 20px;
}

.auth-container h2 {
    margin-bottom: 25px;
}

.auth-container .form-group {
    text-align: left;
    margin-bottom: 15px;
}

.auth-container .form-group label {
    display: block;
    margin-bottom: 5px;
}

.recaptcha-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.auth-switch {
    margin-top: 20px;
    font-size: 0.9em;
}

.auth-body .app-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    border-top: none;
    background: transparent;
}

.form-group-checkbox {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 8px;
}

.form-group-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.form-group-checkbox label {
    margin: 0;
}

.form-group-checkbox-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 1rem;
}

.form-group-checkbox-row .form-group-checkbox {
    margin-bottom: 0;
}

.cost-input-group {
    display: flex;
    align-items: center;
    gap: 15px;
}
.cost-input-group input {
    margin-bottom: 0;
}
.cost-input-group .form-group-checkbox {
    margin-bottom: 0;
    white-space: nowrap;
}
.calculated-gross {
    font-size: 0.9em;
    font-weight: bold;
    color: var(--primary-color);
    margin-top: 8px;
    padding-left: 5px;
}