/* ==========================================================================
   RelookingIA Module — Viewer Public (Bouton Flottant + Modale Avant/Après)
   100% autonome (zéro dépendance Tailwind / Bootstrap / jQuery)
   ========================================================================== */

:root {
    --ria-grad-start: #4353E8;
    --ria-grad-mid:   #8B46DF;
    --ria-grad-end:   #D946B8;
    --ria-font:       'Montserrat', 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Bouton Flottant "Voir le relooking IA" ── */
#ia-floating-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1990;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 22px;
    border-radius: 9999px !important;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: linear-gradient(135deg, var(--ria-grad-start) 0%, var(--ria-grad-mid) 52%, var(--ria-grad-end) 100%);
    color: #FFFFFF;
    font-family: var(--ria-font);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 12px 32px rgba(124, 58, 237, 0.42), 0 4px 12px rgba(0, 0, 0, 0.22);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.32s ease, opacity 0.3s ease;
    overflow: hidden;
    box-sizing: border-box;
}
#ia-floating-trigger::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.28) 50%, transparent 75%);
    transform: translateX(-120%);
    transition: transform 0.8s ease;
}
#ia-floating-trigger:hover::before {
    transform: translateX(120%);
}
#ia-floating-trigger:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 18px 40px rgba(139, 70, 223, 0.55), 0 6px 16px rgba(0, 0, 0, 0.25);
}
#ia-floating-trigger:active {
    transform: scale(0.98);
}
#ia-floating-trigger .ia-sparkle-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.65));
}
#ia-floating-trigger .ia-count-pill {
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.3;
}
@media (max-width: 1023px) {
    #ia-floating-trigger {
        bottom: 92px;
        right: 16px;
        padding: 11px 17px;
        font-size: 12px;
    }
}
body.ia-editor-active #ia-floating-trigger {
    display: none !important;
}

/* Badge auto-injecté sur les miniatures publiques d'autres sites */
.ria-public-thumb-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: linear-gradient(135deg, var(--ria-grad-start) 0%, var(--ria-grad-mid) 55%, var(--ria-grad-end) 100%);
    color: #FFFFFF;
    font-family: var(--ria-font);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32);
    transition: transform 0.2s ease;
}
.ria-public-thumb-badge:hover {
    transform: scale(1.06);
}

/* ── Modale Plein Écran Avant / Après Relooking IA ── */
#ia-viewer-modal,
#ia-viewer-modal * {
    box-sizing: border-box;
}
#ia-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 999990;
    background: rgba(11, 13, 20, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    display: none;
    opacity: 0;
    transition: opacity 0.28s ease;
    font-family: var(--ria-font);
    color: #FFFFFF;
}
#ia-viewer-modal.is-open {
    display: flex;
}
#ia-viewer-modal.is-visible {
    opacity: 1;
}

.ia-viewer-shell {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Stage gauche (comparateur) */
.ia-viewer-stage {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 28px;
    position: relative;
    background: radial-gradient(circle at 30% 25%, rgba(88, 60, 180, 0.14), transparent 55%), #0D1018;
}

.ia-compare-frame {
    position: relative;
    width: 100%;
    max-width: 1120px;
    height: calc(100vh - 96px);
    max-height: 760px;
    border-radius: 18px;
    overflow: hidden;
    background: #141824;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.08);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    cursor: ew-resize;
    --ia-split: 50%;
}

.ia-compare-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.ia-compare-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    margin: 0;
    padding: 0;
}
.ia-layer-before {
    z-index: 2;
    clip-path: inset(0 calc(100% - var(--ia-split)) 0 0);
    -webkit-clip-path: inset(0 calc(100% - var(--ia-split)) 0 0);
}
.ia-layer-after {
    z-index: 1;
}

/* Badges État Actuel / Après Relooking IA */
.ia-stage-badge {
    position: absolute;
    top: 18px;
    z-index: 15;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.ia-badge-before {
    left: 18px;
    background: rgba(15, 19, 28, 0.78);
    backdrop-filter: blur(10px);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.16);
}
.ia-badge-after {
    right: 18px;
    background: linear-gradient(135deg, var(--ria-grad-mid) 0%, var(--ria-grad-end) 100%);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Ligne et poignée centrale */
.ia-compare-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--ia-split);
    width: 2px;
    margin-left: -1px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.65);
    z-index: 20;
    pointer-events: none;
}
.ia-compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    border-radius: 9999px !important;
    background: #FFFFFF;
    color: #191D24;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.22);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.ia-compare-frame.is-dragging .ia-compare-handle {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 10px 34px rgba(139, 92, 246, 0.65), 0 0 0 6px rgba(167, 139, 250, 0.35);
}

/* Raccourcis Avant / 50-50 / Après */
.ia-quick-split {
    position: absolute;
    bottom: 18px;
    right: 18px;
    z-index: 25;
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 9999px;
    background: rgba(15, 19, 28, 0.72);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.14);
}
.ia-quick-split button {
    padding: 6px 12px;
    border-radius: 9999px;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font-family: var(--ria-font);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.ia-quick-split button:hover,
.ia-quick-split button.active {
    background: rgba(255, 255, 255, 0.18);
    color: #FFFFFF;
}

/* Sélecteur Propositions de Style (Bas Gauche) */
.ia-style-dock {
    position: absolute;
    bottom: 18px;
    left: 18px;
    z-index: 25;
    max-width: calc(100% - 220px);
    background: rgba(16, 19, 28, 0.68);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    cursor: default;
}
.ia-style-dock-header {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.88);
    margin-bottom: 10px;
}
.ia-style-thumbs {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
}
.ia-style-thumb-btn {
    position: relative;
    width: 66px;
    height: 66px;
    border-radius: 12px;
    overflow: hidden;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.18);
    background: #141824;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.ia-style-thumb-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ia-style-thumb-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.55);
}
.ia-style-thumb-btn.active {
    border-color: #E879F9;
    box-shadow: 0 0 0 2px rgba(217, 70, 239, 0.45), 0 6px 18px rgba(217, 70, 239, 0.35);
}
.ia-style-thumb-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
    color: #FFFFFF;
    font-size: 9px;
    font-weight: 600;
    padding: 10px 4px 3px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Spinner */
.ia-stage-spinner {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(13, 16, 24, 0.45);
    pointer-events: none;
}
.ia-stage-spinner.visible {
    display: flex;
}
.ia-stage-spinner::after {
    content: "";
    width: 38px;
    height: 38px;
    border-radius: 9999px;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: #C084FC;
    animation: riaSpin 0.7s linear infinite;
}
@keyframes riaSpin {
    to { transform: rotate(360deg); }
}

/* Panneau latéral droit "Autres Pièces relookées" */
.ia-viewer-sidebar {
    width: 360px;
    flex-shrink: 0;
    height: 100%;
    background: #12151E;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    padding: 24px 24px 18px;
    position: relative;
}
.ia-sidebar-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.ia-sidebar-title {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.18;
    color: #FFFFFF;
    margin: 8px 0 0;
    letter-spacing: -0.3px;
}
.ia-sidebar-close {
    width: 38px;
    height: 38px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}
.ia-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}
.ia-sidebar-divider {
    height: 2px;
    width: 100%;
    background: linear-gradient(90deg, var(--ria-grad-mid) 0%, var(--ria-grad-end) 55%, rgba(255, 255, 255, 0.08) 100%);
    border-radius: 9999px;
    margin-bottom: 22px;
    flex-shrink: 0;
}
.ia-rooms-list {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}
.ia-rooms-list::-webkit-scrollbar { width: 5px; }
.ia-rooms-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 9999px;
}

.ia-room-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    color: #FFFFFF;
    font-family: var(--ria-font);
}
.ia-room-card:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateX(2px);
}
.ia-room-card.active {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.22) 0%, rgba(217, 70, 239, 0.14) 100%);
    border-color: rgba(167, 139, 250, 0.78);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.22);
}
.ia-room-card-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: #1C2130;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.ia-room-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ia-room-card-info {
    min-width: 0;
    flex: 1 1 auto;
}
.ia-room-card-title {
    font-size: 14px;
    font-weight: 700;
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.ia-room-card-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.58);
    font-weight: 500;
}
.ia-room-card.active .ia-room-card-meta {
    color: #D8B4FE;
}

.ia-sidebar-footer {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: right;
}
.ia-sidebar-disclaimer {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.38);
    text-align: left;
}
.ia-sidebar-brand {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.42);
}
.ia-sidebar-brand strong {
    color: rgba(255, 255, 255, 0.72);
}

/* Responsive Mobile & Tablette */
@media (max-width: 1023px) {
    .ia-viewer-shell { flex-direction: column; }
    .ia-viewer-stage {
        padding: 14px;
        flex: 1 1 60%;
        min-height: 0;
    }
    .ia-compare-frame {
        height: 100%;
        max-height: 58vh;
        border-radius: 14px;
    }
    .ia-viewer-sidebar {
        width: 100%;
        height: auto;
        max-height: 38vh;
        border-left: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding: 14px 16px;
    }
    .ia-sidebar-title { font-size: 17px; margin: 0; }
    .ia-sidebar-top { align-items: center; margin-bottom: 10px; }
    .ia-sidebar-divider { margin-bottom: 12px; }
    .ia-rooms-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 4px;
    }
    .ia-room-card { width: 210px; flex-shrink: 0; padding: 9px; }
    .ia-room-card-thumb { width: 44px; height: 44px; }
    .ia-quick-split { display: none; }
    .ia-style-dock {
        max-width: calc(100% - 28px);
        bottom: 12px;
        left: 12px;
        padding: 8px 10px;
    }
    .ia-style-thumb-btn { width: 48px; height: 48px; }
    .ia-sidebar-footer { display: none; }
}
