/**
 * Focus Images GeoDirectory - Styles Logique Conditionnelle
 * 
 * Améliore l'expérience visuelle lors des transitions d'affichage/masquage
 * des champs selon les règles conditionnelles
 * 
 * @version 2.0.0
 */

/* ========================================
   TRANSITIONS DOUCES
   ======================================== */

/* Tous les champs custom peuvent avoir des transitions */
[class*="geodir-custom-field-"],
[data-field],
[id$="_row"] {
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

/* Animation d'apparition */
[class*="geodir-custom-field-"]:not(.fi-hidden),
[data-field]:not(.fi-hidden),
[id$="_row"]:not(.fi-hidden) {
    opacity: 1;
    max-height: 2000px;
    margin-bottom: 1em;
}

/* Animation de disparition */
[class*="geodir-custom-field-"].fi-hidden,
[data-field].fi-hidden,
[id$="_row"].fi-hidden {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
}

/* ========================================
   INDICATEURS VISUELS
   ======================================== */

/* Badge pour champs requis */
.geodir-custom-field-required::before,
.field-required::before {
    content: "*";
    color: #e74c3c;
    font-size: 1.2em;
    margin-right: 4px;
    font-weight: bold;
}

/* Highlight des champs selon catégorie */
.category-camera .geodir-custom-field-camera_type,
.category-lens .geodir-custom-field-lens_mount,
.category-drone .geodir-custom-field-drone_weight_class,
.category-lighting .geodir-custom-field-light_type,
.category-audio .geodir-custom-field-audio_type {
    border-left: 4px solid #3498db;
    padding-left: 12px;
}

/* ========================================
   GROUPEMENT DE CHAMPS
   ======================================== */

/* Section pour regrouper les champs */
.fi-field-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid #e9ecef;
}

.fi-field-section-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #3498db;
    display: flex;
    align-items: center;
}

.fi-field-section-title::before {
    content: "";
    width: 4px;
    height: 20px;
    background: #3498db;
    margin-right: 10px;
    border-radius: 2px;
}

/* ========================================
   CHAMPS GLOBAUX (toujours visibles)
   ======================================== */

.fi-global-fields {
    background: #fff;
    border: 2px solid #3498db;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.fi-global-fields-title {
    font-size: 1.2em;
    font-weight: 700;
    color: #3498db;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
}

.fi-global-fields-title::before {
    content: "🌍";
    margin-right: 8px;
    font-size: 1.3em;
}

/* ========================================
   ÉTATS DES CHAMPS
   ======================================== */

/* Champ en cours d'édition */
.geodir-custom-field:focus-within,
[data-field]:focus-within {
    background: #f0f8ff;
    border-radius: 4px;
    padding: 8px;
    margin: -8px;
}

/* Champ valide (avec contenu) */
.geodir-custom-field.has-value input,
.geodir-custom-field.has-value select,
.geodir-custom-field.has-value textarea {
    border-left: 3px solid #27ae60;
}

/* Champ invalide (requis mais vide) */
.geodir-custom-field.is-invalid input,
.geodir-custom-field.is-invalid select,
.geodir-custom-field.is-invalid textarea {
    border-left: 3px solid #e74c3c;
    background: #fff5f5;
}

/* Message d'erreur */
.fi-field-error {
    color: #e74c3c;
    font-size: 0.9em;
    margin-top: 4px;
    display: none;
    animation: shake 0.3s;
}

.geodir-custom-field.is-invalid .fi-field-error {
    display: block;
}

/* ========================================
   TOOLTIPS & AIDE
   ======================================== */

/* Info bulle pour champs */
.fi-field-help {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: #3498db;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 18px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 6px;
    cursor: help;
    position: relative;
}

.fi-field-help:hover::after {
    content: attr(data-help);
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 13px;
    font-weight: normal;
    margin-bottom: 8px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.fi-field-help:hover::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2c3e50;
    margin-bottom: 2px;
}

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

@media (max-width: 768px) {
    .fi-field-section {
        padding: 16px;
        margin-bottom: 16px;
    }

    .fi-field-section-title {
        font-size: 1em;
    }

    .fi-global-fields {
        padding: 16px;
    }

    .fi-field-help:hover::after {
        white-space: normal;
        max-width: 200px;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

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

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

/* Animation sur apparition */
.fi-animating-in {
    animation: fadeIn 0.3s ease-out;
}

/* Animation sur disparition */
.fi-animating-out {
    animation: fadeOut 0.3s ease-out;
}

/* ========================================
   LOADING STATES
   ======================================== */

/* Overlay de chargement */
.fi-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.fi-loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.fi-loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   BADGES DE CATÉGORIE
   ======================================== */

.fi-category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    margin-right: 8px;
    margin-bottom: 8px;
}

.fi-category-badge.camera {
    background: #e3f2fd;
    color: #1976d2;
}

.fi-category-badge.lens {
    background: #f3e5f5;
    color: #7b1fa2;
}

.fi-category-badge.drone {
    background: #e8f5e9;
    color: #388e3c;
}

.fi-category-badge.lighting {
    background: #fff3e0;
    color: #f57c00;
}

.fi-category-badge.audio {
    background: #fce4ec;
    color: #c2185b;
}

.fi-category-badge.support {
    background: #e0f2f1;
    color: #00796b;
}

/* ========================================
   PROGRESS BAR (formulaire)
   ======================================== */

.fi-form-progress {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    border: 1px solid #e9ecef;
}

.fi-progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.fi-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.fi-progress-text {
    font-size: 0.9em;
    color: #6c757d;
    text-align: center;
}

/* ========================================
   COLLAPSIBLE SECTIONS
   ======================================== */

.fi-collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.fi-collapsible-header:hover {
    background: #e9ecef;
}

.fi-collapsible-icon {
    transition: transform 0.3s;
}

.fi-collapsible-header.collapsed .fi-collapsible-icon {
    transform: rotate(-90deg);
}

.fi-collapsible-content {
    max-height: 5000px;
    overflow: hidden;
    transition: max-height 0.5s ease;
}

.fi-collapsible-content.collapsed {
    max-height: 0;
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    .fi-field-section {
        background: #2c3e50;
        border-color: #34495e;
    }

    .fi-field-section-title {
        color: #ecf0f1;
        border-bottom-color: #3498db;
    }

    .fi-global-fields {
        background: #34495e;
        border-color: #3498db;
    }

    .fi-global-fields-title {
        color: #3498db;
    }

    .geodir-custom-field:focus-within,
    [data-field]:focus-within {
        background: #34495e;
    }

    .fi-field-help:hover::after {
        background: #ecf0f1;
        color: #2c3e50;
    }

    .fi-collapsible-header {
        background: #34495e;
    }

    .fi-collapsible-header:hover {
        background: #3d566e;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .fi-hidden {
        display: none !important;
    }

    .fi-field-section {
        page-break-inside: avoid;
    }

    .fi-loading-overlay {
        display: none !important;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus visible pour navigation clavier */
.geodir-custom-field input:focus-visible,
.geodir-custom-field select:focus-visible,
.geodir-custom-field textarea:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* Annoncer les changements aux lecteurs d'écran */
.fi-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Zone de notifications pour lecteurs d'écran */
.fi-aria-live {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ========================================
   UTILITAIRES
   ======================================== */

.fi-mt-1 { margin-top: 0.5rem; }
.fi-mt-2 { margin-top: 1rem; }
.fi-mt-3 { margin-top: 1.5rem; }
.fi-mb-1 { margin-bottom: 0.5rem; }
.fi-mb-2 { margin-bottom: 1rem; }
.fi-mb-3 { margin-bottom: 1.5rem; }

.fi-text-muted { color: #6c757d; }
.fi-text-primary { color: #3498db; }
.fi-text-success { color: #27ae60; }
.fi-text-danger { color: #e74c3c; }
.fi-text-warning { color: #f39c12; }

.fi-font-weight-bold { font-weight: 700; }
.fi-font-weight-semibold { font-weight: 600; }
.fi-font-weight-normal { font-weight: 400; }

/* ========================================
   COMPATIBILITÉ NAVIGATEURS
   ======================================== */

/* Fallback pour navigateurs anciens */
@supports not (transition: all 0.3s ease-in-out) {
    [class*="geodir-custom-field-"],
    [data-field],
    [id$="_row"] {
        transition: none;
    }
}
