/* Common Styles for All Form Pages */

* {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    text-align: right;
    box-sizing: border-box;
}

/* Force RTL for all text elements */
body, div, span, p, label, input, textarea, select, option {
    direction: rtl;
    text-align: right;
}

body {
    background: linear-gradient(135deg, #f1f1ed 0%, #d5cbbe 100%);
    min-height: 100vh;
    padding: 20px;
    margin: 0;
}

.form-container {
    max-width: 700px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(180, 172, 167, 0.15);
    padding: 40px;
    border: 2px solid #d5cbbe;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

/* Make the logo fill the form width but never overflow */
.logo-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    display: block;
}

.form-title {
    color: #0d0d0d;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(13, 13, 13, 0.1);
    white-space: nowrap; /* keep the brand line on one line */
}

.form-subtitle {
    color: #b4aca7;
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 30px;
    font-weight: 400;
}

.section-title {
    color: #0d0d0d;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(13, 13, 13, 0.1);
}

.field-group {
    margin-bottom: 25px;
}

.field-label {
    color: #0d0d0d;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 8px;
    display: block;
    text-align: right;
}

.required::after {
    content: " *";
    color: #b4aca7;
    font-weight: bold;
}

/* Input Styles */
input[type="text"], 
input[type="tel"], 
input[type="email"], 
textarea {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #cebfa8;
    border-radius: 12px;
    font-size: 16px;
    background: #f1f1ed;
    transition: all 0.3s ease;
    direction: rtl;
    text-align: right;
    color: #0d0d0d;
}

/* Improve number, date and datetime inputs to match other inputs */
input[type="number"],
input[type="datetime-local"],
input[type="date"] {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #cebfa8;
    border-radius: 12px;
    font-size: 16px;
    background: #f1f1ed;
    transition: all 0.3s ease;
    color: #0d0d0d;
    direction: ltr;
    text-align: left;
}

/* Normalize native date input across browsers (especially iOS Safari) */
input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
}
input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.8;
    cursor: pointer;
}

input[type="tel"] {
    direction: rtl;
    text-align: right;
}

/* Email input should be LTR like typical email addresses */
input[type="email"] {
    direction: ltr;
    text-align: left;
}

/* Phone input placeholder should be right-aligned for RTL consistency */
input[type="tel"]::placeholder {
    direction: rtl;
    text-align: right;
}

input:focus, textarea:focus {
    border-color: #b4aca7;
    box-shadow: 0 0 0 3px rgba(180, 172, 167, 0.1);
    outline: none;
    background: white;
}

/* Ensure input placeholders are right-aligned for Hebrew text */
input[type="text"]::placeholder {
    direction: rtl;
    text-align: right;
}

/* Email placeholder (if used) should be LTR */
input[type="email"]::placeholder {
    direction: ltr;
    text-align: left;
}

/* Select Styles */
select {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #cebfa8;
    border-radius: 12px;
    font-size: 16px;
    background: #f1f1ed;
    transition: all 0.3s ease;
    direction: rtl;
    text-align: right;
    color: #0d0d0d;
}

select:focus {
    border-color: #b4aca7;
    box-shadow: 0 0 0 3px rgba(180, 172, 167, 0.1);
    outline: none;
    background: white;
}

/* Ensure select options are right-aligned */
select option {
    direction: rtl;
    text-align: right;
}

/* Radio and Checkbox Styles */
.radio-group, .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-option, .checkbox-option {
    background: #f1f1ed;
    border: 2px solid #cebfa8;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    color: #0d0d0d;
    text-align: right;
}

.radio-option:hover, .checkbox-option:hover {
    background: #d5cbbe;
    border-color: #b4aca7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(180, 172, 167, 0.15);
}

.radio-option.selected, .checkbox-option.selected {
    background: #b4aca7;
    color: white;
    border-color: #cebfa8;
}

/* Ensure text inside radio/checkbox options is properly aligned */
.radio-option span, .checkbox-option span {
    text-align: right;
    direction: rtl;
    /* Ensure the text takes the full width of the container so multi-line
       labels stay flush to the right edge */
    display: block;
    width: 100%;
    /* Fix Hebrew text rendering */
    unicode-bidi: isolate;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Collapsible dropdown styles */
.dropdown-container {
    position: relative;
    width: 100%;
}

.dropdown-header {
    background: #f1f1ed;
    border: 2px solid #cebfa8;
    border-radius: 12px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #0d0d0d;
    font-size: 16px;
    font-weight: 500;
    width: 100%;
}

.dropdown-header:hover {
    background: #d5cbbe;
    border-color: #b4aca7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(180, 172, 167, 0.15);
}

.dropdown-header.selected {
    background: #b4aca7;
    color: white;
    border-color: #cebfa8;
}

.dropdown-arrow {
    transition: transform 0.3s ease;
    font-size: 18px;
    font-weight: bold;
}

.dropdown-arrow.open {
    transform: rotate(180deg);
}

.dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 12px rgba(180, 172, 167, 0.15);
    z-index: 1000;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.dropdown-options.open {
    /* Unified rule: all dropdowns respect a configurable max height */
    max-height: var(--dropdown-max-height, min(50vh, 360px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}


.dropdown-option {
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid #f1f1ed;
    color: #0d0d0d;
    text-align: right;
    direction: rtl;
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option:hover {
    background: #f1f1ed;
}

.dropdown-option.selected {
    background: #b4aca7;
    color: white;
}

/* removed pest dropdown specific styles */

/* Compact collapsible controls (date/time folds) */
.collapsible {
    margin: 8px 0;
}

.collapsible-header {
    background: #f1f1ed;
    border: 2px solid #cebfa8;
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #0d0d0d;
    font-size: 16px;
    font-weight: 500;
    width: 100%;
}

.collapsible-header:hover {
    background: #d5cbbe;
    border-color: #b4aca7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(180, 172, 167, 0.15);
}

.collapsible-header.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.collapsible-arrow {
    transition: transform 0.3s ease;
    font-size: 18px;
    font-weight: bold;
}

.collapsible.open .collapsible-arrow {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible.open .collapsible-content {
    max-height: 500px;
    padding-top: 10px;
}

.collapsible.disabled .collapsible-content {
    max-height: 0 !important;
}

.selected-datetime-pill {
    display: inline-block;
    background: #f7f6f3;
    color: #0d0d0d;
    border: 2px solid #d5cbbe;
    border-radius: 16px;
    padding: 10px 14px;
    margin-top: 12px;
    font-size: 16px;
    direction: ltr;
    text-align: left;
}

/* Button Styles */
.next-button, .submit-button {
    background: linear-gradient(135deg, #b4aca7 0%, #cebfa8 100%);
    color: white;
    border: none;
    padding: 18px 40px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.next-button:hover, .submit-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(180, 172, 167, 0.3);
    background: linear-gradient(135deg, #cebfa8 0%, #b4aca7 100%);
}

.next-button:disabled, .submit-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Textarea Styles */
textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

/* Make the accident/event description easier to scroll and read */
.textarea-wrapper {
    position: relative;
    overflow: hidden; /* ensure custom rail does not spill outside rounded frame */
    border-radius: 12px; /* match input radius so rail is clipped neatly */
}

/* Keep native scroll functional but hide its chrome while keeping space */
#event_description {
    /* Larger default area and clear scrolling */
    min-height: 120px;
    max-height: min(50vh, 360px);
    overflow-y: scroll; /* reserve scrollbar space so it's present when overflowing */
    -webkit-overflow-scrolling: touch; /* smooth momentum scroll on iOS */
    scrollbar-gutter: stable both-edges; /* reserve gutter and avoid layout shifts */
    /* Improve readability */
    line-height: 1.5;
    /* Thicker, visible scrollbar for supporting browsers */
    scrollbar-width: auto; /* Firefox: thicker than thin */
    scrollbar-color: #cebfa8 transparent;
    /* Hide native scrollbar visually (WebKit) while preserving scroll mechanics */
    scrollbar-width: none; /* Firefox hide */
}

/* WebKit scrollbar styling */
#event_description::-webkit-scrollbar { width: 0; height: 0; }

/* Custom scrollbar (always visible) */
.custom-scrollbar {
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 6px; /* RTL: keep inside the field */
    width: 12px; /* slimmer to avoid overflow feel */
    background: transparent;
    border-radius: 8px;
}

.custom-scrollbar-thumb {
    position: absolute;
    left: 0;
    width: 100%;
    min-height: 40px; /* ensures easy grabbing even with little overflow */
    background: #cebfa8;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.custom-scrollbar-thumb:hover,
.custom-scrollbar-thumb.dragging {
    background: #b4aca7;
}

/* Ensure textarea placeholder is right-aligned */
textarea::placeholder {
    direction: rtl;
    text-align: right;
}

/* File input (upload) styles */
input[type="file"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #cebfa8;
    border-radius: 12px;
    font-size: 16px;
    background: #f1f1ed;
    transition: all 0.3s ease;
    color: #0d0d0d;
}

input[type="file"]:hover {
    background: #ffffff;
    border-color: #b4aca7;
    box-shadow: 0 4px 12px rgba(180, 172, 167, 0.15);
}

input[type="file"]:focus {
    border-color: #b4aca7;
    box-shadow: 0 0 0 3px rgba(180, 172, 167, 0.1);
    outline: none;
    background: white;
}

/* Modern browsers */
input[type="file"]::file-selector-button {
    background: linear-gradient(135deg, #b4aca7 0%, #cebfa8 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    margin-inline-start: 12px; /* RTL-aware gap between text and button */
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

input[type="file"]::file-selector-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(180, 172, 167, 0.25);
    background: linear-gradient(135deg, #cebfa8 0%, #b4aca7 100%);
}

input[type="file"]::file-selector-button:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Safari fallback */
input[type="file"]::-webkit-file-upload-button {
    background: linear-gradient(135deg, #b4aca7 0%, #cebfa8 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    margin-inline-start: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

input[type="file"]::-webkit-file-upload-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(180, 172, 167, 0.25);
    background: linear-gradient(135deg, #cebfa8 0%, #b4aca7 100%);
}

/* Custom file upload UI to suppress native English texts */
.file-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f1f1ed;
    border: 2px solid #cebfa8;
    border-radius: 12px;
    padding: 12px 16px;
    position: relative;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    pointer-events: none; /* hide native control and its English text while keeping it in-flow to avoid scroll jumps */
}

.file-upload-button {
    background: linear-gradient(135deg, #b4aca7 0%, #cebfa8 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    white-space: nowrap;
}

.file-upload-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(180, 172, 167, 0.25);
    background: linear-gradient(135deg, #cebfa8 0%, #b4aca7 100%);
}

.file-upload-text {
    color: #0d0d0d;
    flex: 1;
    text-align: right;
    direction: rtl;
}

/* removed unused pest photos preview styles */

/* Fullscreen overlay shown while uploading/submitting */
.uploading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.uploading-box {
    background: #fff;
    border: 2px solid #cebfa8;
    border-radius: 12px;
    padding: 18px 22px;
    box-shadow: 0 10px 30px rgba(180, 172, 167, 0.25);
    color: #0d0d0d;
    display: flex;
    align-items: center;
    gap: 12px;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #dcd4c9;
    border-top-color: #b4aca7;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Section-specific styles */
.pest-control-section, .scent-section, .shared-fields-section {
    border-right: 4px solid #b4aca7;
    background: linear-gradient(90deg, #f1f1ed 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 20px;
    margin: 15px 0;
}

/* Flatpickr overrides to match theme and RTL */
.flatpickr-calendar {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    text-align: right;
    border: 2px solid #cebfa8;
    box-shadow: 0 10px 30px rgba(180, 172, 167, 0.15);
    border-radius: 12px;
}

.flatpickr-months, .flatpickr-weekdays {
    direction: rtl;
}

.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange {
    background: #b4aca7;
    border-color: #b4aca7;
    color: #fff;
}

.flatpickr-day:hover {
    background: #d5cbbe;
}

/* Neutralize any theme greens by overriding Flatpickr accent elements */
.flatpickr-months .flatpickr-prev-month, 
.flatpickr-months .flatpickr-next-month, 
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month .numInputWrapper input,
.flatpickr-weekday,
.flatpickr-day.inRange,
.flatpickr-day.today {
    color: #0d0d0d;
    border-color: #cebfa8;
}

.flatpickr-day.today {
    border: 2px solid #cebfa8 !important;
}

.flatpickr-months .flatpickr-prev-month:hover svg, 
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: #0d0d0d;
}

.flatpickr-months .flatpickr-prev-month svg, 
.flatpickr-months .flatpickr-next-month svg {
    fill: #0d0d0d;
}

.flatpickr-weekdays {
    color: #0d0d0d;
}

.flatpickr-months .flatpickr-month {
    color: #0d0d0d;
}

.flatpickr-calendar .flatpickr-months .flatpickr-monthDropdown-months, 
.flatpickr-calendar .numInputWrapper input {
    background: #fff;
    border: 1px solid #cebfa8;
    border-radius: 8px;
}

.flatpickr-days {
    background: #fff;
}

.flatpickr-time .numInput, .flatpickr-time input.flatpickr-hour, .flatpickr-time input.flatpickr-minute {
    direction: ltr;
    text-align: left;
}

.flatpickr-current-month .flatpickr-monthDropdown-months, 
.flatpickr-current-month .numInputWrapper input {
    direction: rtl;
    text-align: right;
}

.flatpickr-time .flatpickr-time-separator {
    padding: 0 4px;
}

/* removed unused time slot grid styles */

/* Ensure visible Flatpickr alt input (D/M/Y) is LTR and left-aligned */
.flatpickr-input[readonly].input, .flatpickr-alt-input {
    direction: ltr !important;
    text-align: left !important;
}

/* Hide native numeric year input since we provide a nicer year dropdown */
.flatpickr-current-month .numInputWrapper { display: none !important; }

/* Ensure month and custom year select are side-by-side and centered */
.flatpickr-current-month {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Mobile tuning */
@media (max-width: 768px) {
    body {
        /* Reduce side padding on mobile to maximize usable width */
        padding: 12px 10px 20px;
    }

    /* removed mobile overrides for time slot grid */

    /* Make the form container edge-to-edge on mobile (remove bezels/frames) */
    .form-container {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 16px 12px;
        border: none;
        border-radius: 12px;
        box-shadow: none;
        background: white;
    }

    /* Reduce inner section framing on mobile */
    .pest-control-section, .scent-section, .shared-fields-section {
        border-right: none;
        background: linear-gradient(90deg, #f1f1ed 0%, #ffffff 100%);
        padding: 12px 0;
    }
    .logo-container { gap: 8px; }
    /* Keep logo responsive on mobile without overflow */
    .logo-container img { width: 100% !important; max-width: 100% !important; height: auto; }
    
    /* Mobile-specific tuning for the description field */
    #event_description {
        /* Slightly taller and bounded by viewport height */
        min-height: 140px;
        max-height: 45vh;
        touch-action: pan-y; /* hint that vertical scrolling is intended */
    }
    .custom-scrollbar { width: 14px; left: 6px; }
    .custom-scrollbar-thumb { border-radius: 9px; }
}

/* Mobile/Desktop visibility classes */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
    
    .form-container {
        padding: 16px 12px; /* keep compact padding */
        margin: 0; /* remove side margins for full-width */
    }
    
    .form-title {
        /* scale down on smaller screens to prevent wrapping */
        font-size: clamp(1rem, 4.6vw, 1.6rem);
    }
    .section-title {
        font-size: 1.8rem;
    }
    
    input, textarea, select {
        padding: 12px 15px;
    }
    
    .next-button, .submit-button {
        padding: 15px 30px;
        font-size: 1.1rem;
    }
}

/* removed unused WhatsApp widget styles */

select.flatpickr-year-select {
    margin-inline-start: 8px;
    padding: 4px 8px;
    border: 1px solid #cebfa8;
    border-radius: 8px;
    background: #fff;
    color: #0d0d0d;
    font-size: 0.95rem;
}
select.flatpickr-year-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(180, 172, 167, 0.15);
    border-color: #b4aca7;
}

/* Footer with privacy link */
.site-footer {
    max-width: 700px;
    margin: 16px auto 0;
    color: #0d0d0d;
    font-size: 0.95rem;
    text-align: center;
}
.site-footer a {
    color: #0d0d0d;
    text-decoration: underline;
}
.site-footer small { color: #7b736c; }
