/**
 * Style aplikacji Odwiedziny Chorych
 */

/* Reset i podstawowe style */
.oc-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(135deg, #f5f0e6 0%, #e8dcc8 100%);
    min-height: 100vh;
}

/* Ukryj WordPress admin bar (dla wszystkich poza administratorami edytującymi) */
body:not(.wp-admin) #wpadminbar {
    display: none !important;
}

/* Ukryj tytuł strony WordPress i header przed aplikacją */
.oc-container {
    margin-top: 0 !important; /* Nie potrzebujemy ujemnego marginesu, jeśli header jest ukryty */
}

/* Ukryj tytuł strony i entry header */
body .entry-title,
body .entry-header h1,
body .page-title,
body .entry-header {
    display: none !important;
}

/* BARDZO AGRESYWNE ukrywanie WordPress header - wszystkie możliwe selektory */
body header:not(.oc-header),
body .site-header:not(.oc-header),
body .main-header:not(.oc-header),
body .site-header,
body .wp-site-blocks > header:not(.oc-header),
body .wp-block-template-part[data-area="header"]:not(.oc-header),
body .site-branding,
body .site-title,
body .site-description,
body .main-navigation,
body nav[role="navigation"]:not(.oc-header),
body header[role="banner"]:not(.oc-header),
body .site-header-wrapper,
body #masthead:not(.oc-header),
body #header:not(.oc-header),
body .header:not(.oc-header) {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
}

/* Ukryj również header jeśli jest przed .oc-container */
body .oc-container ~ header,
body header + .oc-container,
body .site-header + .oc-container {
    /* Zastosuj style do headera przed kontenerem */
}

/* Alternatywnie - ukryj wszystko przed .oc-container */
body:has(.oc-container) > header:first-of-type,
body:has(.oc-container) .site-header:first-of-type {
    display: none !important;
}

.oc-container * {
    box-sizing: border-box;
}

/* Ekran logowania */
.oc-login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.oc-login-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(109, 92, 61, 0.2);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    border: 1px solid #d4c4a8;
}

.oc-login-header {
    text-align: center;
    margin-bottom: 30px;
}

.oc-login-header h1 {
    color: #6d5c3d;
    font-size: 1.8rem;
    margin: 0 0 10px 0;
}

.oc-login-header p {
    color: #8b7355;
    margin: 0;
}

.oc-login-form .oc-form-group {
    margin-bottom: 20px;
}

.oc-login-form label {
    display: block;
    margin-bottom: 8px;
    color: #6d5c3d;
    font-weight: 600;
}

.oc-login-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #d4c4a8;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.oc-login-form input[type="password"]:focus {
    outline: none;
    border-color: #bfa16b;
}

.oc-error {
    background: #fee;
    color: #c00;
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #fcc;
}

/* Ukryj WordPress admin bar dla użytkowników końcowych */
.oc-container ~ #wpadminbar,
.oc-container ~ .wpadminbar {
    display: none !important;
}

/* Nagłówek aplikacji - musi być widoczny */
.oc-header {
    display: flex !important;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 15px 20px;
    background: linear-gradient(135deg, #6d5c3d 0%, #8b7355 100%);
    color: #fff;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(109, 92, 61, 0.3);
}

.oc-header h1 {
    margin: 0;
    font-size: 1.5rem;
    text-align: center;
}

/* Przycisk wylogowania - teraz w menu przycisków */
#oc-logoutBtn {
    /* Style już zdefiniowane przez .oc-btn i .oc-btn-secondary */
}

/* Przyciski */
.oc-btn {
    background: #f5e9d4;
    color: #6b4c1b;
    border: 1px solid #bfa76a;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 10px 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.oc-btn:hover {
    background: #e6d3b3;
    color: #4d3200;
    border-color: #bfa76a;
}

.oc-btn-primary {
    background: linear-gradient(135deg, #6d5c3d 0%, #8b7355 100%);
    color: #fff;
    border: none;
}

.oc-btn-primary:hover {
    background: linear-gradient(135deg, #5a4d33 0%, #7a6548 100%);
    color: #fff;
}

.oc-btn-secondary {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.5);
}

.oc-btn-secondary:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.oc-btn-success {
    background: #4caf50;
    color: #fff;
    border: none;
}

.oc-btn-success:hover {
    background: #43a047;
    color: #fff;
}

.oc-btn-danger {
    background: #f44336;
    color: #fff;
    border: none;
}

.oc-btn-danger:hover {
    background: #e53935;
    color: #fff;
}

/* Zakładki */
.oc-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 20px;
    background: #fff;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(109, 92, 61, 0.1);
    justify-content: center; /* Wyśrodkuj wszystkie przyciski razem */
    align-items: center;
}

/* Wszystkie przyciski w wierszu zakładek - jednakowe traktowanie */
.oc-tabs .oc-tab-button,
.oc-tabs .oc-logout-btn {
    flex: 0 0 auto;
}

.oc-tab-button,
.oc-tabs .oc-logout-btn {
    background: transparent;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: #8b7355;
    border-radius: 8px;
    transition: all 0.2s;
}

/* Przycisk Wyloguj ma dodatkowy border */
.oc-tabs .oc-logout-btn {
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.oc-tab-button:hover,
.oc-tabs .oc-logout-btn:hover {
    background: #f5e9d4;
    color: #6d5c3d;
}

.oc-tabs .oc-logout-btn:hover {
    border-color: rgba(109, 92, 61, 0.3);
}

.oc-tab-button.active {
    background: linear-gradient(135deg, #6d5c3d 0%, #8b7355 100%);
    color: #fff;
}

.oc-tab-content {
    display: none;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(109, 92, 61, 0.1);
}

.oc-tab-content.active {
    display: block;
}

/* Przyciski w zakładkach */
.oc-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    align-items: center;
}

.oc-buttons .oc-btn {
    min-width: 180px;
    flex: 0 0 auto;
}

/* Pasek przycisków Kalendarza: jeden styl (motywy WP często nadpisują button[type=button]) */
#oc-kalendarz-buttons .oc-btn {
    background: #f5e9d4;
    color: #6b4c1b;
    border: 1px solid #bfa76a;
    border-radius: 6px;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

#oc-kalendarz-buttons .oc-btn:hover {
    background: #e6d3b3;
    color: #4d3200;
    border-color: #bfa76a;
}

/* Przycisk wylogowania - style już zdefiniowane wyżej, tylko hover */

.oc-tabs .oc-logout-btn:hover {
    background: #f5e9d4;
    color: #6d5c3d;
    border-color: rgba(109, 92, 61, 0.3);
}

/* Na mobile przycisk będzie pod Adwent dzięki flex-wrap */

/* Wybór roku/miesiąca */
.oc-year-select,
.oc-raport-select {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.oc-year-select select,
.oc-raport-select select {
    padding: 8px 12px;
    border: 1px solid #d4c4a8;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
}

/* Tabele */
.oc-table-container {
    overflow-x: auto;
}

.oc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.oc-table th,
.oc-table td {
    padding: 12px 15px;
    text-align: center;
    border: 1px solid #d4c4a8;
    vertical-align: middle;
}

.oc-table th {
    background: linear-gradient(135deg, #6d5c3d 0%, #8b7355 100%);
    color: #fff;
    font-weight: 600;
}

.oc-table tbody tr:nth-child(even) {
    background: #faf7f2;
}

.oc-table tbody tr:hover {
    background: #f5e9d4;
}

.oc-table tbody tr.status-tak {
    background: #e8f5e9;
}

.oc-table tbody tr.status-nie {
    background: #ffebee;
}

.oc-table tbody tr.next-duty-row {
    background: #fff9c4 !important; /* Bladożółte tło */
    outline: 3px solid #ffc107 !important; /* Żółta obwódka widoczna z wszystkich stron */
    outline-offset: -3px !important; /* Obwódka wewnątrz wiersza */
    position: relative;
    z-index: 1;
}

/* Dodatkowe style dla mobile - ramka na wszystkich komórkach */
@media (max-width: 768px) {
    .oc-table tbody tr.next-duty-row td {
        border: 3px solid #ffc107 !important;
    }
}

.oc-table tbody tr.swieto-row {
    background: #e3f2fd;
}

/* Selecty w tabelach */
.oc-table select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d4c4a8;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #fff;
}

/* Pola edytowalne */
.oc-table td[contenteditable="true"] {
    min-width: 100px;
    cursor: text;
}

.oc-table td[contenteditable="true"]:focus {
    outline: 2px solid #bfa16b;
    outline-offset: -2px;
}

/* Modal */
.oc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.oc-modal-content {
    background: #fff;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.oc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #6d5c3d 0%, #8b7355 100%);
    color: #fff;
}

.oc-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.oc-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.oc-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.oc-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #eee;
}

.oc-chorzy-list {
    max-height: 300px;
    overflow-y: auto;
}

.oc-chorzy-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.oc-chorzy-item:last-child {
    border-bottom: none;
}

.oc-chorzy-item label {
    flex: 1;
    cursor: pointer;
}

.oc-chorzy-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Raport */
.oc-raport-container {
    padding: 20px;
    background: #faf7f2;
    border-radius: 8px;
}

.oc-raport-stats {
    margin-bottom: 20px;
}

.oc-raport-stats ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.oc-raport-stats li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

/* Status select */
.oc-status-select {
    padding: 6px 10px;
    border: 1px solid #d4c4a8;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #fff;
    cursor: pointer;
}

.oc-status-select.status-tak {
    background: #e8f5e9;
    color: #2e7d32;
}

.oc-status-select.status-nie {
    background: #ffebee;
    color: #c62828;
}

/* Responsywność */
@media (max-width: 768px) {
    .oc-container {
        padding: 10px;
    }
    
    .oc-login-container {
        padding: 30px 20px;
    }
    
    .oc-login-header h1 {
        font-size: 1.5rem;
    }
    
    /* Ukryj WordPress header również na mobile */
    body:not(.wp-admin) .site-header:not(.oc-header),
    body:not(.wp-admin) header:not(.oc-header) {
        display: none !important;
    }
    
    .oc-header {
        padding: 12px !important;
    }
    
    .oc-header h1 {
        font-size: 1.2rem !important;
    }
    
    .oc-tabs {
        flex-direction: column;
        padding: 8px;
        justify-content: center; /* Wyśrodkuj również na mobile */
    }
    
    .oc-tab-button,
    .oc-tabs .oc-logout-btn {
        width: 100%;
        text-align: center;
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .oc-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .oc-btn {
        width: 100%;
    }
    
    .oc-tab-content {
        padding: 15px;
    }
    
    /* Tabela kalendarza na mobile - kompaktowy widok */
    .oc-table {
        font-size: 0.75rem;
        min-width: 600px; /* Minimalna szerokość dla lepszej czytelności */
    }
    
    .oc-table th,
    .oc-table td {
        padding: 6px 4px;
        white-space: nowrap; /* Zapobiega zawijaniu tekstu */
    }
    
    /* Sticky kolumna Data - zawsze widoczna przy scrollowaniu */
    #oc-tabelaKalendarz th:first-child {
        position: sticky;
        left: 0;
        background: linear-gradient(135deg, #6d5c3d 0%, #8b7355 100%);
        z-index: 10;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }
    
    #oc-tabelaKalendarz td:first-child {
        position: sticky;
        left: 0;
        z-index: 9;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
        /* Domyślne tło - zostanie nadpisane przez bardziej specyficzne selektory */
        background: #faf7f2;
    }
    
    /* Tło sticky kolumny dla parzystych wierszy */
    #oc-tabelaKalendarz tbody tr:nth-child(even) td:first-child {
        background: #faf7f2;
    }
    
    /* Tło sticky kolumny dla nieparzystych wierszy */
    #oc-tabelaKalendarz tbody tr:nth-child(odd) td:first-child {
        background: #fff;
    }
    
    /* Tło sticky kolumny dla wierszy ze świętami */
    #oc-tabelaKalendarz tbody tr.swieto-row td:first-child {
        background: #e3f2fd !important;
    }
    
    /* Tło sticky kolumny dla odwiedzonych */
    #oc-tabelaKalendarz tbody tr.status-tak td:first-child {
        background: #e8f5e9 !important;
    }
    
    /* Tło sticky kolumny dla nieodwiedzonych */
    #oc-tabelaKalendarz tbody tr.status-nie td:first-child {
        background: #ffebee !important;
    }
    
    /* Tło sticky kolumny dla najbliższego dyżuru */
    #oc-tabelaKalendarz tbody tr.next-duty-row td:first-child {
        background: #fff9c4 !important;
        /* RAMKA na sticky kolumnie - musi być widoczna! */
        border: 3px solid #ffc107 !important;
        border-left: 3px solid #ffc107 !important;
        border-top: 3px solid #ffc107 !important;
        border-bottom: 3px solid #ffc107 !important;
        border-right: 3px solid #ffc107 !important;
        z-index: 11 !important;
    }
    
    /* Naprawa ramki dla najbliższego dyżuru na mobile - ramka obejmuje cały wiersz */
    #oc-tabelaKalendarz tbody tr.next-duty-row {
        outline: none !important; /* Wyłącz outline na mobile - nie działa z sticky */
    }
    
    /* WSZYSTKIE komórki w wierszu mają żółtą ramkę - obejmuje cały wiersz */
    /* Bardzo specyficzny selektor z !important, żeby nadpisać domyślne style tabeli */
    /* Musimy nadpisać .oc-table td { border: 1px solid #d4c4a8; } */
    #oc-tabelaKalendarz.oc-table tbody tr.next-duty-row td,
    table#oc-tabelaKalendarz tbody tr.next-duty-row td,
    .oc-table tbody tr.next-duty-row td {
        border: 3px solid #ffc107 !important; /* Nadpisuje domyślny border: 1px solid #d4c4a8 */
        border-top: 3px solid #ffc107 !important;
        border-bottom: 3px solid #ffc107 !important;
        border-left: 3px solid #ffc107 !important;
        border-right: 3px solid #ffc107 !important;
    }
    
    /* Upewnij się, że sticky kolumna ma odpowiedni z-index i widoczną ramkę */
    #oc-tabelaKalendarz.oc-table tbody tr.next-duty-row td:first-child,
    table#oc-tabelaKalendarz tbody tr.next-duty-row td:first-child,
    .oc-table tbody tr.next-duty-row td:first-child {
        z-index: 11 !important;
        border: 3px solid #ffc107 !important; /* Nadpisuje domyślny border */
        border-top: 3px solid #ffc107 !important;
        border-bottom: 3px solid #ffc107 !important;
        border-left: 3px solid #ffc107 !important;
        border-right: 3px solid #ffc107 !important;
        /* Dodatkowy box-shadow dla sticky kolumny, żeby ramka była widoczna */
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }
    
    /* Tło sticky kolumny przy hover */
    #oc-tabelaKalendarz tbody tr:hover td:first-child {
        background: #f5e9d4 !important;
    }
    
    /* Wyjątki dla hover - jeśli wiersz ma specjalne tło, zachowaj je */
    #oc-tabelaKalendarz tbody tr.swieto-row:hover td:first-child {
        background: #bbdefb !important;
    }
    
    #oc-tabelaKalendarz tbody tr.status-tak:hover td:first-child {
        background: #c8e6c9 !important;
    }
    
    #oc-tabelaKalendarz tbody tr.status-nie:hover td:first-child {
        background: #ffcdd2 !important;
    }
    
    #oc-tabelaKalendarz tbody tr.next-duty-row:hover td:first-child {
        background: #fff59d !important;
    }
    
    .oc-modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
    }
    
    .oc-modal-header h2 {
        font-size: 1.1rem;
    }
    
    .oc-modal-body {
        padding: 15px;
    }
}

/* Bardzo małe ekrany (telefony) */
@media (max-width: 480px) {
    .oc-container {
        padding: 5px;
    }
    
    .oc-login-container {
        padding: 20px 15px;
    }
    
    .oc-login-header h1 {
        font-size: 1.3rem;
    }
    
    /* Ukryj WordPress header również na bardzo małych ekranach */
    body:not(.wp-admin) .site-header:not(.oc-header),
    body:not(.wp-admin) header:not(.oc-header) {
        display: none !important;
    }
    
    .oc-header {
        padding: 10px !important;
    }
    
    .oc-header h1 {
        font-size: 1.1rem !important;
    }
    
    .oc-buttons {
        flex-direction: column;
    }
    
    /* Na mobile przycisk Wyloguj już jest w .oc-tabs, więc będzie pod Raporty */
}

/* Bardzo małe ekrany - iPhone SE i podobne (max 375px) */
@media (max-width: 375px) {
    .oc-header {
        padding: 8px !important;
    }
    
    .oc-header h1 {
        font-size: 1rem !important;
    }
    
    .oc-tab-button {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    /* Tabela kalendarza na bardzo małych ekranach - jeszcze bardziej kompaktowa */
    .oc-table {
        font-size: 0.7rem;
        min-width: 550px;
    }
    
    .oc-table th,
    .oc-table td {
        padding: 5px 3px;
    }
    
    /* Ukryj kolumnę Uwagi na bardzo małych ekranach (można dodać ikonę info później) */
    #oc-tabelaKalendarz th:nth-child(5),
    #oc-tabelaKalendarz td:nth-child(5) {
        display: none;
    }
    
    /* Wybierz w selectach - mniejszy font */
    .oc-table select {
        font-size: 0.7rem;
        padding: 4px 6px;
    }
    
    .oc-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .oc-year-select,
    .oc-raport-select {
        flex-direction: column;
        align-items: stretch;
    }
    
    .oc-year-select select,
    .oc-raport-select select {
        width: 100%;
    }
}

/* Drukowanie */
@media print {
    .oc-header,
    .oc-tabs,
    .oc-buttons,
    .oc-year-select,
    .oc-raport-select,
    .oc-modal {
        display: none !important;
    }
    
    /* Ukryj kolumnę "Akcje" (ostatnia kolumna) tylko w tabelach, które ją mają */
    /* Wyklucz tabelę Adwentu, która nie ma kolumny "Akcje" */
    #oc-tabelaKalendarz th:last-child,
    #oc-tabelaKalendarz td:last-child,
    #oc-tabelaChorzy th:last-child,
    #oc-tabelaChorzy td:last-child,
    #oc-tabelaSzafarze th:last-child,
    #oc-tabelaSzafarze td:last-child {
        display: none !important;
    }
    
    .oc-container {
        background: #fff;
        padding: 0;
    }
    
    /* Ukryj wszystkie zakładki oprócz aktywnej */
    .oc-tab-content:not(.active) {
        display: none !important;
    }
    
    /* Pokaż tylko aktywną zakładkę */
    .oc-tab-content.active {
        display: block !important;
        box-shadow: none;
        padding: 0;
    }
    
    .oc-table {
        width: 100%;
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }
    
    /* Delikatne ramki podczas drukowania - tylko border, bez box-shadow */
    .oc-table th,
    .oc-table td {
        border: 0.5px solid #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .oc-table th {
        background: #333 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        border: 0.5px solid #000 !important;
    }
    
    /* Upewnij się, że ramki są widoczne również dla pierwszej kolumny (Data) - wszystkie strony */
    #oc-tabelaKalendarz th:first-child,
    #oc-tabelaKalendarz td:first-child {
        border: 0.5px solid #000 !important;
        border-top: 0.5px solid #000 !important;
        border-bottom: 0.5px solid #000 !important;
        border-left: 0.5px solid #000 !important;
        border-right: 0.5px solid #000 !important;
    }
}

/* Tooltip dla przycisku Odwiedzone */
.oc-visited-tooltip {
    position: fixed;
    background: #fff;
    color: #6d5c3d;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    white-space: pre-line;
    text-align: left;
    box-shadow: 0 4px 12px rgba(109, 92, 61, 0.3);
    border: 1px solid #bfa16b;
    z-index: 999999;
    pointer-events: none;
    min-width: 150px;
    max-width: 280px;
    font-family: 'Open Sans', Arial, sans-serif;
    line-height: 1.5;
}
