/**
 * CPA Calculateur d'Itinéraire - Styles
 *
 * Designed to integrate seamlessly with the existing
 * camping-parc-aquatique.fr theme (Bootstrap-like grid,
 * default-padding, container large, etc.)
 */

/* =========================================
   Section wrapper
   ========================================= */
.cpa-itineraire-section {
    background-color: #fff;
    padding-top: 3rem;
    padding-bottom: 3rem;
}

body .cpa-itineraire-title {
    font-size: 1.6rem;
    font-family: 'Nunito';
    font-style: normal;
    font-size: 2.3rem;
    line-height: 48px;
    text-align: center;
    letter-spacing: .03em;
    color: var(--bleufonce);
    margin: 1.5rem 0;
    text-transform: none;
}

.cpa-itineraire-intro {
    text-align: center;
    color: #555;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* =========================================
   Form
   ========================================= */
.cpa-itineraire-form {
    margin-bottom: 1.5rem;
}

.cpa-itineraire-input-group {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.cpa-itineraire-input-wrapper {
    flex: 1;
    position: relative;
}

.cpa-itineraire-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #ccc;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.cpa-itineraire-input:focus {
    border-color: #2c3f58;
    box-shadow: 0 0 0 3px rgba(44, 63, 88, 0.15);
}

/* Autocomplete suggestions */
.cpa-itineraire-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cpa-itineraire-suggestions.active {
    display: block;
}

.cpa-itineraire-suggestions li {
    padding: 0.65rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s ease;
}

.cpa-itineraire-suggestions li:last-child {
    border-bottom: none;
}

.cpa-itineraire-suggestions li:hover,
.cpa-itineraire-suggestions li.active {
    background-color: #e8eef5;
    color: #2c3f58;
}

.cpa-itineraire-suggestions li .cpa-suggestion-context {
    display: block;
    font-size: 0.78rem;
    color: #888;
    margin-top: 2px;
}

/* Geolocate button */
.cpa-itineraire-btn-geo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: #fff;
    color: #2c3f58;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cpa-itineraire-btn-geo:hover {
    border-color: #2c3f58;
    background: #e8eef5;
}

.cpa-itineraire-btn-geo.loading {
    animation: cpa-pulse 1s infinite;
}

@keyframes cpa-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Submit button */
.cpa-itineraire-btn-submit {
    width: 100%;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, #2c3f58, #3a5575);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cpa-itineraire-btn-submit:hover:not(:disabled) {
    background: linear-gradient(135deg, #1e3247, #2c3f58);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 63, 88, 0.3);
}

.cpa-itineraire-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cpa-itineraire-btn-submit.loading {
    position: relative;
    color: transparent;
}

.cpa-itineraire-btn-submit.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cpa-spin 0.6s linear infinite;
}

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

/* =========================================
   Results panel
   ========================================= */
.cpa-itineraire-results {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    animation: cpa-fadeIn 0.3s ease;
}

@keyframes cpa-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.cpa-itineraire-result-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e8eef5;
}

.cpa-itineraire-summary {
    font-size: 1.15rem;
    font-weight: 600;
    color: #2c3f58;
}

.cpa-itineraire-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.cpa-itineraire-result-item {
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.75rem;
    background: #f9f9f9;
    border-radius: 8px;
}

.cpa-itineraire-result-icon {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

.cpa-itineraire-result-label {
    font-size: 0.78rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0.15rem;
}

.cpa-itineraire-result-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

.cpa-itineraire-result-total {
    background: #e8eef5;
}

.cpa-itineraire-result-total .cpa-itineraire-result-value {
    color: #2c3f58;
    font-size: 1.25rem;
}

.cpa-itineraire-result-co2 {
    background: #f0f3f7;
}

/* Google Maps CTA */
.cpa-itineraire-btn-gmaps {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: #4285f4;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-bottom: 1rem;
    box-sizing: border-box;
}

.cpa-itineraire-btn-gmaps:hover {
    background: #3367c7;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
    color: #fff;
    text-decoration: none;
}

/* SEO text */
.cpa-itineraire-seo-text {
    font-size: 0.88rem;
    color: #666;
    line-height: 1.5;
    margin: 0;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
}

/* =========================================
   Error message
   ========================================= */
.cpa-itineraire-error {
    background: #fff3f3;
    color: #c0392b;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid #f5c6cb;
    margin-top: 1rem;
}

/* =========================================
   Map
   ========================================= */
.cpa-itineraire-map {
    width: 100%;
    height: 400px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    background: #e8e8e8;
    position: relative;
}

/* Leaflet override to respect border-radius */
.cpa-itineraire-map .leaflet-container {
    border-radius: 12px;
}

/* =========================================
   Responsive
   ========================================= */

/* Force flex layout on the row inside our section
   (the theme's .row class does not use display:flex) */
.cpa-itineraire-section .row {
    display: flex;
    flex-wrap: nowrap;
}

/* Neutralise the theme's clearfix pseudo-elements which act as
   invisible flex items and force columns to wrap onto new lines */
.cpa-itineraire-section .row::before,
.cpa-itineraire-section .row::after {
    display: none;
}

/* Custom grid for this section (matches theme's Bootstrap-like approach) */
.cpa-itineraire-form-col,
.cpa-itineraire-map-col {
    padding: 0 15px;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .cpa-itineraire-form-col {
        flex: 0 0 41.666%;
        max-width: 41.666%;
    }
    .cpa-itineraire-map-col {
        flex: 0 0 58.333%;
        max-width: 58.333%;
    }
}

@media (max-width: 767px) {
    .cpa-itineraire-section .row {
        flex-wrap: wrap;
    }

    .cpa-itineraire-section {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .cpa-itineraire-title {
        font-size: 1.3rem;
    }

    .cpa-itineraire-form-col,
    .cpa-itineraire-map-col {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .cpa-itineraire-map {
        height: 300px;
        margin-top: 1.5rem;
    }

    .cpa-itineraire-result-grid {
        grid-template-columns: 1fr;
    }

    .cpa-itineraire-btn-gmaps {
        font-size: 0.9rem;
        padding: 0.85rem 1rem;
    }
}