/* Resetowanie stylów i ustawienia globalne */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Fredoka', Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Nagłówki i teksty ogólne */
h1.addReviewTitle {
    font-size: 26px;
    font-weight: 600;
    text-align: center;
    margin-top: 10px;
}

p.legend {
    margin-top: 20px;
    margin-bottom: 30px;    
    font-weight: 600;
}

/* Formularz główny */
#ratingForm {
    margin: 100px auto 5% auto;
    width: 95%;
    max-width: 700px;
    background: white;
    padding: 20px;
    box-shadow: 0 0 10px rgba(217, 132, 132, 0.1);
    transition: margin-top 0.3s ease;
}

body.menu-open #ratingForm {
    margin-top: 320px; /* Wysokość headera, gdy menu jest otwarte (powinna odpowiadać max-height z nav.menu-open) */
}

@media (max-width: 800px) {
    form#ratingForm {
        margin-top: 200px;
    }
}

/* Sekcje formularza */
.form-section {
    margin-bottom: 20px;
}

.form-section label,
.rating-section legend {
    display: block;
    margin-bottom: 5px;
}

.form-helper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.form-text,
.char-counter,
.char-counter-topic {
    font-size: 0.875rem;
    color: #666;
}

/* Pola tekstowe i textarea */
.form-section input[type="text"],
.form-section input[type="date"],
.form-section input[type="email"],
.form-section select,
.form-section textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: 'Fredoka', Arial, sans-serif;
    font-weight: 300;
}

.form-section input[type="text"]:focus,
.form-section input[type="date"]:focus,
.form-section input[type="email"]:focus,
.form-section select:focus,
.form-section textarea:focus {
    border-color: #f86969;
    outline: none;
}

textarea {
    height: 100px;
    resize: vertical;
}

/* Checkboxy i etykiety */
.checkbox-container {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

.checkbox-container input[type="checkbox"] {
    margin-right: 10px;
}

/* Pomocnicze ikony */
.label-container {
    display: flex;
    align-items: center;
}

.help-icon {
    display: inline-block;
    margin-left: 5px;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
}

.help-icon::after {
    content: attr(data-title);
    display: none;
    background: #000;
    color: #fff;
    padding: 5px;
    border-radius: 5px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 150%;
    white-space: normal;
    z-index: 1;
    width: 200px;
    text-align: center;
}

.help-icon:hover::after {
    display: block;
}

.help-icon i {
    color: #000000;
    font-size: 14px;
}

#postalCode {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

#postalCode:focus {
    border-color: #f86969;
    outline: none;
}

/* Sekcja ocen szczegółowych */
.rating-section {
    border: 1px solid #ddd;
    padding: 20px;
    margin-bottom: 20px;
    width: auto;
}

.rating-section legend {
    font-size: 20px;
    color: #333;
    margin-bottom: 10px;
}

label.form-descriptions {
    display: block;
    text-align: justify;
    margin-bottom: 15px; /* Opcjonalnie, aby dodać odstęp poniżej tekstu */
}

.detailed-rating {
    margin-bottom: 20px;
    margin-top: 20px;
}

.detailed-rating label {
    display: block;
    margin-bottom: 5px;
}
/* Detailed Rating Fields */
.detailed-rating input[type="email"],
.detailed-rating input[type="text"],
.detailed-rating textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: 'Fredoka', Arial, sans-serif;
    font-weight: 300;
}

.detailed-rating input[type="email"]:focus,
.detailed-rating input[type="text"]:focus,
.detailed-rating textarea:focus {
    border-color: #f86969;
    outline: none;
}

.detailed-rating label {
    margin-bottom: 5px;
}

/* Adjustments for .rating-section */
.rating-section {
    padding: 20px;
    margin-bottom: 20px;
    overflow: hidden; /* Zapobiega wyciekaniu elementów */
}

/* Media queries for smaller screens */
@media (max-width: 768px) {
    .rating-section {
        padding: 15px;
    }
    
    .detailed-rating textarea {
        height: auto; /* Pozwól wysokości dostosować się */
    }
}

label.detailed-title {
    margin-bottom: -5px;
    font-size: 16px;
    font-family: 'Fredoka', Arial, sans-serif;
}
/* Ocena gwiazdkowa */
.star-rating {
    display: inline-block;
}

.star-rating input[type="radio"] {
    display: none;
}

.star-rating > label {
    display: inline-block;
    cursor: pointer;
    color: #ccc;
    transition: color 0.2s;
    float: right;
}

.star-rating label {
    font-size: 30px;
    margin-bottom: 0;
}

.star-rating > input:checked ~ label,
.star-rating > label:hover,
.star-rating > label:hover ~ label {
    color: #f5a623;
}

.verifyReviewText {
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 10px;
    margin-top: 20px;
}

/* Pola specjalne (numer księgi wieczystej) */
.books-number-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    font-family: 'Fredoka', Arial, sans-serif;
}

.books-number-container select,
.books-number-container input[type="text"],
.books-number-container .slash {
    margin: 5px 2px; /* Minimalne marginesy dla odstępów */
    font-family: 'Fredoka', Arial, sans-serif;
}

.books-number-container select,
.books-number-container input[type="text"] {
    flex: 1;
    min-width: 0; /* Pozwala polom na kurczenie się poniżej domyślnej szerokości */
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: 'Fredoka', Arial, sans-serif;
}

.books-number-container .slash {
    font-size: 18px;
}

#booksNumberContainer {
    transition: all 0.3s ease;
}

#booksNumberContainer.hidden {
    display: none;
}

/* Ukrywanie kontenera numeru księgi wieczystej */
/* Stylizacja pól, gdy są dezaktywowane */
input:disabled, select:disabled {
    background-color: #f0f0f0;
    color: #888;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .books-number-container {
        flex-direction: column;
        align-items: stretch;
    }

    .books-number-container select,
    .books-number-container input[type="text"],
    .books-number-container .slash {
        margin: 5px 0;
    }

    .books-number-container .slash {
        display: none; /* Opcjonalnie można ukryć slashe na bardzo małych ekranach */
    }
}


/* Obszar przeciągania i upuszczania */
#photos {
    display: none;
}

/* Stylizacja #drop-area */
#drop-area {
    border: 2px dashed #ccc;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    margin-top: 10px;
    position: relative;
}

#drop-area.dragging {
    background-color: #f0f0f0;
}

/* Stylizacja etykiety jako przycisku */
.file-input-label {
    display: inline-block;
    cursor: pointer;
}

.file-input-button {
    background-color: #f86969;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-family: 'Fredoka', Arial, sans-serif;
    font-weight: 500;
    font-size: 16px;
    text-decoration: none;
}

.file-input-button:hover {
    background-color: #7a3d3d;
}


/* Tekst w obszarze przeciągania */
.drop-area-text {
    display: inline-block;
    font-size: 16px;
    color: #666;
}

/* Stylizacja podczas przeciągania */
#drop-area.dragging {
    background-color: #f0f0f0;
}

/* Dostosowanie dla mniejszych ekranów */
@media (max-width: 600px) {
    .file-input-button {
        font-size: 14px;
        padding: 8px 16px;
    }

    .drop-area-text {
        font-size: 14px;
        margin-top: 10px;
    }
}

/* Galeria zdjęć */
#gallery {
    display: flex;
    flex-wrap: wrap;
    margin-top: 10px;
}

.gallery-item {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 5px;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

/* Stylizacja nakładki z tekstem "Główne zdjęcie" */
.gallery-item .main-photo-label {
    display: none;
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: rgba(248, 105, 105, 0.8);
    color: white;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}

/* Wyświetlanie nakładki tylko na wybranym zdjęciu */
.gallery-item.selected-main-photo .main-photo-label {
    display: block;
}

/* Dodatkowe podkreślenie ramką */
.gallery-item.selected-main-photo {
    border: 2px solid #f86969;
}

.main-photo-info {
    font-size: 14px;
    color: #666;
    margin-top: 10px;
    display: none; /* Domyślnie ukryty */
}

/* Przycisk usuwania zdjęcia */
.remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: red;
    color: white;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    z-index: 10;
}

.gallery-item:hover .remove-btn {
    display: block;
}

/* Link do regulaminu */
.regulamin-link {
    text-decoration: none;
    color: #f86969;
}

.regulamin-link:hover {
    text-decoration: underline;
}

label {
    display: inline-block; /* Ustawia blokowy układ dla każdego label */
    position: relative; /* Aby zachować kontrolę nad zawartością */
    margin-bottom: 10px;
    margin-top: 3px;
    cursor: pointer;
}

label input[type="checkbox"] {
    vertical-align: middle; /* Wyrównuje checkbox do środka tekstu */
    margin-top: 0px; /* Dostosowuje pozycję checkboxa względem tekstu */
    margin-bottom: 4px;
    margin-right: 2px; /* Odstęp między checkboxem a tekstem */
    cursor: pointer;
}

label a {
    color: #f86969;
    text-decoration: none;
}

label a:hover {
    text-decoration: underline;
}


.checkbox-desc {
    font-size: small;
    margin-top: 5px;
    margin-bottom: 5px;
    text-align: justify;
    font-family: 'Fredoka', Arial, sans-serif;
}

/* Przyciski */
#buttonSubmit {
    width: 100%;
    padding: 10px;
    background-color: #f86969;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Fredoka', Arial, sans-serif;
    font-weight: 500;
    font-size: 18px;
    margin-top: 20px;
}

#buttonSubmit:hover {
    background-color: #7a3d3d;
}

/* Styl dla przycisku podczas ładowania */
button.loading {
    position: relative;
    cursor: not-allowed;
    opacity: 0.7;
}

button.loading::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

.error-message {
    color: red;
    margin-top: 10px;
}

/* Animacja spinnera */
@keyframes spinner {
    to { transform: rotate(360deg); }
}


.invalid-shake {
    border: 2px solid red;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25%, 75% {
        transform: translateX(-5px);
    }
    50% {
        transform: translateX(5px);
    }
}


/* Media Queries dla responsywności */
@media (max-width: 768px) {
    /* Formularz główny */
    #ratingForm {
        margin: 10px auto;
        padding: 15px;
        min-height: 100vh;
    }

    /* Pola tekstowe */
    .form-section input[type="text"],
    .form-section input[type="date"],
    .form-section input[type="email"],
    .form-section select,
    .form-section textarea {
        font-size: 16px;
    }

    /* Sekcja ocen szczegółowych */
    .star-rating {
        font-size: 30px;
    }

    /* Obszar przeciągania i upuszczania */
    #gallery {
        justify-content: center;
    }

    .gallery-item {
        width: 80px;
        height: 80px;
    }

    /* Przyciski */
    #buttonSubmit {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    /* Nagłówki */
    h1.addReviewTitle {
        font-size: 22px;
    }

    /* Pola tekstowe */
    .form-section input[type="text"],
    .form-section input[type="date"],
    .form-section input[type="email"],
    .form-section select,
    .form-section textarea {
        font-size: 14px;
    }

    /* Sekcja ocen szczegółowych */
    .star-rating {
        font-size: 30px;
    }

    /* Przyciski */
    #buttonSubmit {
        font-size: 14px;
    }
}

/* Ukryj objaśnienia domyślnie */
.field-explanation {
    display: none;
    font-size: 0.875rem;
    color: #666;
    margin-top: 5px;
}

/* Wyświetl objaśnienie, gdy pole jest w focusie */
.form-section input:focus + .field-explanation,
.form-section select:focus + .field-explanation,
.form-section textarea:focus + .field-explanation {
    display: block;
}

@media (max-width: 768px) {
    .field-explanation {
        font-size: 0.8rem;
    }
}

input, select, textarea {
    scroll-margin-top: 300px; /* Zastąp 100px rzeczywistą wysokością nagłówka */
}