/* ══════════════════════════════════════════════════════════
           TRUSTQUICK ELITE — ARCHITECTURE STABLE (STYLE OPENAI)
           ══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap');

:root {
    --bg: #ffffff;
    --sidebar-bg: #f9f9f9;
    --border: rgba(0, 0, 0, 0.08);
    --text-main: #0d0d0d;
    --text-muted: #676767;
    --font-main: 'Inter', sans-serif;
    --accent: #10a37f;
    --danger: #df1b12;
    --success: #34c759;
    --text-dim: #999999;
    --font-code: 'Roboto Mono', monospace;
    --surface: #f9f9f9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text-main);
    overflow: hidden;
}

/* --- STRUCTURE --- */
.header {
    display: none !important;
}

.container {
    display: flex;
    height: 100vh;
    width: 100vw;
    transition: all 0.3s ease;
}

/* 1. SIDEBAR ELITE (La bande fine [|]) */
.sidebar {
    width: 320px;
    min-width: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 50;
    overflow: hidden;
}

/* État fermé : La bande fine de 48px */
.sidebar.collapsed {
    width: 56px !important;
}

/* On cache tout violemment quand c'est réduit, sauf le logo et le toggle */
.sidebar.collapsed>*:not(.toggle-wrapper):not(.main-nav) {
    opacity: 0;
    visibility: hidden;
    display: none !important;
}

.sidebar.collapsed .sidebar-brand {
    display: none !important;
}

.sidebar.collapsed .toggle-wrapper {
    justify-content: center !important;
    padding: 12px 0 !important;
    /* On retire le padding horizontal pour que le bouton se centre parfaitement sans décalage */
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-right: -8px;
}

.sidebar-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
}

.sidebar.collapsed .sidebar-toggle-btn {
    margin-right: 0;
    padding: 10px;
    border-radius: 10px;
}

/* BOUTON FLOTTANT (STYLE CHATGPT) */
.floating-toggle-btn {
    position: absolute;
    top: 50%;
    right: -14px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.sidebar:hover .floating-toggle-btn,
.floating-toggle-btn:hover {
    opacity: 1;
}

.floating-toggle-btn:hover {
    color: #000;
    background: #f9f9f9;
}

/* Quand collapsed, pointer vers la droite */
.sidebar.collapsed .floating-toggle-btn svg {
    transform: rotate(180deg);
}

/* NAVIGATION PRINCIPALE (STYLE NOTION/APPLE) */
.main-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 16px 16px 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.main-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: #444;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.main-nav-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #000;
}

.main-nav-item svg {
    color: #666;
    transition: all 0.2s ease;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.main-nav-item:hover svg {
    color: #000;
}

.main-nav-item.active {
    background: #E8F0FE;
    color: #4A8BF5;
    font-weight: 600;
}

.main-nav-item.active svg {
    color: #4A8BF5;
}

.bottom-nav {
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 16px;
    border-bottom: none;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Mode réduit : ne garder que les icônes centrées */
.sidebar.collapsed .main-nav {
    padding: 0 8px 16px 8px;
}

.sidebar.collapsed .bottom-nav {
    padding-top: 16px;
    /* garder un peu d'espace avec les filtres au-dessus */
}

.sidebar.collapsed .main-nav-item {
    justify-content: center;
    padding: 10px;
}

.sidebar.collapsed .main-nav-item span {
    display: none;
}

.sidebar.collapsed .main-nav-item svg {
    margin: 0;
}

/* 2. ZONE DE CHAT (Centrage Zen) */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg);
    height: 100%;
    position: relative;
}

/* ⚡️ MAGIE CHATGPT : Barre proche du titre au centre sur l'accueil */
.chat-area:has(#welcome) {
    justify-content: center;
}

.chat-area:has(#welcome) .chat-messages {
    flex: none;
    /* Le conteneur s'adapte au texte, sans pousser la barre */
}

.chat-area:has(#welcome) .chat-messages-inner {
    padding-bottom: 0;
    gap: 0;
}

.chat-header-bar {
    display: none !important;
}

.chat-messages {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-messages-inner {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-bottom: 100px;
}

/* 3. ACCUEIL ET BARRE PILULE (Centrage Optique) */
.welcome-state {
    text-align: center;
    animation: fadeIn 0.8s ease;
    width: 100%;
    flex: none !important;
    padding: 0 !important;
    margin-bottom: 30px;
}

.welcome-state h2 {
    display: none;
    font-size: 38px;
    font-weight: 600;
    letter-spacing: -1.2px;
    margin-bottom: 24px;
    color: #212121;
}

.welcome-state .logo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 30px auto;

    position: relative;
    z-index: 10;
}

@keyframes levitation {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-12px);
    }

    100% {
        transform: translateY(0px);
    }
}

.welcome-state p {
    display: none;
}

/* La Barre de Saisie "Pilule" */
.chat-input-area {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 10px 24px 40px;
    background: transparent;
}

/* On dashboard view, push input strictly to the bottom */
.dashboard-split-layout.visible ~ .chat-input-area {
    margin-top: auto;
}

.chat-input-wrapper {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 30px;
    padding: 8px 12px 8px 24px;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
    transition: border-color 0.2s;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.chat-input-wrapper:focus-within {
    border-color: rgba(0, 0, 0, 0.25);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.chat-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 10px 0;
    background: transparent;
    font-family: var(--font-main);
    caret-color: #4A8BF5; /* Curseur bleu comme demandé */
}

/* 4. LE BOUTON "PREMIUM" (Rond Noir + Flèche) */
#chat-send-btn {
    background: #4A8BF5 !important;
    color: #fff !important;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    cursor: pointer;
    border: none;
    font-size: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.3;
    pointer-events: none;
}

#chat-send-btn.active {
    opacity: 1;
    pointer-events: auto;
}

#chat-send-btn.active:hover {
    transform: scale(1.05);
}

#chat-send-btn.active:active {
    transform: scale(0.95);
}

/* SVG Arrow Animée */
#chat-send-btn svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-send-btn:not(.active) svg {
    transform: translateY(2px);
}

/* 5. ÉLÉMENTS DE CHAT */
.chat-msg {
    font-size: 16px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
    animation: fadeIn 0.5s ease;
}

.chat-msg.ai {
    background: transparent;
    border: none;
    color: var(--text-main);
    align-self: flex-start;
    padding: 0;
}

.chat-msg.user {
    align-self: flex-end;
    background: #f4f4f4;
    padding: 12px 24px;
    border-radius: 24px;
    max-width: 85%;
    color: var(--text-main);
}

.chat-msg.system {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 11px;
    padding: 8px 16px;
    color: var(--text-dim);
    align-self: center;
    text-align: center;
    max-width: 500px;
}

.chat-msg b,
.chat-msg code {
    font-family: var(--font-code) !important;
    background: #f1f1f1 !important;
    color: #000 !important;
    padding: 2px 6px !important;
    border-radius: 5px !important;
    font-size: 0.9em !important;
    font-weight: 500 !important;
}

.quick-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.quick-btn {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: #000;
    color: #fff;
    border-color: #000;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ══════════ STYLES PRÉSERVÉS (Escalades, Attachments, Lightbox) ══════════ */
.sidebar-header {
    padding: 20px 16px 10px 16px;
    border-bottom: none;
    position: relative;
}

.filter-row {
    position: absolute;
    top: 70px;
    left: 16px;
    right: 16px;
    background: transparent;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
    /* Dropdown hidden par défaut */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-row.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.filter-btn {
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #444444;
    font-size: 12px;
    font-family: var(--font-main);
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: none;
    width: 100%;
}

.filter-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #111111;
}

.filter-btn.active {
    background: #4A8BF5;
    color: #ffffff;
    font-weight: 500;
}

.filter-btn .count {
    margin-left: auto;
    /* Pousse à droite */
    color: #888888;
    font-size: 11px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.filter-btn.active .count {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
}

.search-row {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 30px;
    padding: 6px 8px 6px 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    margin-bottom: 8px;
    /* Séparation avec le menu dropdown */
}

.search-row:focus-within {
    border-color: rgba(0, 0, 0, 0.25);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.search-row input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 13px;
    /* Légèrement plus petit que le chat (16px) pour la sidebar */
    padding: 4px 0;
    background: transparent;
    font-family: var(--font-main);
    color: var(--text-main);
}

.search-row input::placeholder {
    font-size: 12px;
}

.search-row button {
    background: #4A8BF5;
    color: #fff;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    border: none;
    font-size: 14px;
    opacity: 0.3;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-row button:hover {
    transform: scale(1.05);
    opacity: 1;
}

.search-row button:active {
    transform: scale(0.95);
}

#esc-list {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.esc-item {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.esc-item:hover {
    background: rgba(74, 139, 245, 0.04);
    box-shadow: 0 2px 8px rgba(74, 139, 245, 0.08);
}

.esc-item.active {
    background: rgba(74, 139, 245, 0.08);
    border-color: #4A8BF5;
    box-shadow: 0 4px 12px rgba(74, 139, 245, 0.15);
}

.esc-item .top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}

.esc-item .email {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
}

.esc-item .date {
    font-size: 10px;
    color: var(--text-dim);
}

.esc-item .cat {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin-right: 4px;
    background: #eef4ff;
    color: #4A8BF5;
}

.esc-item .reason {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.esc-label {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
    background: #eef4ff;
    color: #4A8BF5;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    z-index: 100;
    transform: translateY(100px);
    opacity: 0;
    transition: all .3s;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
    color: #fff;
}

.toast.error {
    background: var(--danger);
    color: #fff;
}

.spinner {
    width: 17px;
    height: 17px;
    border: 2px solid var(--border);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}

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

.chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chat-attachment {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .3s;
    border: 1px solid var(--border);
}

.chat-attachment:hover {
    transform: scale(1.03);
}

.chat-attachment img {
    display: block;
    max-width: 200px;
    max-height: 160px;
    object-fit: cover;
    border-radius: 12px;
}

.chat-attachment .file-badge {
    padding: 10px 16px;
    background: var(--surface);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.chat-attachment .file-badge .icon {
    font-size: 20px;
}

.attachments-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 10px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 200;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    backdrop-filter: blur(15px);
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    cursor: default;
}

.lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    background: rgba(0, 0, 0, .5);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    z-index: 201;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, .15);
}

.lightbox-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-main);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.lightbox-download-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.att-filename {
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    padding: 4px 6px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment-pdf {
    background: #fff7ed;
    border-color: #fed7aa;
}

.chat-attachment-pdf:hover {
    border-color: #fb923c;
    background: #ffedd5;
}

@keyframes pulse-light {
    0% {
        background: rgba(245, 158, 11, 0.15);
    }

    50% {
        background: rgba(245, 158, 11, 0.3);
    }

    100% {
        background: rgba(245, 158, 11, 0.15);
    }
}

span[style*="color:var(--accent)"],
span[style*="color:#f59e0b"] {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #d97706 !important;
    border-radius: 10px !important;
    padding: 2px 10px !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    display: inline-block;
    animation: pulse-light 2s infinite;
}

/* ══════════ CARTES PREMIUM (Email + Shopify) ══════════ */
/* Tentacles & Top Cards Animation */
.tentacles-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 250px;
    pointer-events: none;
    z-index: 10;
    display: none;
    overflow: hidden;
}

.tentacles-wrapper.visible {
    display: block;
}

/* The tentacles themselves using SVG for high quality */
.tentacle-left,
.tentacle-right {
    position: absolute;
    top: 20px;
    /* Moins bas */
    width: 320px;
    height: 250px;
    /* Plus grand pour éviter que le SVG soit coupé */
}

.tentacle-left {
    left: -30px;
    transform: translateX(-400px) translateY(-20px);
}

.tentacle-right {
    right: -30px;
    transform: translateX(400px) translateY(-20px) scaleX(-1);
}

.tentacles-wrapper.visible .tentacle-left {
    /* Animation d'arrivée fluide, suivie d'un mouvement de flottement infini */
    animation: tentacle-arrive-left 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards, float-tentacle-left 4s ease-in-out 0.8s infinite;
}

.tentacles-wrapper.visible .tentacle-right {
    animation: tentacle-arrive-right 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards, float-tentacle-right 4.2s ease-in-out 0.8s infinite;
}

/* Animations Keyframes pour les tentacules */
@keyframes tentacle-arrive-left {
    from {
        transform: translateX(-400px) translateY(-30px);
    }

    to {
        transform: translateX(0) translateY(0);
    }
}

@keyframes tentacle-arrive-right {
    from {
        transform: translateX(400px) translateY(-30px) scaleX(-1);
    }

    to {
        transform: translateX(0) translateY(0) scaleX(-1);
    }
}

@keyframes float-tentacle-left {
    0% {
        transform: translateX(0) translateY(0) rotate(0deg);
    }

    50% {
        transform: translateX(-5px) translateY(-10px) rotate(1.5deg);
    }

    100% {
        transform: translateX(0) translateY(0) rotate(0deg);
    }
}

@keyframes float-tentacle-right {
    0% {
        transform: translateX(0) translateY(0) scaleX(-1) rotate(0deg);
    }

    50% {
        transform: translateX(5px) translateY(-10px) scaleX(-1) rotate(-1.5deg);
    }

    100% {
        transform: translateX(0) translateY(0) scaleX(-1) rotate(0deg);
    }
}

/* The glowing eyes */
.octopus-eyes-top {
    position: absolute;
    top: -10px;
    /* Remonté pour être bien visible */
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    display: none;
    justify-content: center;
    z-index: 5;
    /* Info cards are default/relative so they might pop above */
    opacity: 0;
    transition: opacity 1s ease;
}

.octopus-head-emerging {
    position: relative;
    width: 120px;
    height: 85px;
    /* Plus grande pour qu'on voit bien son crâne */
    background: #4A8BF5;
    border-radius: 55px 55px 15px 15px;
    box-shadow: 0 -5px 25px rgba(74, 139, 245, 0.4);
}

.octopus-reflection {
    position: absolute;
    top: 10px;
    left: 15px;
    width: 26px;
    height: 14px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: rotate(-30deg);
}

.octopus-eyes-top-inner {
    position: absolute;
    top: 30px;
    /* Les yeux descendent un peu proportionnellement à la nouvelle hauteur */
    left: 35px;
    /* Pour centrer dans les 120px : 120/2=60. 60-25=35 */
    width: 50px;
    height: 16px;
    display: flex;
    justify-content: space-between;
}

.welcome-state {
    transition: transform 0.6s cubic-bezier(0.5, 0, 0.1, 1), opacity 0.5s ease;
}

.welcome-state.plunge {
    transform: translateY(300px) scale(0.5);
    opacity: 0;
    pointer-events: none;
}

/* Interactive Tentacles Hover */
.tentacle-left path,
.tentacle-right path {
    transition: filter 0.3s ease, stroke-width 0.3s ease;
    cursor: pointer;
}

.tentacle-left:hover path,
.tentacle-right:hover path {
    stroke-width: 44;
    filter: drop-shadow(0px 0px 25px rgba(74, 139, 245, 0.9));
}

.octopus-eyes-top.visible {
    display: flex;
    opacity: 1;
    animation: eyes-float 4.5s ease-in-out infinite;
}

@keyframes eyes-float {
    0% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(4px);
    }

    100% {
        transform: translateX(-50%) translateY(0);
    }
}

.eye-socket {
    width: 16px;
    height: 16px;
    background: rgba(26, 29, 36, 0.8);
    border-radius: 4px;
    position: relative;
    box-shadow: 0 0 10px rgba(74, 139, 245, 0.5);
}

.eye-pupil {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #4A8BF5;
    border-radius: 50%;
    top: 5px;
    left: 5px;
    box-shadow: 0 0 6px #4A8BF5;
    transition: transform 0.1s ease-out;
}

.dashboard-split-layout {
    display: none;
    position: relative;
    z-index: 11;
    /* Above tentacles */
    gap: 20px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 40px 0;
    /* Space for eyes */
}

.dashboard-split-layout.visible {
    display: grid;
    grid-template-columns: 60% 40%;
    align-items: stretch;
    height: calc(100vh - 280px); /* Laisse la place pour le header et l'input bar sans déborder */
    min-height: 600px; /* Sécurité pour très petits écrans */
}

.split-col-left,
.split-col-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    min-height: 0;
}



@keyframes slideInGlass {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-card {
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
    position: relative;
    opacity: 0;
    max-height: 400px;
}

.dashboard-split-layout.visible .split-col-left>.info-card {
    animation: slideInGlass 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s forwards;
}

.dashboard-split-layout.visible .split-col-right>.info-card {
    animation: slideInGlass 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.3s forwards;
}

.info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.info-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.info-card-header .icon {
    font-size: 18px;
}

.info-card-header h3 {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    letter-spacing: -0.3px;
}

.info-card-header .badge {
    margin-left: auto;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(74, 139, 245, 0.1);
    color: #4A8BF5;
    font-weight: 600;
}

.card-summary {
    font-size: 15px;
    line-height: 1.5;
    color: #444;
    margin-bottom: 10px;
}

.card-summary.loading {
    color: #999;
    font-style: italic;
}

.card-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 11px;
}

.card-detail-row:last-child {
    border-bottom: none;
}

.card-detail-row .label {
    color: #888;
    font-weight: 500;
}

.card-detail-row .value {
    color: #222;
    font-weight: 600;
    text-align: right;
    max-width: 65%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-detail-row .value a {
    color: #4A8BF5;
    text-decoration: none;
    font-weight: 500;
}

.card-detail-row .value a:hover {
    text-decoration: underline;
}

.card-items-list {
    margin-top: 10px;
}

.card-item {
    background: #fdfdfd;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 11px;
}

.card-item .item-name {
    font-weight: 600;
    color: #222;
    margin-bottom: 2px;
}

.card-item .item-detail {
    color: #888;
    font-size: 11px;
}

.card-item .item-props {
    margin-top: 4px;
}

.card-item .item-props span {
    display: inline-block;
    background: rgba(74, 139, 245, 0.08);
    color: #4A8BF5;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    margin-right: 4px;
    margin-top: 2px;
}

.card-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    color: #555;
    font-size: 11px;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.card-btn:hover {
    background: #4A8BF5;
    color: #fff;
    border-color: #4A8BF5;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-fulfilled {
    background: #ecfdf5;
    color: #047857;
}

.status-unfulfilled {
    background: #fff7ed;
    color: #c2410c;
}

.status-paid {
    background: #ecfdf5;
    color: #047857;
}

.status-refunded {
    background: #fef2f2;
    color: #b91c1c;
}

/* Card Details Grid */
.card-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    margin-bottom: 8px;
}

.card-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.card-detail-item:last-child {
    border-bottom: none;
}

.card-detail-item .label {
    color: #888;
}

.card-detail-item .value {
    color: #222;
    font-weight: 500;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 65%;
}

.card-detail-item .value a {
    color: #4A8BF5;
    text-decoration: none;
}

/* Email Preview Modal */
.email-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.email-modal-overlay.active {
    display: flex;
}

.email-modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
}

.email-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.email-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #222;
}

.email-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 4px;
}

.email-modal-close:hover {
    color: #333;
}

.email-thread-item {
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 11px;
    line-height: 1.6;
}

.email-thread-item.client {
    background: #f7f7f7;
    border-left: 3px solid #4A8BF5;
}

.email-thread-item.response {
    background: #f0fdf4;
    border-left: 3px solid #34c759;
}

.email-thread-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.email-thread-subject {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    font-size: 11px;
}

/* --- NOUVEAU: ACTIONS SAV PREMIUM --- */
.actions-wrapper {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #eaeaea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    padding: 20px;
    animation: fadeIn 0.4s ease;
}

.actions-header {
    font-size: 15px;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 16px;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.actions-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    height: auto;
    min-height: 56px;
    padding: 6px 20px 6px 6px;
    border-radius: 50px;
    border: 2px solid #2563EB;
    background: #ffffff !important;
    cursor: pointer;
    transition: transform 0.2s ease-in-out, filter 0.2s ease-in-out, background 0.2s ease;
    color: #2563EB !important;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    gap: 16px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* Couleurs spécifiques par bouton supprimées pour l'unification Premium */

/* --- Effet Reflet au Clic (Shine Effect) --- */
.action-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right,
            rgba(37, 99, 235, 0) 0%,
            rgba(37, 99, 235, 0.1) 50%,
            rgba(37, 99, 235, 0) 100%);
    transform: skewX(-25deg);
    transition: none;
    z-index: 1;
}

.action-btn:active::after {
    left: 200%;
    transition: left 0.4s ease-out;
}

.action-btn svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    stroke: #2563EB;
}

/* --- BADGE CIRCULAIRE POUR L'ICONE --- */
.action-btn .icon-badge {
    width: 44px;
    height: 44px;
    background: rgba(37, 99, 235, 0.05); /* very light blue */
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: none;
}

.action-btn:hover:not(:disabled) {
    background: #f0f6ff !important;
    transform: scale(1.02);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f9fafb;
}

.action-btn .icon {
    font-size: 24px;
    margin-bottom: 4px;
}

/* Modal Styles */
.sav-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 400;
    justify-content: center;
    align-items: center;
}

.sav-modal-overlay.active {
    display: flex;
}

.sav-modal {
    background: #ffffff;
    border-radius: 20px;
    /* Coins plus arrondis comme l'image */
    width: 90%;
    max-width: 440px;
    /* Légèrement plus étroit pour un look carte */
    padding: 24px 28px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    /* Ombre douce + legère bordure */
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-main);
}

.sav-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 12px;
}

.sav-modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1d1d1f;
    /* Noir Apple */
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.5px;
}

/* --- Style spécifique pour le bloc récapitulatif --- */
.refund-summary-box {
    background: #f5f5f7;
    /* Gris clair Apple */
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}

.refund-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    color: #1d1d1f;
    margin-bottom: 8px;
}

.refund-summary-row:last-child {
    margin-bottom: 0;
}

.refund-summary-row .val {
    font-weight: 600;
}

.refund-summary-row.already-refunded .val {
    color: #e74c3c;
}

.sav-form-group {
    margin-bottom: 16px;
}

.sav-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 6px;
}

.sav-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    font-size: 15px;
    color: #1d1d1f;
    font-family: inherit;
    transition: all 0.2s;
    box-sizing: border-box;
    background: #fff;
}

.sav-input:focus {
    outline: none;
    border-color: #4A8BF5;
    box-shadow: 0 0 0 3px rgba(74, 139, 245, 0.1);
}

.range-slider {
    width: 100%;
    margin-top: 16px;
    -webkit-appearance: none;
    height: 6px;
    background: #d2d2d7;
    border-radius: 4px;
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #d2d2d7;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.action-confirm-btn {
    width: 100%;
    padding: 14px;
    background: #0071e3;
    /* Bleu Apple */
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
}

.action-confirm-btn:disabled {
    background: #e5e5ea;
    color: #aeaeb2;
    cursor: not-allowed;
}

.action-confirm-btn:hover {
    background: #3A7BE5;
    transform: scale(1.02);
}

.action-confirm-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #f0f2f5;
    padding: 4px;
    border-radius: 10px;
}

.tab-btn {
    flex: 1;
    text-align: center;
    padding: 8px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #fff;
    color: #222;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.existing-codes-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.code-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.code-item:hover {
    background: #f8fbff;
}

.code-item:last-child {
    border-bottom: none;
}

.code-item.selected {
    background: #eef4ff;
    border-left: 3px solid #4A8BF5;
}

.actions-log {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #eaeaea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Remove rigid limit to allow graceful shrink */
    flex: 1;
    overflow-y: auto;
}

.actions-log-header {
    font-weight: 700;
    font-size: 15px;
    color: #1d1d1f;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 10px;
}

.actions-log-item {
    padding: 8px 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
    font-size: 12px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.actions-log-item:last-child {
    border-bottom: none;
}

/* Tabs & Ticket Colors Re-added */
.bg-pending {
    background-color: rgba(153, 27, 27, 0.03);
    border-left: 3px solid #f87171;
}

.bg-pending:hover {
    background-color: rgba(153, 27, 27, 0.08);
}

.bg-pending-active {
    background-color: rgba(153, 27, 27, 0.1) !important;
    border-left: 4px solid #ef4444 !important;
}

.bg-resolved {
    background-color: rgba(6, 95, 70, 0.03);
    border-left: 3px solid #34d399;
}

.bg-resolved:hover {
    background-color: rgba(6, 95, 70, 0.08);
}

.bg-resolved-active {
    background-color: rgba(6, 95, 70, 0.1) !important;
    border-left: 4px solid #10b981 !important;
}

.esc-tab-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
}

.esc-tab-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.esc-tab-btn.active.pending {
    background: #fee2e2;
    color: #991b1b;
}

.esc-tab-btn.active:not(.pending) {
    background: #d1fae5;
    color: #065f46;
}

.info-card {
    width: 100%;
    max-width: none;
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
    position: relative;
    overflow: auto;
    max-height: 400px;
}

/* --- BOÎTE D'INTERACTION IA --- */
.interaction-box {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #eaeaea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.interaction-box-header {
    font-weight: 700;
    font-size: 15px;
    color: #1d1d1f;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 10px;
}

.interaction-box-content {
    flex: 1;
    min-height: 0; /* Ensures the flex item can shrink smaller than its content, enabling overflow scroll */
    overflow-y: auto !important; /* Force scroll, prevent structural growth */
    padding-right: 5px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    /* Fond blanc très propre */
    border-radius: 18px;
    padding: 16px;
    border: 1px solid #e5e5ea;
    /* Bordure très discrète façon Apple */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    /* Ombre douce premium */
}

/* Style des bulles iMessage */
.interaction-box-content .chat-msg {
    position: relative;
    margin-bottom: 14px;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 14.5px;
    line-height: 1.4;
    max-width: 80%;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Message Utilisateur (Bleu, à droite) */
.interaction-box-content .chat-msg.user {
    background: #007aff;
    /* Bleu iMessage classique */
    /* Version 3D subtile avec dégradé : background: linear-gradient(180deg, #3795FF 0%, #007aff 100%); */
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
    /* Simule la petite queue de la bulle */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Message IA/Hassan (Gris, à gauche) */
.interaction-box-content .chat-msg.ai {
    background: #e9e9eb;
    /* Gris iMessage */
    color: #000;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    /* Queue de bulle à gauche */
}

.interaction-box-content .empty-state {
    color: #86868b;
    font-size: 13px;
    text-align: center;
    max-width: 80%;
    line-height: 1.5;
}

/* --- TWIN CARDS FIXED HEIGHT FIX --- */
#card-email, #card-shopify {
    height: 190px; /* Force identical fixed height, wider than tall */
    display: flex;
    flex-direction: column;
}

#card-email > .info-card-header, #card-shopify > .info-card-header {
    flex-shrink: 0;
}

.card-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom scrollbars */
.card-scroll-area::-webkit-scrollbar,
#actions-log-list::-webkit-scrollbar,
.interaction-box-content::-webkit-scrollbar {
    width: 4px;
}
.card-scroll-area::-webkit-scrollbar-track,
#actions-log-list::-webkit-scrollbar-track,
.interaction-box-content::-webkit-scrollbar-track {
    background: transparent;
}
.card-scroll-area::-webkit-scrollbar-thumb,
#actions-log-list::-webkit-scrollbar-thumb,
.interaction-box-content::-webkit-scrollbar-thumb {
    background: #4A8BF5;
    border-radius: 4px;
}

#actions-log-list {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 5px;
}

/* --- HIDE GHOST CHAT MESSAGES BAR REPELLING THE INPUT --- */
.dashboard-split-layout.visible ~ .chat-messages {
    display: none !important;
}