/**
 * Frontend Styles - Leaflet Map & Form Enhancements
 */

/* ===========================
   Map Container
   =========================== */
#fitters-map {
    width: 100%;
    height: 700px;
    border-radius: 16px;
    z-index: 1;
}

@media (max-width: 768px) {
    #fitters-map {
        height: 450px;
    }
}

/* ===========================
   Custom Marker Icon
   =========================== */
.ffm-marker-icon {
    background: none;
    border: none;
}

.ffm-marker-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.ffm-marker-pin:hover {
    transform: scale(1.2);
}

/* Dimmed markers (filtered out) */
.ffm-marker-dimmed .ffm-marker-pin {
    opacity: 0.35;
    pointer-events: auto;
}

/* Foreign-country markers (fitters from countries other than the current page language) */
.ffm-marker-foreign .ffm-marker-pin {
    opacity: 0.6;
}

/* Highlighted markers (closest in postal search) */
.ffm-marker-highlighted .ffm-marker-pin {
    filter: drop-shadow(0 0 6px rgba(0, 163, 42, 0.5));
}

/* Search location marker */
.ffm-search-marker {
    background: none;
    border: none;
}

.ffm-search-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ffmPulse 1.5s ease-in-out infinite;
}

@keyframes ffmPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ===========================
   Popup Styles (Simplified)
   =========================== */
.ffm-popup-container .leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.ffm-popup-container .leaflet-popup-content {
    margin: 0;
    min-width: 240px;
}

.ffm-popup-container .leaflet-popup-tip {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.ffm-popup {
    padding: 1rem 2rem;
    text-align: center;
}

.ffm-popup-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}

.ffm-popup-inquiry-btn {
    display: block;
    width: 100%;
    padding: 10px;
    border-radius: 3rem;
    border: 2px solid #F57D20;
    background: none;
    color: #000;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    text-align: center;
    font-family: 'quiche-sans', sans-serif;
}

.ffm-popup-inquiry-btn:hover {
    background-color: #F57D20;
    color: #fff;
}

/* ===========================
   Search Row (postal code)
   =========================== */
.ffm-search-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.5rem;
}

.ffm-search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    width: 100%;
}

.ffm-search-input-wrapper input {
    width: 100%;
    padding-right: 2.5rem; /* Make room for clear button */
}

.ffm-search-row input {
    flex: 1;
}

.ffm-search-button {
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    border: 2px solid #F57D20;
    background: none;
    color: #000;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.ffm-search-button:hover {
    background: #F57D20;
    color: white;
}

.ffm-search-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Clear search button (X inside input) */
.ffm-clear-search-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e5e5;
    border: none;
    border-radius: 50%;
    color: #666;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    padding: 0;
}

.ffm-clear-search-btn:hover {
    background: #d4d4d4;
    color: #333;
}

.ffm-clear-search-btn:active {
    background: #c4c4c4;
}

/* Clear filters button */
.ffm-clear-filters-btn {
    display: block;
    margin-top: 1rem;
    padding: 0.4rem 1.5rem;
    border-radius: 2rem;
    border: 1px solid #999;
    background: #fff;
    color: #333;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.ffm-clear-filters-btn:hover {
    background: #f0f0f0;
    border-color: #666;
}

/* Search result message */
.ffm-search-message {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

/* ===========================
   Modal: hierarchical service structure
   =========================== */

/* Service group container (parent + children block) */
.modal-service-group {
    margin-bottom: 0.75rem;
}

/* Parent service label */
.modal-service-parent .label-text {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
}

/* Subtree container for child services */
.modal-service-subtree {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 1.5rem;
    padding-left: 2.5rem;
    row-gap: 1.5rem;
}

/* Child service label (indented) */
.modal-service-child {
    padding-left: 1.5rem;
}

.modal-service-child .label-text {
    font-size: 0.8rem;
    font-weight: 400;
}

/* ===========================
   Form Enhancements
   =========================== */
.ffm-form-messages {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.ffm-form-errors {
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.ffm-form-errors ul {
    margin: 0;
    padding: 0 0 0 18px;
}

.ffm-form-errors li {
    margin: 4px 0;
}

.ffm-form-success {
    background-color: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.ffm-form-success p {
    margin: 0;
}

.ffm-field-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15) !important;
}

.ffm-loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.ffm-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: ffmSpin 0.6s linear infinite;
}

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

/* Add more input types */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
textarea, select {
    font-family: 'Open Sans', sans-serif;
    border: 1px solid #e1e1e1;
    line-height: 30px;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 1rem;
    min-width: 87px;
}

/* File upload drag zone */
.input-file.drag-over {
    border-color: #F57D20 !important;
    background-color: rgba(200, 35, 44, 0.05) !important;
}

/* File list */
#ffm-file-list,
#ffm-inq-file-list {
    display: none;
    margin-top: 10px;
}

.ffm-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background-color: #f9f9f9;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 13px;
}

.ffm-file-item.ffm-file-invalid {
    background-color: #fef2f2;
}

.ffm-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ffm-file-size {
    color: #888;
    font-size: 12px;
}

.ffm-file-error {
    color: #dc2626;
    font-size: 12px;
    font-weight: 600;
}

/* ===========================
   Inquiry Modal Overrides
   =========================== */
#ffm-inquiry-modal {
    z-index: 10002;
}

#ffm-inquiry-modal .modal-content textarea {
    width: 100%;
    box-sizing: border-box;
}

/* ===========================
   Marker Cluster Overrides
   =========================== */
.marker-cluster-small {
    background-color: rgba(245, 125, 32, 0.2);
}

.marker-cluster-small div {
    background-color: rgba(245, 125, 32, 0.6);
    color: white;
    font-weight: 700;
}

.marker-cluster-medium {
    background-color: rgba(245, 125, 32, 0.3);
}

.marker-cluster-medium div {
    background-color: rgba(245, 125, 32, 0.7);
    color: white;
    font-weight: 700;
}

.marker-cluster-large {
    background-color: rgba(245, 125, 32, 0.4);
}

.marker-cluster-large div {
    background-color: rgba(245, 125, 32, 0.8);
    color: white;
    font-weight: 700;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 600px) {
    .ffm-popup {
        padding: 12px;
    }

    .ffm-popup-title {
        font-size: 13px;
    }

    .ffm-search-row {
        flex-direction: column;
    }

    .ffm-search-button {
        width: 100%;
    }
}

/* ===========================
   Filter Buttons
   =========================== */
#ffm-service-filters {
    list-style: none;
    padding: 0;
    margin: 0;
}

#ffm-service-filters > li {
    margin-bottom: 12px;
}

.ffm-filter-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.15rem 18px;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.375rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
    width: 100%;
    text-align: left;
    border: none;
    font-weight: 500;
}

.ffm-filter-btn.active {
    border-color: #999;
    background: transparent;
    font-weight: 700;
}

/* Orange circle indicator */
.ffm-filter-indicator {
    width: 1.9375rem;
    height: 1.9375rem;
    min-width: 1.9375rem;
    min-height: 1.9375rem;
    border-radius: 50%;
    background: transparent;
    border: 2px solid #F57D20;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.ffm-filter-btn.active .ffm-filter-indicator {
    background: #F57D20;
    border-color: #F57D20;
}

/* Sub-filter button (smaller) */
.ffm-filter-btn--sub {
    padding: 0 10px;
    font-size: 1.25rem;
}

.ffm-filter-btn--sub .ffm-filter-indicator {
    width: 1.4375rem;
    height: 1.4375rem;
    min-width: 1.4375rem;
    min-height: 1.4375rem;
}

/* Sub-filters container */
.subfilters {
    margin-top: 8px;
    margin-left: 44px;
    padding-left: 0;
    list-style: none;
}

.subfilters li {
    margin-bottom: 8px;
}

/* Mobile styles */
@media (max-width: 768px) {
    .ffm-filter-btn {
        width: 100%;
        padding: 0 16px;
        font-size: 15px;
    }
    
    .ffm-filter-btn--sub {
        padding: 0 10px;
        font-size: 14px;
    }
    
    .subfilters {
        margin-left: 44px;
        flex-direction: column;
    }
}
