/* ==========================================================================
   CSS VARIABLES & GLOBAL RESET
   Les valeurs ci-dessous ne sont que des garde-fous : /config.js les écrase
   au chargement à partir du .env. Ne pas éditer les couleurs ici.
   ========================================================================== */
:root {
    --brand-primary: #19181a;
    --brand-accent: #d4003b;
    --bg-main: #f7f6f7;
    --card-bg: #ffffff;
    --text-muted: #6f6d70;
    --border-light: #e6e3e5;
    --brand-hue: 343;
    --brand-sat: 90%;

    /* Teinte/saturation par agent : héritées de la marque tant qu'aucune
       slide ne les surcharge. Les tons clairs sont dérivés par calc() pour
       éviter les fonds "bonbon" sur les teintes très saturées. */
    --agent-hue: var(--brand-hue);
    --agent-sat: var(--brand-sat);

    /* Dimensions des slides selon le mode et l'écran */
    --slide-width-desktop: 290px;
    --slide-height-desktop: 460px;
    --slide-width-mobile: 260px;
    --slide-height-mobile: 410px;
}

body {
    background-color: var(--bg-main);
    color: var(--brand-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
}

/* ==========================================================================
   TYPOGRAPHY & UTILITIES
   ========================================================================== */
.text-brand { color: var(--brand-primary) !important; }
.text-accent { color: var(--brand-accent) !important; }
.text-muted { color: var(--text-muted) !important; }
.tracking-tight { letter-spacing: -0.02em; }

.main-title {
    font-size: clamp(2rem, 3.5vw, 2.8rem);
    line-height: 1.25;
}

/* ==========================================================================
   HEADER & FOOTER (REASSURANCE)
   ========================================================================== */
header {
    background: var(--card-bg);
}

.brand-logo {
    max-height: 68px;
    width: auto;
    object-fit: contain;
}

.reassurance-badge {
    color: var(--text-muted);
    border-color: var(--border-light) !important;
}

.reassurance-pill {
    border-color: var(--border-light) !important;
    gap: 12px;
}

/* ==========================================================================
   SWIPER CAROUSEL ENGINE (Dual Mode: Coverflow & Cards)
   ========================================================================== */
.swiper {
    width: 100%;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.swiper.is-visible {
    opacity: 1;
}

.swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

/* Correctif des ombres Swiper pour respecter les coins arrondis */
.swiper-slide-shadow,
.swiper-slide-shadow-cards,
.swiper-slide-shadow-coverflow {
    border-radius: inherit !important;
}

/* --- MODE 1 : COVERFLOW --- */
.swiper.mode-coverflow {
    padding-top: 20px;
    padding-bottom: 40px;
    -webkit-mask-image: linear-gradient(to right, transparent, black 50px, black calc(100% - 50px), transparent);
    mask-image: linear-gradient(to right, transparent, black 50px, black calc(100% - 50px), transparent);
}

.swiper.mode-coverflow .swiper-slide {
    width: var(--slide-width-desktop);
    height: var(--slide-height-desktop);
}

/* --- MODE 2 : CARDS --- */
.swiper.mode-cards {
    width: var(--slide-width-desktop);
    height: var(--slide-height-desktop);
    margin: 0 auto;
    padding-top: 20px;
    padding-bottom: 40px;
    overflow: visible;
}

.swiper.mode-cards .swiper-slide {
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   AGENT CARD INTERNALS
   ========================================================================== */
.agent-card {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 24px;
    position: relative;
    overflow: hidden;
    will-change: transform;
}

.swiper-slide-active .agent-card {
    border-color: hsl(var(--agent-hue), calc(var(--agent-sat) * 0.5), 70%);
    box-shadow: 0 25px 40px rgba(0, 0, 0, 0.08);
}

.agent-avatar {
    border-radius: 50%;
    object-fit: cover;
    background-color: hsl(var(--agent-hue), calc(var(--agent-sat) * 0.35), 90%);
    margin-bottom: 0;
    width: 125px;
    height: 125px;
    border: 5px solid transparent;
}

.swiper-slide-active .agent-avatar {
    border-color: hsl(var(--agent-hue), calc(var(--agent-sat) * 0.5), 70%);
}

.agent-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
    color: hsl(var(--agent-hue), var(--agent-sat), 38%);
    font-size: 0.9rem;
    transform: translateY(-12px);
    z-index: 2;
}

.swiper-slide-active .agent-icon-wrapper {
    border-color: hsl(var(--agent-hue), calc(var(--agent-sat) * 0.5), 70%);
}

.agent-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--brand-primary);
    margin-bottom: 4px;
    margin-top: -5px;
    text-align: center;
}

.agent-role {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: hsl(var(--agent-hue), calc(var(--agent-sat) * 0.85), 40%);
    margin-bottom: 15px;
    text-align: center;
}

.agent-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.6;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Dynamic Buttons --- */
.chat-btn {
    width: 100%;
    background: hsl(var(--agent-hue), calc(var(--agent-sat) * 0.5), 97%);
    border: 1px solid hsl(var(--agent-hue), calc(var(--agent-sat) * 0.45), 88%);
    color: hsl(var(--agent-hue), var(--agent-sat), 35%);
    border-radius: 30px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: auto;
    transition: background 0.2s ease, color 0.2s ease;
}

.swiper-slide-active .chat-btn {
    background: hsl(var(--agent-hue), var(--agent-sat), 40%);
    border: none;
    color: #ffffff;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   SWIPER CONTROLS OVERRIDES
   ========================================================================== */
.custom-nav-arrow {
    color: var(--brand-primary) !important;
    background: var(--card-bg);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    margin-top: -22px;
}

.custom-nav-arrow:after {
    font-size: 1.2rem !important;
    font-weight: bold;
}

.swiper-button-prev { left: 20px !important; }
.swiper-button-next { right: 20px !important; }

.swiper-pagination {
    position: relative !important;
    bottom: 0 !important;
}

.swiper-pagination-bullet {
    background: #cbd5e1 !important;
    opacity: 1 !important;
    width: 8px !important;
    height: 8px !important;
    transition: all 0.3s ease;
}

.swiper-pagination-bullet-active {
    background: var(--brand-accent) !important;
}

/* ==========================================================================
   MOBILE VIEWPORT OPTIMIZATIONS
   ========================================================================== */
@media (max-width: 767.98px) {
    header {
        padding: 10px 15px !important;
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.12);
        margin-bottom: 10px;
    }

    .brand-logo { max-height: 48px !important; }

    .main-title {
        font-size: clamp(1.05rem, 5vw, 1.4rem);
        margin-top: 8px !important;
        margin-bottom: 4px !important;
        padding: 0 5px;
    }

    .secondary-title { display: none; }

    .swiper.mode-coverflow {
        padding-top: 10px;
        padding-bottom: 25px;
    }

    .swiper.mode-coverflow .swiper-slide {
        width: var(--slide-width-mobile);
        height: var(--slide-height-mobile);
    }

    .swiper.mode-cards {
        width: var(--slide-width-mobile);
        height: var(--slide-height-mobile);
        padding-top: 10px;
        padding-bottom: 25px;
    }

    .agent-card { padding: 20px 16px; }
    .agent-name { font-size: 1.2rem; }
    .agent-desc {
        font-size: 0.8rem;
        margin-bottom: 10px;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }
    .custom-nav-arrow { display: none !important; }
}

/* ==========================================================================
   MODAL LAYOUT (Strict Viewport Constraint)
   ========================================================================== */
@media (min-width: 576px) {
    .custom-fullscreen-dialog {
        max-width: 95vw !important;
        width: 95vw;
        height: 96dvh !important;
        margin: 2dvh auto !important;
        display: flex;
        flex-direction: column;
    }

    .custom-fullscreen-dialog .branded-modal {
        height: 100% !important;
        max-height: 100% !important;
        display: flex;
        flex-direction: column;
        overflow: hidden !important;
        border-radius: 24px;
        border: none;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    }

    .custom-fullscreen-dialog .modal-body {
        flex: 1 1 auto;
        overflow-y: auto !important;
        min-height: 0;
    }
}

@media (max-width: 575.98px) {
    .custom-fullscreen-dialog {
        margin: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        display: flex;
        flex-direction: column;
    }

    .custom-fullscreen-dialog .branded-modal {
        height: 100% !important;
        border-radius: 0 !important;
        border: none;
        overflow: hidden !important;
        display: flex;
        flex-direction: column;
    }

    .custom-fullscreen-dialog .modal-body {
        flex: 1 1 auto;
        overflow-y: auto !important;
        min-height: 0;
    }
}

/* ==========================================================================
   CHAT SYSTEM & BUBBLES
   ========================================================================== */
.chat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid hsl(var(--agent-hue), var(--agent-sat), 45%);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.bg-slate { background-color: #f8fafc; }

.chat-box {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
}

.chat-bubble {
    width: fit-content;
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 4px;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: bubbleEnter 0.25s ease-out forwards;
}

.user-bubble {
    align-self: flex-end;
    background: hsl(var(--agent-hue), var(--agent-sat), 42%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.bot-bubble {
    align-self: flex-start;
    background: var(--card-bg);
    color: var(--brand-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-light);
}

/* ==========================================================================
   INTERACTIVE CHOICES
   ========================================================================== */
.choices-container {
    align-self: flex-start;
    width: 100%;
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.choice-btn-item {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 12px 16px;
    text-align: left;
    width: 100%;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.choice-btn-item:hover:not(:disabled) {
    border-color: hsl(var(--agent-hue), var(--agent-sat), 45%);
    background: hsl(var(--agent-hue), calc(var(--agent-sat) * 0.5), 98%);
}

.choice-btn-item:disabled { opacity: 0.55; }

.choice-title {
    font-weight: 600;
    color: hsl(var(--agent-hue), var(--agent-sat), 32%);
    display: block;
    font-size: 0.9rem;
}

.choice-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* ==========================================================================
   INPUTS & ANIMATIONS
   ========================================================================== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    align-self: flex-start;
    background: var(--card-bg);
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-light);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: hsl(var(--agent-hue), var(--agent-sat), 45%);
    border-radius: 50%;
    will-change: transform;
    transform: translateZ(0);
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

.branded-input {
    background-color: var(--card-bg) !important;
    border: 1px solid var(--border-light) !important;
    color: var(--brand-primary) !important;
    border-radius: 30px;
    padding: 12px 55px 12px 20px;
}

.branded-input:focus {
    border-color: hsl(var(--agent-hue), var(--agent-sat), 45%) !important;
    box-shadow: 0 0 0 3px hsl(var(--agent-hue), calc(var(--agent-sat) * 0.6), 92%) !important;
}

.send-branded-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 12px;
}

.send-branded-btn:hover { color: hsl(var(--agent-hue), var(--agent-sat), 42%); }

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

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale3d(0, 0, 1); }
    40% { transform: scale3d(1, 1, 1); }
}

@media (prefers-reduced-motion: reduce) {
    .chat-bubble { animation: none; }
    .swiper { transition: none; }
}
