/**
 * Styles pour SpaceTransformer v2
 * Module de transformation des locaux IFC
 */

/* ═══════════════════════════════════════════════════════════════════════════
   SECTION LOCAUX
   ═══════════════════════════════════════════════════════════════════════════ */

#section-transform-spaces {
    animation: fadeIn 0.3s ease-out;
}

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

/* Cartes stats */
#section-transform-spaces .stat-card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

#section-transform-spaces .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Table des locaux */
#spacesTransformBody tr {
    transition: background-color 0.15s;
}

#spacesTransformBody tr:hover {
    background-color: #f3e8ff !important;
}

#spacesTransformBody tr[style*="background: #fef3c7"] {
    animation: pulse-modified 2s ease-in-out;
}

@keyframes pulse-modified {
    0%, 100% { background-color: #fef3c7; }
    50% { background-color: #fde68a; }
}

/* Boutons d'action */
#spacesTransformBody button {
    transition: transform 0.15s, background-color 0.15s;
}

#spacesTransformBody button:hover {
    transform: scale(1.1);
}

/* Barre de recherche */
#spaceSearchInput {
    transition: border-color 0.2s, box-shadow 0.2s;
}

#spaceSearchInput:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    outline: none;
}

/* Filtre étage */
#spaceStoreyFilter {
    transition: border-color 0.2s;
}

#spaceStoreyFilter:focus {
    border-color: #8b5cf6;
    outline: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   APERÇU DES MODIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

#spaceModificationsPreview {
    animation: slideIn 0.3s ease-out;
}

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

#spaceModificationsBody tr {
    transition: background-color 0.15s;
}

#spaceModificationsBody tr:hover {
    background-color: #f5f3ff;
}

/* Badges */
#spaceModificationsPreview .badge {
    animation: badgePop 0.3s ease-out;
}

@keyframes badgePop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOUTONS PRINCIPAUX
   ═══════════════════════════════════════════════════════════════════════════ */

#section-transform-spaces .btn {
    transition: transform 0.2s, box-shadow 0.2s;
}

#section-transform-spaces .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#section-transform-spaces .btn:active {
    transform: translateY(0);
}

#section-transform-spaces .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Bouton télécharger template */
#section-transform-spaces button[onclick*="exportTemplate"] {
    position: relative;
    overflow: hidden;
}

#section-transform-spaces button[onclick*="exportTemplate"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

#section-transform-spaces button[onclick*="exportTemplate"]:hover::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(40, 40);
        opacity: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ÉTAPES VISUELLES
   ═══════════════════════════════════════════════════════════════════════════ */

#section-transform-spaces > div[style*="background: white"] {
    transition: box-shadow 0.2s;
}

#section-transform-spaces > div[style*="background: white"]:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Numéros d'étape */
#section-transform-spaces div[style*="border-radius: 50%"] {
    transition: transform 0.2s;
}

#section-transform-spaces > div[style*="background: white"]:hover div[style*="border-radius: 50%"] {
    transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    #section-transform-spaces .table-container {
        max-height: 300px;
    }
    
    #section-transform-spaces table th,
    #section-transform-spaces table td {
        padding: 0.4rem !important;
        font-size: 0.75rem !important;
    }
    
    /* Cacher certaines colonnes sur mobile */
    #section-transform-spaces table th:first-child,
    #section-transform-spaces table td:first-child {
        display: none;
    }
    
    #spaceSearchInput,
    #spaceStoreyFilter {
        font-size: 16px; /* Empêche le zoom sur iOS */
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE (si activé)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
    #section-transform-spaces {
        /* Dark mode styles - à personnaliser si besoin */
        color-scheme: dark;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════════════════════════════════ */

#spacesTransformBody tr.loading td {
    position: relative;
}

#spacesTransformBody tr.loading td::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.1), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS (intégration)
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-space-success {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed) !important;
}

.toast-space-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ÉDITION INLINE
   ═══════════════════════════════════════════════════════════════════════════ */

#spacesTransformBody tr.editing {
    background: #ede9fe !important;
    box-shadow: inset 0 0 0 2px #8b5cf6;
}

#spacesTransformBody tr.editing td {
    background: transparent !important;
}

#spacesTransformBody tr.editing input {
    animation: inputFocus 0.3s ease-out;
}

@keyframes inputFocus {
    0% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    }
}

/* Boutons sauvegarde/annulation */
#spacesTransformBody tr.editing button {
    transition: transform 0.15s, background-color 0.15s;
}

#spacesTransformBody tr.editing button:hover {
    transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   INTÉGRATION VIEWER - SÉLECTION
   ═══════════════════════════════════════════════════════════════════════════ */

#spacesTransformBody tr.selected {
    box-shadow: inset 0 0 0 2px #8b5cf6 !important;
    background: #f5f3ff !important;
}

#spacesTransformBody tr.selected td {
    background: transparent !important;
}

/* Hover avec viewer connecté */
#spacesTransformBody tr:not(.editing):hover {
    cursor: pointer;
}

/* Badge étage amélioré */
#spacesTransformBody .storey-badge {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Modifications en attente */
#spacesTransformBody tr[style*="background: #dbeafe"] {
    position: relative;
}

#spacesTransformBody tr[style*="background: #dbeafe"]::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #3b82f6;
}

/* Bouton isoler dans viewer */
#spacesTransformBody button[title*="Isoler"] {
    transition: transform 0.2s, box-shadow 0.2s;
}

#spacesTransformBody button[title*="Isoler"]:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.4);
}

/* ═══════════════════════════════════════════════════════════════════════════
   APERÇU DES MODIFICATIONS AMÉLIORÉ
   ═══════════════════════════════════════════════════════════════════════════ */

#spaceModificationsPreview {
    border-left: 4px solid #7c3aed;
}

#spaceModificationsBody tr {
    border-left: 3px solid transparent;
    transition: border-color 0.2s, background-color 0.15s;
}

#spaceModificationsBody tr:hover {
    border-left-color: #8b5cf6;
    background-color: #f5f3ff;
}

/* Texte barré pour anciennes valeurs */
#spacesTransformBody span[style*="line-through"] {
    opacity: 0.6;
    font-size: 0.85em;
}

/* Nouvelles valeurs mises en évidence */
#spacesTransformBody span[style*="color: #059669"] {
    animation: newValuePulse 0.5s ease-out;
}

@keyframes newValuePulse {
    0% { opacity: 0; transform: translateX(-5px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   INDICATEUR VIEWER CONNECTÉ
   ═══════════════════════════════════════════════════════════════════════════ */

.viewer-connected-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.viewer-connected-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: viewerPulse 2s infinite;
}

@keyframes viewerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
