/**
 * ShareTools - Styles Autocomplétion Code Postal
 * Fichier centralisé utilisé par tous les formulaires
 */

/* ========================================
   CONTENEUR PRINCIPAL
   ======================================== */

.postal-autocomplete {
    position: relative;
    width: 100%;
}

.postal-input-wrapper {
    position: relative;
}

/* ========================================
   INPUT
   ======================================== */

.postal-input {
    width: 100%;
    padding: 12px 16px;
    padding-right: 44px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
}

.postal-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.postal-input::placeholder {
    color: #999;
}

.postal-input.has-selection {
    border-color: #27ae60;
    background: #f0fff4;
}

.postal-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    color: #666;
}

/* ========================================
   ICÔNE
   ======================================== */

.postal-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: color 0.3s;
}

.postal-icon.success {
    color: #27ae60;
}

.postal-icon svg {
    width: 18px;
    height: 18px;
}

/* Spinner de chargement */
.postal-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: postal-spin 0.8s linear infinite;
}

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

/* ========================================
   LISTE DE SUGGESTIONS
   ======================================== */

.postal-suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    padding: 6px;
    display: none;
}

.postal-suggestions.active {
    display: block;
    animation: postal-slideDown 0.2s ease;
}

@keyframes postal-slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar personnalisée */
.postal-suggestions::-webkit-scrollbar {
    width: 6px;
}

.postal-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.postal-suggestions::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.postal-suggestions::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ========================================
   SUGGESTION INDIVIDUELLE
   ======================================== */

.postal-suggestion {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.postal-suggestion:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
}

.postal-suggestion:active {
    transform: scale(0.98);
}

/* Badge avec code département */
.postal-suggestion-badge {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Informations */
.postal-suggestion-info {
    flex: 1;
    min-width: 0;
}

.postal-suggestion-main {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.postal-suggestion-code {
    color: #667eea;
    font-weight: 700;
}

.postal-suggestion-city {
    color: #333;
}

.postal-suggestion-district {
    color: #888;
    font-weight: 400;
}

.postal-suggestion-region {
    font-size: 12px;
    color: #888;
}

/* ========================================
   AUCUN RÉSULTAT
   ======================================== */

.postal-no-results {
    padding: 24px;
    text-align: center;
    color: #888;
}

.postal-no-results-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.postal-no-results-text {
    font-size: 14px;
}

/* ========================================
   BADGE DE SÉLECTION
   ======================================== */

.postal-selected {
    margin-top: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 10px;
    display: none;
}

.postal-selected.active {
    display: flex;
    align-items: center;
    gap: 12px;
    animation: postal-fadeIn 0.3s ease;
}

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

.postal-selected-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.postal-selected-icon svg {
    width: 16px;
    height: 16px;
}

.postal-selected-text {
    flex: 1;
    min-width: 0;
}

.postal-selected-label {
    font-size: 10px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.postal-selected-value {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.postal-selected-clear {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.postal-selected-clear:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #e74c3c;
}

.postal-selected-clear svg {
    width: 14px;
    height: 14px;
}

/* ========================================
   BADGE DE LOCALISATION (AFFICHAGE)
   ======================================== */

.location-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border: 1px solid rgba(102, 126, 234, 0.25);
    padding: 8px 14px;
    border-radius: 25px;
    font-size: 14px;
    color: #333;
    transition: all 0.2s;
}

.location-badge:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
}

.location-badge-icon {
    color: #667eea;
    display: flex;
    align-items: center;
}

.location-badge-icon svg {
    width: 14px;
    height: 14px;
}

.location-badge-text {
    font-weight: 500;
}

/* Version grande pour agregar-herramienta */
.location-badge-lg {
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 15px;
}

.location-badge-lg .location-badge-icon svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   TEXTE D'AIDE
   ======================================== */

.postal-help {
    font-size: 12px;
    color: #888;
    margin-top: 6px;
}

.postal-help.success {
    color: #27ae60;
}

.postal-help.error {
    color: #e74c3c;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .postal-input {
        padding: 14px 16px;
        padding-right: 44px;
        font-size: 16px; /* Empêche le zoom sur iOS */
    }

    .postal-suggestions {
        max-height: 250px;
    }

    .postal-suggestion {
        padding: 14px 12px;
    }

    .postal-suggestion-badge {
        width: 40px;
        height: 40px;
        font-size: 11px;
    }

    .postal-suggestion-main {
        font-size: 13px;
    }

    .postal-suggestion-region {
        font-size: 11px;
    }

    .postal-selected {
        padding: 10px 14px;
    }

    .location-badge {
        padding: 6px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .postal-suggestion-badge {
        width: 36px;
        height: 36px;
        font-size: 10px;
    }

    .postal-suggestion {
        gap: 10px;
    }
}
