/* Podstawowe style dla formularza wyszukiwania */
.search-form {
    background-color: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem; /* Dodano margines dla lepszego odstępu */
}

label {
    margin-bottom: 0.5rem;
    font-weight: bold;
}

/* Układ siatki dla pól formularza */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Domyślnie dwie kolumny dla przycisków */
    gap: 1.5rem;
    margin-top: 2rem;
    align-items: center; /* Wyrównanie elementów w pionie */
}

/* Responsywność siatki */
@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-bottom {
        grid-template-columns: 1fr; /* Jedna kolumna na mniejszych ekranach */
    }
}

/* Style dla list wyboru (select) */
select {
    /* Można dodać specyficzne style dla select, jeśli UIkit nie wystarcza */
    /* np. padding, border */
}

select:disabled {
    background-color: #f8f8f8;
    cursor: not-allowed;
    opacity: 0.7; /* Lekkie przygaszenie */
}

/* Animacja ładowania dla opcji w listach rozwijanych */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Celowanie w opcję "Ładowanie..." - może wymagać dostosowania selektora */
/* Ten selektor :contains() nie jest standardowym CSS i może nie działać we wszystkich przeglądarkach */
/* Lepszym podejściem byłoby dodanie klasy do opcji ładowania przez JS */
select option[value=""] { /* Styl dla domyślnej pustej opcji */
    color: #999;
}

/* Przykładowy styl dla opcji ładowania, jeśli dodamy klasę .loading-option przez JS */
select option.loading-option {
    animation: pulse 1.5s infinite;
    color: #666;
    font-style: italic;
}


/* Poprawa responsywności list wyboru */
@media (max-width: 768px) {
    .form-group select,
    .form-group input[type="text"],
    .form-group input[type="date"] { /* Dodano inne typy pól */
        width: 100%; /* Pełna szerokość na małych ekranach */
    }
}

/* Style dla przycisków */
.apf-buttons {
    display: flex;
    gap: 1rem; /* Odstęp między przyciskami */
    justify-content: flex-end; /* Wyrównanie do prawej */
}

@media (max-width: 768px) {
    .apf-buttons {
        justify-content: center; /* Wyśrodkowanie na małych ekranach */
        flex-direction: column; /* Przyciski jeden pod drugim */
        width: 100%;
    }
    .apf-buttons button {
        width: 100%; /* Pełna szerokość przycisków */
        margin-bottom: 0.5rem; /* Odstęp między przyciskami w kolumnie */
    }
    .apf-buttons button:last-child {
        margin-bottom: 0;
    }
}


/* Style dla wyników wyszukiwania */
#apf-results {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    position: relative;
    min-height: 200px; /* zapewnia minimalne miejsce na wyniki */
}

#apf-results .apf-result-item {
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
}

#apf-results .apf-result-item:last-child {
    border-bottom: none;
}

#apf-results h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

#apf-results p {
    margin-bottom: 0.5rem;
    color: #555;
}

/* Styl dla kontenera wyników podczas ładowania */
#apf-results.loading {
    position: relative;
    opacity: 0.7;
    transition: opacity 0.3s;
    pointer-events: none;
}

#apf-results.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 100;
}

#apf-results.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    z-index: 101;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Paginacja */
.apf-pagination-container {
    margin-top: 1.5rem;
    text-align: center;
}

.apf-pagination {
    display: inline-block;
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
    background-color: #0073aa; /* Kolor WordPress */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}

.apf-pagination:hover {
    background-color: #005a87;
}

.apf-pagination.current {
    background-color: #666;
    cursor: default;
}

/* Komunikat ładowania */
#apf-loading {
    text-align: center;
    padding: 1rem;
    font-style: italic;
    color: #777;
}

/* Komunikat o braku wyników */
#apf-no-results {
    text-align: center;
    padding: 1rem;
    color: #777;
}

/* Style dla tabel */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* płynne przewijanie na iOS */
    position: relative;
}

.table-container::after {
    content: "← Przesuń w bok, aby zobaczyć więcej →";
    display: block;
    font-size: 0.9em;
    color: #888;
    text-align: right;
    margin-top: 0.25em;
    margin-bottom: 0.5em;
    white-space: nowrap;
}

@media (min-width: 769px) {
    .table-container::after {
        content: "";
        display: none;
    }
}

.table-container table.uk-table td,
.table-container table.uk-table th {
    border: 1px solid #e0e0e0;
    padding: 0.5em 0.75em;
}
.table-container table.uk-table {
    border-collapse: collapse;
}

/* Style dla wiersza wyszukiwania */
.search-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.search-row__input {
    flex: 0 0 70%;
    min-width: 200px;
    max-width: 70%;
}
.search-row__buttons {
    flex: 0 0 25%;
    min-width: 180px;
    max-width: 30%;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}
@media (max-width: 1024px) {
    .search-row__input {
        flex: 1 1 100%;
        max-width: 100%;
    }
    .search-row__buttons {
        flex: 1 1 100%;
        max-width: 100%;
        justify-content: flex-start;
    }
}
@media (max-width: 700px) {
    .search-row {
        flex-direction: column;
        align-items: stretch;
    }
    .search-row__input,
    .search-row__buttons {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
    .search-row__buttons {
        flex-direction: column;
        gap: 8px;
        justify-content: stretch;
        align-items: stretch;
    }
}

/* Aktualizacja stylów dla wskaźnika ładowania */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Zwiększ widoczność paginacji */
.uk-pagination {
    margin-top: 30px !important;
    padding: 15px 0;
}

.uk-pagination li a {
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.uk-pagination li a:hover {
    background-color: #f0f0f0;
}

/* Style dla wersji iframe */
.apf-iframe-container {
    max-width: 100%;
}

.apf-iframe-container .search-form {
    background: #f8f8f8;
    border-radius: 4px;
    padding: 15px;
}

/* Poprawki dla responsywności w iframe */
@media (max-width: 767px) {
    .apf-iframe-container .grid-2,
    .apf-iframe-container .grid-3 {
        grid-template-columns: 1fr;
    }
}