/* =================================================================== */
/* STYL CSS - MOTYW "CITIZENSHIP" DLA FORMULARZA O POBYT           */
/* Wersja: 1.0                     */
/* =================================================================== */

/* --- Główny kontener --- */
.residence-form-container {
    width: 80% !important;
    max-width: 100%;
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background-color: transparent;
}

/* --- Kontener sekcji --- */
#residenceForm .form-section {
    background-color: #e9ecef;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
}

/* --- Tytuł wewnątrz sekcji --- */
#residenceForm .form-section-title {
    font-size: 20px;
    font-weight: 700;
    color: #343a40;
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
}

/* --- Struktura wiersza i pola --- */
#residenceForm .form-row {
    display: flex;
    flex-direction: row;
    gap: 20px;
    margin-bottom: 20px;
}
#residenceForm .form-row:last-child {
    margin-bottom: 0;
}

/* --- Animacja tła pól --- */
#residenceForm .row {
    background: linear-gradient(to right, rgba(var(--residence-form-accent-color-rgb, 8, 139, 204), 0.83) 50%, #acbdd5d6 50%);
    background-size: 200% 100%;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    background-position: right bottom;
    border-radius: 10px;
    padding: 10px;
    transition: background-position 0.5s ease-out; 
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#residenceForm .row:hover {
    transform: translateY(-2px);
}
#residenceForm .row.row-filled {
    background-position: left bottom;
}

#residenceForm .form-field {
    min-width: 150px;
}

/* --- Etykiety --- */
#residenceForm .form-field > label {
    margin-bottom: 5px;
    font-size: 18px;
    color: white;
}

/* --- UJEDNOLICONA WYSOKOŚĆ PÓL --- */
#residenceForm input[type="text"],
#residenceForm input[type="email"],
#residenceForm input[type="number"],
#residenceForm input[type="tel"],
#residenceForm input[type="date"],
#residenceForm textarea,
#residenceForm select {
    width: 100%;
    height: 42px; 
    padding: 0 12px; 
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 16px;
    color: #4a5568;
    background-color: white;
    transition: all 0.2s ease;
}
#residenceForm textarea {
    min-height: 84px;
    padding: 8px 12px;
}

#residenceForm *:focus-visible, 
#residenceForm input:focus, 
#residenceForm select:focus, 
#residenceForm textarea:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
}

#residenceForm .date-select-group .date-inputs { display: flex; gap: 10px; }

#residenceForm input[type="date"] {
    position: relative;
    padding-right: 15px;
}

#residenceForm input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#residenceForm input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* ================================================= */
/* === NOWY MOTYW SELECT2 (CAF MODERN THEME) === */
/* ================================================= */
#residenceForm .select2-container .select2-selection--single {
    background-color: #fff;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    height: 42px;
    outline: none;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}
#residenceForm .select2-container--open .select2-selection--single {
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
}
#residenceForm .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #4a5568;
    line-height: 40px;
    padding-left: 12px;
    padding-right: 30px;
    font-size: 16px; 
}
#residenceForm .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #a0aec0;
    font-size: 16px;
}
#residenceForm .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
    position: absolute;
    top: 1px;
    right: 1px;
    width: 25px;
}
#residenceForm .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #888 transparent transparent transparent;
    border-style: solid;
    border-width: 5px 4px 0 4px;
    height: 0;
    left: 50%;
    margin-left: -4px;
    margin-top: -2px;
    position: absolute;
    top: 50%;
    width: 0;
    transition: all 0.2s ease;
}
#residenceForm .select2-container--default.select2-container--open .select2-selection__arrow b {
    transform: rotate(180deg);
}
/* Style dla rozwijanej listy Select2 */
.select2-dropdown {
    background-color: white;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    z-index: 9999;
}
.select2-search--dropdown .select2-search__field {
    outline: none;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px;
    width: calc(100% - 20px) !important;
}
.select2-dropdown .select2-results__option {
    padding: 12px 20px !important;
    transition: all 0.15s ease-in-out;
    font-size: 16px;
}
.select2-results__option--highlighted,
.select2-results__option--highlighted[aria-selected] { 
    background-color: var(--residence-form-accent-color) !important;
    color: white !important;
}
.select2-results__option[aria-selected=true] { 
    background-color: #e2e8f0;
    color: #2d3748;
}

/* --- Przycisk, ładowanie i komunikaty --- */
#residenceForm .btn-form {
    color: white; border: none; padding: 15px; border-radius: 8px; cursor: pointer;
    margin-top: 20px; font-size: 18px; display: block; width: 100%; transition: all 0.3s ease;
    background: linear-gradient(40deg, #74859e, #94a8c6, #74859e);
    background-size: 200% 200%;
    animation: gradient-flow 3s ease infinite;
}
#residenceForm .btn-form:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
@keyframes gradient-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Gwiazdka/ikona walidacji --- */
#residenceForm .form-field.row { 
    position: relative; 
}

#residenceForm .form-field.row::after {
    content: ''; 
    position: absolute; 
    top: 15px; 
    right: 15px;
    transition: all 0.3s ease-in-out; 
    transform: scale(0.5); 
    opacity: 0;
}

#residenceForm .form-field.row.is-required:not(.row-filled)::after {
    content: '*'; 
    font-family: 'Arial', sans-serif; 
    font-size: 24px; 
    font-weight: bold;
    color: white; 
    line-height: 1; 
    top: 12px; 
    transform: scale(1); 
    opacity: 0.7;
}

/* KROK 1: Definiujemy wygląd ikony w stanie WYPEŁNIONYM, ale animacja jest w stanie początkowym (schowana) */
#residenceForm .form-field.row.row-filled::after {
    content: ''; 
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M3 8l3 3 7-7'/%3e%3c/svg%3e");
    background-size: contain; 
    background-repeat: no-repeat; 
    font-size: initial; 
    font-weight: normal; 
    width: 16px; 
    height: 16px; 
    top: 18px;
    opacity: 1;
    transform: scale(0); /* Początkowy stan animacji: schowana */
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* Definicja animacji */
}

/* KROK 2: Po dodaniu klasy .is-validated przez JS, ikona płynnie "wyskakuje" do pełnego rozmiaru */
#residenceForm .form-field.row.row-filled.is-validated::after {
    transform: scale(1); /* Końcowy stan animacji: widoczna */
}
/* --- Przycisk "Wypełnij od nowa" --- */
#residenceForm .btn-secondary {
    display: none; width: 100%; text-align: center; padding: 15px; margin-top: 15px;
    font-size: 18px; border-radius: 8px; cursor: pointer; transition: all 0.3s ease;
    background-color: transparent; border: 2px solid #718096; color: #718096;
}
#residenceForm .btn-secondary:hover { background-color: #718096; color: white; }

/* ================================================= */
/* === NOWE KONTROLKI (SEGMENTED, TOGGLE, GENDER) === */
/* ================================================= */

/* --- Przełącznik Widoku (Segmented Control) --- */
#residenceForm .view-switcher { 
    display: flex; 
    justify-content: flex-end; 
    margin-bottom: 20px; 
}
#residenceForm .view-switcher-segmented {
    display: inline-flex;
    width: auto; /* Zmieniono na auto, aby przyciski dostosowywały się do zawartości */
    border-radius: 8px;
    overflow: hidden;
    background-color: #f8f9fa;
}
#residenceForm .view-switcher-segmented button {
    display: flex; 
    align-items: center; 
    justify-content: center; /* Wyśrodkowanie tekstu i ikony */
    gap: 8px;
    border: none; 
    background-color: transparent;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px; 
    color: #4a5568;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
    border-left: 1px solid #e2e8f0;
    white-space: nowrap; /* Zapobiega zawijaniu się tekstu */
}
#residenceForm .view-switcher-segmented button:first-child { border-left: none; }
#residenceForm .view-switcher-segmented button svg { width: 16px; height: 16px; fill: currentColor; }
#residenceForm .view-switcher-segmented button.active-view { background-color: var(--residence-form-accent-color); color: white; }
#residenceForm .view-switcher-segmented button:not(.active-view):hover { background-color: #e2e8f0; }

/* --- Przełącznik (Toggle Switch) --- */
#residenceForm .toggle-switch-container { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
#residenceForm .toggle-label { font-size: 16px !important; color: white !important; margin-bottom: 0 !important; cursor: pointer; }
#residenceForm .toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
#residenceForm .toggle-switch input { opacity: 0; width: 0; height: 0; }
#residenceForm .toggle-switch .slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .4s; border-radius: 24px;
}
#residenceForm .toggle-switch .slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: white; transition: .4s; border-radius: 50%;
}
#residenceForm .toggle-switch input:checked + .slider { background-color: var(--residence-form-accent-color); }
#residenceForm .toggle-switch input:focus + .slider { box-shadow: 0 0 1px var(--residence-form-accent-color); }
#residenceForm .toggle-switch input:checked + .slider:before { transform: translateX(20px); }

/* === NOWA, ANIMOWANA KONTROLKA SEGMENTOWA (WERSJA POPRAWIONA) === */
#residenceForm .segmented-control {
    display: grid;
    /* Tworzymy dwie kolumny o równej szerokości */
    grid-template-columns: 1fr 1fr; 
    position: relative;
    background-color: #f0f3f7;
    border-radius: 8px;
    margin-top: 5px;
    width: 100%;
}

/* Ukrycie oryginalnego przycisku radio */
#residenceForm .segmented-control input[type="radio"] {
    opacity: 0;
    position: fixed;
    width: 0;
    height: 0;
}

/* Etykiety, które są teraz w siatce (grid) */
#residenceForm .segmented-control .segmented-control-label {
    text-align: center;
    cursor: pointer;
    /* Umieszczamy etykiety na wierzchu */
    z-index: 2;
    /* Etykiety muszą być w odpowiedniej kolumnie siatki */
    grid-row: 1;
}
/* Pozycjonowanie etykiet w siatce */
#residenceForm .segmented-control label[for$="_male"], 
#residenceForm .segmented-control label[for$="_yes"] {
    grid-column: 1;
}
#residenceForm .segmented-control label[for$="_female"], 
#residenceForm .segmented-control label[for$="_no"] {
    grid-column: 2;
}


/* Tekst wewnątrz etykiety */
#residenceForm .segmented-control .segmented-control-label span {
    display: block;
    padding: 8px;
    font-size: 16px;
    color: #4a5568;
    transition: color 0.3s ease-in-out;
}

/* Suwak (glider) - animowane tło */
#residenceForm .segmented-control .glider {
    position: absolute;
    top: 2px;
    left: 2px;
    height: calc(100% - 4px);
    width: calc(50% - 2px);
    background-color: var(--residence-form-accent-color);
    border-radius: 6px;
    transition: transform 0.3s cubic-bezier(0.65, 0, 0.35, 1);
    /* Glider jest pod spodem */
    z-index: 1;
    /* Umieszczamy go w pierwszej komórce siatki */
    grid-column: 1;
    grid-row: 1;
}

/* Zmiana koloru tekstu po najechaniu na niego */
#residenceForm .segmented-control .segmented-control-label:hover span {
    color: var(--residence-form-accent-color);
}


/* === MAGIA DZIEJE SIĘ TUTAJ (POPRAWIONE SELEKTORY) === */

/* Kiedy DRUGI przycisk (female/no) jest zaznaczony... */
#residenceForm .segmented-control input[id$="_female"]:checked ~ .glider,
#residenceForm .segmented-control input[id$="_no"]:checked ~ .glider {
    /* ...przesuń suwak o 100% jego szerokości w prawo */
    transform: translateX(100%);
}

/* Zmiana koloru tekstu dla aktywnej opcji */
#residenceForm .segmented-control input[id$="_male"]:checked ~ label[for="gender_male"] span,
#residenceForm .segmented-control input[id$="_female"]:checked ~ label[for="gender_female"] span,
#residenceForm .segmented-control input[id$="_yes"]:checked ~ label[for="convicted_yes"] span,
#residenceForm .segmented-control input[id$="_no"]:checked ~ label[for="convicted_no"] span {
    color: white;
}

/* Zapobiegnięcie zmiany koloru na niebieski przy najechaniu na aktywną opcję */
#residenceForm .segmented-control input:checked ~ label:hover span {
    color: white !important;
}


/* --- Logika widoku kolumnowego --- */
#residenceForm.view-columns .residence-form-container {
    max-width: 60% !important; /* Nowa szerokość 60% w widoku kolumnowym */
    margin: 0 auto; /* Wyśrodkowanie formularza */
    transition: max-width 0.5s ease-in-out; /* Płynna animacja zmiany szerokości */
}
#residenceForm.view-columns .form-row { flex-direction: column; gap: 0; margin-bottom: 0; }
#residenceForm.view-columns .form-row .form-field.row { margin-bottom: 15px; }
#residenceForm.view-columns .form-field.row { flex-direction: row; align-items: center; gap: 25px; padding-right: 40px; }
#residenceForm.view-columns .form-field.row > label:first-of-type { flex-basis: 200px; flex-shrink: 0; margin-bottom: 0; }
#residenceForm.view-columns .form-field.row .date-inputs,
#residenceForm.view-columns .form-field.row .toggle-switch-container,
#residenceForm.view-columns .form-field.row .segmented-control { flex-grow: 1; }
#residenceForm.view-columns .form-field.row .select2-container { flex-grow: 1; }
#residenceForm.view-columns .form-field-manual-city { flex-grow: 1; display: flex; flex-direction: column; gap: 10px; }

/* === Animacja wysuwania okienka dla pola "Karalność" === */

#residenceForm #conviction-details {
    /* Ukrywamy wszystko, co "wystaje" poza kontener */
    overflow: hidden;
    
    /* Stan początkowy (ukryty): zerowa wysokość, zerowa widoczność */
    max-height: 0;
    opacity: 0;
    margin-top: 0 !important; /* Nadpisujemy istniejący margines */
    padding-top: 0;
    padding-bottom: 0;
    
    /* Definicja płynnych przejść dla wielu właściwości */
    transition: 
        max-height 0.4s ease-in-out,
        opacity 0.3s ease-in-out,
        margin-top 0.4s ease-in-out,
        padding-top 0.4s ease-in-out,
        padding-bottom 0.4s ease-in-out;
}

/* Stan końcowy (widoczny): po dodaniu klasy .is-visible */
#residenceForm #conviction-details.is-visible {
    /* Ustawiamy maksymalną wysokość na wartość większą niż zawartość */
    max-height: 200px;
    opacity: 1;
    margin-top: 15px !important; /* Przywracamy margines */
}
/* === Górny pasek formularza === */
#residenceForm .form-top-bar {
    display: flex;
    justify-content: space-between; /* Rozsuwa elementy na boki */
    align-items: center;
    margin-bottom: 25px;
    gap: 20px;
}


#residenceForm #restore-notification {
    display: flex;
  justify-content: space-between; 
  align-items: center;
  padding: 12px 20px;
  margin-bottom: 25px; 
  background-color: #f0f3f7; 
  border: 1px solid #dfe3e8;
  border-radius: 8px; /* Zaokrąglone rogi */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); 
  transition: all 0.3s ease;
}

#residenceForm #restore-notification .restore-text {
  font-size: 14px;
  font-weight: 500;
  color: #4a5568;
  margin-right: 20px;
}

#residenceForm #restore-notification .view-switcher-segmented {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  background-color: #e2e8f0; 
  flex-shrink: 0; 
}

/* Ogólny styl dla przycisków w powiadomieniu */
#residenceForm #restore-notification .view-switcher-segmented button {
  border: none;
  background-color: transparent; 
  padding: 8px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Styl dla aktywnego przycisku (Tak) */
#residenceForm #restore-notification .view-switcher-segmented button.active-view {
  background-color: var(--residence-form-accent-color, #088bcc); /* Kolor akcentu z formularza */
  color: white;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Efekt najechania myszą na nieaktywny przycisk (Nie) */
#residenceForm #restore-notification .view-switcher-segmented button:not(.active-view):hover {
  background-color: #cbd5e0;
}

/* ================================================= */
/* === STYLE WALIDACJI === */
/* ================================================= */

/* Czerwone tło dla kontenera pola z błędem */
#residenceForm .form-field.row.has-error {
    background: linear-gradient(to right, rgba(229, 62, 62, 0.8) 50%, rgba(245, 101, 101, 0.8) 50%);
    background-size: 200% 100%;
    background-position: left bottom;
}

/* Wygląd samego komunikatu o błędzie */
.error-message-field {
    background-color: #c53030;
    color: white;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    margin-top: 10px; 
    border-radius: 6px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .error-message-field {
        margin-left: 0;
        max-width: 100%;
        margin-top: 5px;
    }
}

/* ================================================= */

/* ===  białym ptaszkiem (rysowany w CSS) === */
/* ================================================= */

/* Główny kontener pola - bez zmian */
#residenceForm #gdpr-field-wrapper {
    display: flex;
    padding-top: 15px;
    padding-bottom: 15px;
}

/* Etykieta jako klikalny element - dodajemy pozycjonowanie względne */
#residenceForm #gdpr-field-wrapper label {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: white;
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
    position: relative; /* Kluczowe dla pozycjonowania ptaszka */
}

/* Link wewnątrz etykiety - bez zmian */
#residenceForm #gdpr-field-wrapper label a {
    color: #a7d8ff;
    text-decoration: underline;
    font-weight: bold;
}
#residenceForm #gdpr-field-wrapper label a:hover {
    color: #ffffff;
}

/* Ukrywamy domyślny checkbox - bez zmian */
#residenceForm #gdpr-field-wrapper input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

/* Tworzymy "fałszywy" checkbox (pudełko) - bez zmian */
#residenceForm #gdpr-field-wrapper label::before {
    content: '';
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 2px solid #a7d8ff;
    border-radius: 4px;
    margin-right: 15px;
    flex-shrink: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* === NOWY/STARY KOD: Ponownie rysujemy ptaszek za pomocą ::after === */
/* Definiujemy wygląd ptaszka, na razie jest ukryty */
#residenceForm #gdpr-field-wrapper label::after {
    content: '';
    position: absolute; /* Pozycjonujemy go wewnątrz etykiety */
    
    /* Precyzyjne wartości, aby wycentrować ptaszek w pudełku 22x22px */
    left: 9px;
    top: 5px;
    
    /* Rysujemy kształt "L", który stanie się ptaszkiem po obróceniu */
    width: 6px;
    height: 12px;
    border: solid white; /* WAŻNE: ptaszek jest w 100% biały */
    border-width: 0 3px 3px 0; /* Rysujemy tylko prawą i dolną krawędź */

    /* Początkowo jest niewidoczny i przeskalowany do zera */
    opacity: 0;
    transform: rotate(45deg) scale(0);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Zmieniamy wygląd, gdy checkbox jest ZAZNACZONY */
#residenceForm #gdpr-field-wrapper input[type="checkbox"]:checked + label::before {
    background-color: var(--residence-form-accent-color);
    border-color: var(--residence-form-accent-color);
}

/* Pokazujemy ptaszek (::after), gdy checkbox jest zaznaczony */
#residenceForm #gdpr-field-wrapper input[type="checkbox"]:checked + label::after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

/* Dostępność: obramowanie w stanie :focus - bez zmian */
#residenceForm #gdpr-field-wrapper input[type="checkbox"]:focus + label::before {
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
}

/* ================================================= */
/* === STYLE FORMULARZA WIELOETAPOWEGO === */
/* ================================================= */

/* Ukrywamy wszystkie sekcje domyślnie */
#residenceForm .form-section {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

/* Pokazujemy tylko aktywną sekcję */
#residenceForm .form-section.active-step {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Kontener paska postępu */
#form-step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
    padding-bottom: 25px; /* Miejsce na etykiety */
}

/* Element kroku (kontener na ikonę i etykietę) */
.step-indicator-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    z-index: 2;
    width: 24%;
}

/* Ikona z numerem kroku */
.step-indicator-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e2e8f0;
    color: #4a5568;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    border: 3px solid #e2e8f0;
    transition: all 0.3s ease;
}

/* Etykieta pod ikoną */
.step-indicator-label {
    position: absolute;
    top: 45px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
}

/* --- Style dla stanu AKTYWNEGO --- */
.step-indicator-item.active .step-indicator-icon {
    background-color: var(--residence-form-accent-color);
    border-color: var(--residence-form-accent-color);
    color: white;
    transform: scale(1.1);
}

.step-indicator-item.active .step-indicator-label {
    color: var(--residence-form-accent-color);
    font-weight: bold;
}


/* --- Style dla stanu UKOŃCZONEGO --- */
.step-indicator-item.completed .step-indicator-icon {
    background-color: #d1e7dd; /* Jaśniejszy zielony */
    border-color: #d1e7dd;
    color: #0f5132; /* Ciemny zielony */
    content: '✔'; /* Zastępuje numer ptaszkiem */
}

.step-indicator-item.completed .step-indicator-label {
    color: #4a5568;
}

/* Styl przycisku "Dalej" - dziedziczy z .btn-form, ale można dodać modyfikacje */
#nextBtn {
    background: var(--residence-form-accent-color);
}
#nextBtn:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

/* ================================================= */
/* === POPRAWKA STYLU PRZYCISKÓW NAWIGACYJNYCH === */
/* ================================================= */

/* Wspólny kontener dla przycisków nawigacji */
#residenceForm #form-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
}

/* Wspólne style dla obu przycisków nawigacyjnych (Dalej i Wstecz) */
#residenceForm #form-navigation button {
    width: auto; /* NAJWAŻNIEJSZE: Usuwa pełną szerokość */
    padding: 10px 30px;
    margin-top: 0; /* Usuwa domyślny margines z klasy .btn-form */
    font-size: 16px;
    border: 2px solid transparent; /* Dodajemy ramkę dla spójności */
    transition: all 0.3s ease;
}

/* Styl dla przycisku "Dalej" (akcja główna) */
#residenceForm #form-navigation #nextBtn {
    background-color: var(--residence-form-accent-color);
    border-color: var(--residence-form-accent-color);
    color: white;
}

#residenceForm #form-navigation #nextBtn:hover {
    filter: brightness(110%);
    transform: translateY(-2px);
}

/* Styl dla przycisku "Wstecz" (akcja drugorzędna) */
#residenceForm #form-navigation #prevBtn {
    background-color: transparent;
    border-color: #a0aec0;
    color: #4a5568;
}

#residenceForm #form-navigation #prevBtn:hover {
    background-color: #a0aec0;
    color: white;
    transform: translateY(-2px);
}

/* ================================================= */
/* === POPRAWKA POLA RODO W WIDOKU KOLUMNOWYM === */
/* ================================================= */

/* Tworzymy wyjątek dla kontenera RODO w widoku kolumnowym */
#residenceForm.view-columns #gdpr-field-wrapper {
    /* Przywracamy domyślne wyrównanie i odstępy */
    flex-direction: initial;
    align-items: initial;
    padding: 15px;
    gap: 0;
}

/* Resetujemy styl dla etykiety RODO, aby nie próbowała stać się kolumną */
#residenceForm.view-columns #gdpr-field-wrapper > label {
    flex-basis: auto; /* Usuwamy stałą szerokość */
    flex-shrink: 1;
}


/* --- Pasek postępu i komunikaty --- */
#residenceForm .progress-bar-container { width: 100%; background-color: #e2e8f0; border-radius: 8px; margin-top: 15px; overflow: hidden; }
#residenceForm .progress-bar { width: 0%; height: 12px; border-radius: 8px; transition: width 0.3s ease-in-out; background: linear-gradient(45deg, #3182ce, #63b3ed, #4299e1, #3182ce); background-size: 400% 400%; animation: gradientAnimation 3s ease infinite; }
@keyframes gradientAnimation { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
#residenceForm .progress-text-style { margin-top: 8px; font-size: 14px; color: #495057; font-weight: bold; }
/* ================================================= */
/* === KOMUNIKATY (SUKCES / BŁĄD) === */
/* ================================================= */

/* Wspólna podstawa dla obu komunikatów */
#residenceForm .success-message,
#residenceForm .error-message {
    display: flex; /* Używamy Flexbox do łatwego wyrównania ikony i tekstu */
    align-items: center; /* Wyrównanie w pionie */
    margin-top: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    text-align: left; /* Zmieniamy na wyrównanie do lewej */
    border: 1px solid transparent; /* Dodajemy przezroczystą ramkę dla spójności */
}

/* Styl dla tekstu wewnątrz komunikatu */
#residenceForm .success-message p,
#residenceForm .error-message p {
    margin: 0;
    padding: 0;
    font-weight: 500;
    flex-grow: 1; /* Tekst zajmuje pozostałą przestrzeń */
}

/* Ikona dodawana jako pseudo-element ::before */
#residenceForm .success-message::before,
#residenceForm .error-message::before {
    content: '';
    display: inline-block;
    flex-shrink: 0; /* Ikona nie będzie się kurczyć */
    width: 20px;
    height: 20px;
    margin-right: 15px; /* Odstęp między ikoną a tekstem */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* --- Komunikat o sukcesie (zielony) --- */
#residenceForm .success-message {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
    /* Gruba ramka po lewej stronie w kolorze głównym */
    border-left: 5px solid #198754; 
}

/* Ikona "checkmark" dla sukcesu (URL-encoded SVG) */
#residenceForm .success-message::before {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23198754'%3e%3cpath d='M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z'/%3e%3c/svg%3e");
}

/* --- Komunikat o błędzie (czerwony) --- */
#residenceForm .error-message {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
    /* Gruba ramka po lewej stronie w kolorze głównym */
    border-left: 5px solid #dc3545;
}

/* Ikona "alert" dla błędu (URL-encoded SVG) */
#residenceForm .error-message::before {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23dc3545'%3e%3cpath d='M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z'/%3e%3c/svg%3e");
}

/* --- Loading bez zmian --- */
#residenceForm .loading {
    text-align: center; 
    margin-top: 20px; 
    padding: 10px; 
    border-radius: 8px;
}
/* ================================================= */
/* === STYLIZACJA NATYWNYCH PÓL SELECT === */
/* ================================================= */

#residenceForm select:not([multiple]) {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='%23888' d='M2 5l6 6 6-6H2z'/%3e%3c/svg%3e");
    
    background-repeat: no-repeat;
    background-position: right 8px center; 
    background-size: 0.8em auto;            

    padding-right: 2.5em !important;
}
/* --- Responsywność --- */
@media (max-width: 768px) {
    .residence-form-container {width: 95% !important;}
    #residenceForm .form-row { flex-direction: column; gap: 0; margin-bottom: 0; }
    #residenceForm .form-row .form-field.row { margin-bottom: 8px; }
    #residenceForm .form-section { padding: 15px; }
    #residenceForm .view-switcher { display: none !important; }
    #residenceForm .date-inputs { flex-direction: column; gap: 8px; }
    #residenceForm.view-columns .residence-form-container {
        max-width: 100%;
        margin: 0;
    }
    .step-indicator-label {display: none;}
}