@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@400;700&family=Inter:wght@400;500;700&family=Space+Grotesk:wght@400;700&family=Fira+Code&family=Outfit:wght@400;700&display=swap');

/* --- HUD CORE ENGINE v5.1 --- */

.dokany-exp-base { 
    font-family: var(--tg-font-body); 
    color: var(--tg-text); 
    background: var(--tg-bg);
    transition: all 0.4s ease;
    -webkit-font-smoothing: antialiased;
}

.dokany-form-container {
    /* Suppression de all:initial qui cassait l'héritage des variables CSS --tg-* */
    box-sizing: border-box !important;
    position: relative !important;
    min-height: 850px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 60px 20px !important;
    /* Héritage explicite des variables CSS depuis le wrapper parent */
    font-family: var(--tg-font-body, 'Inter', sans-serif) !important;
    color: var(--tg-text, #ffffff) !important;
    background: var(--tg-bg, #020204) !important;
}

.tg-bg-grid {
    position: absolute; inset: 0; opacity: 0.2;
    background-image: linear-gradient(var(--tg-primary) 1px, transparent 1px), linear-gradient(90deg, var(--tg-primary) 1px, transparent 1px);
    background-size: 50px 50px; transform: perspective(500px) rotateX(60deg); transform-origin: top;
    animation: tg-grid-move 20s linear infinite; pointer-events: none;
}
@keyframes tg-grid-move { 0% { background-position: 0 0; } 100% { background-position: 0 50px; } }

.tg-perspective-wrap { perspective: 1500px; width: 100%; max-width: 800px; z-index: 10; position: relative; }
.tg-panel {
    background: rgba(2, 2, 4, 0.95) !important;
    backdrop-filter: blur(20px); border: 2px solid var(--tg-primary) !important;
    padding: 50px; transform: rotateY(-5deg);
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.2); border-radius: 0;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.tg-title { font-family: var(--tg-font-heading) !important; color: var(--tg-primary) !important; font-size: 38px !important; font-weight: 900 !important; text-transform: uppercase !important; margin: 0 0 10px 0 !important; text-shadow: 0 0 15px var(--tg-primary) !important; }

/* --- NAVIGATION & BUTTONS --- */
.tg-nav-btn, .tg-submit-cyber, .tg-btn-start {
    padding: 22px 45px !important; font-family: var(--tg-font-heading) !important; font-weight: 900 !important;
    background: var(--tg-primary) !important; color: #000 !important; border: none !important; cursor: pointer !important;
    clip-path: polygon(15% 0, 100% 0, 100% 70%, 85% 100%, 0 100%, 0 30%) !important; 
    text-transform: uppercase !important; letter-spacing: 2px !important; transition: 0.3s !important;
}

.tg-btn-start { font-size: 22px; padding: 30px 80px !important; animation: tg-button-pulse 2s infinite; }
@keyframes tg-button-pulse {
    0% { transform: scale(1); box-shadow: 0 0 30px rgba(0, 243, 255, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 60px rgba(0, 243, 255, 0.6); }
    100% { transform: scale(1); box-shadow: 0 0 30px rgba(0, 243, 255, 0.4); }
}

/* --- MODES SPECIFICITY --- */

/* Standard */
.dokany-exp-standard .tg-step { display: block !important; margin-bottom: 60px; }

/* Wizard */
.dokany-exp-wizard .tg-step { display: none !important; }
.dokany-exp-wizard .tg-step.active { display: block !important; animation: tgZoomIn 0.6s cubic-bezier(0.16, 1, 0.3, 1); }

/* Landing */
/* Le .tg-panel est caché tant que le JS n'a pas ajouté la classe .ready (au clic sur COMMENCER) */
.dokany-exp-landing .tg-perspective-wrap .tg-panel:not(.ready) { display: none !important; }

/* Le landing screen est positionné en overlay absolu dans le container */
.tg-landing-screen {
    position: absolute; inset: 0; z-index: 20;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; width: 100%; padding: 40px;
    animation: tg-power-on 1s ease-out;
    background: var(--tg-bg, #020204);
}
.tg-landing-hero { background: linear-gradient(135deg, var(--tg-primary, #00f3ff), var(--tg-secondary, #ff00ff)); padding: 100px 60px; width: 100%; margin-bottom: 60px; clip-path: polygon(10% 0, 100% 0, 100% 70%, 90% 100%, 0 100%, 0 30%); box-shadow: 0 0 50px rgba(0, 0, 0, 0.5); }
.tg-landing-hero h1 { font-family: var(--tg-font-heading, 'Orbitron', sans-serif); font-size: 64px; color: #000; text-transform: uppercase; letter-spacing: 5px; }
.tg-landing-hero p { font-family: var(--tg-font-body, 'Inter', sans-serif); font-size: 18px; color: rgba(0,0,0,0.8); margin-top: 20px; }

/* =============================================================
   CHAT MODE v2 — Interface Messenger / WhatsApp
   ============================================================= */

/* Container principal en mode chat */
.dokany-form-container.dokany-exp-chat {
    background: #0e0e11 !important;
    padding: 0 !important;
    min-height: 600px !important;
    align-items: stretch !important;
    justify-content: center !important;
}

/* Panel en mode chat : fenêtre de messagerie */
.dokany-form-container.dokany-exp-chat .tg-panel {
    width: 100% !important;
    max-width: 680px !important;
    height: 90vh !important;
    min-height: 600px !important;
    max-height: 900px !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    background: #16161a !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6) !important;
    transform: none !important;
    align-self: center !important;
}

/* Supprimer le HUD status en mode chat */
.dokany-form-container.dokany-exp-chat #tg-hud-status {
    display: none !important;
}

/* Fenêtre chat : doit remplir tout le .tg-panel et être flex column */
.dkc-window {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* ---- HEADER AGENT ---- */
.dkc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #1e1e24;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.dkc-agent-avatar {
    position: relative;
    flex-shrink: 0;
}

.dkc-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tg-primary, #00f3ff), var(--tg-secondary, #ff00ff));
    color: #000;
    font-family: var(--tg-font-heading, 'Orbitron', sans-serif);
    font-weight: 900;
    font-size: 13px;
    letter-spacing: 1px;
}

.dkc-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #00e676;
    border: 2px solid #1e1e24;
}

.dkc-agent-name {
    font-family: var(--tg-font-heading, 'Orbitron', sans-serif);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dkc-agent-status {
    font-size: 11px;
    color: #00e676;
    margin-top: 2px;
    font-family: var(--tg-font-body, 'Inter', sans-serif);
}

/* ---- ZONE MESSAGES ---- */
.dkc-messages-area {
    flex: 1;
    min-height: 0;        /* CRITIQUE : permet au flex-item de rétrécir sous sa taille naturelle */
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* Scrollbar personnalisée */
.dkc-messages-area::-webkit-scrollbar { width: 4px; }
.dkc-messages-area::-webkit-scrollbar-track { background: transparent; }
.dkc-messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }

/* ---- MESSAGES ---- */
.dkc-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 80%;
    animation: dkcMsgIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
}

.dkc-msg.dkc-msg-visible { opacity: 1; }
.dkc-msg.dkc-msg-visible { animation: none; opacity: 1; }

/* Message agent : aligné à gauche */
.dkc-msg-agent {
    align-self: flex-start;
    flex-direction: row;
}

/* Message user : aligné à droite */
.dkc-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 72%;
}

/* Mini avatar dans la zone messages */
.dkc-avatar-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tg-primary, #00f3ff), var(--tg-secondary, #ff00ff));
    color: #000;
    font-family: var(--tg-font-heading, 'Orbitron', sans-serif);
    font-weight: 900;
    font-size: 9px;
    flex-shrink: 0;
    margin-bottom: 4px;
}

/* ---- BULLES ---- */
.dkc-bubble {
    padding: 11px 16px;
    border-radius: 18px;
    font-family: var(--tg-font-body, 'Inter', sans-serif);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

/* Bulle agent : gris foncé, coin bas-gauche carré */
.dkc-bubble-agent {
    background: #2a2a32;
    color: #e8e8ee;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid rgba(255,255,255,0.06);
}

/* Bulle user : couleur primaire, coin bas-droite carré */
.dkc-bubble-user {
    background: var(--tg-primary, #00f3ff);
    color: #000;
    border-radius: 18px 18px 4px 18px;
    font-weight: 500;
}

.dkc-required-star { color: #ff5252; margin-left: 4px; }

/* ---- INDICATEUR "EN TRAIN D'ÉCRIRE" ---- */
.dkc-typing {
    display: flex !important;
    align-items: center;
    gap: 5px;
    padding: 14px 18px !important;
    min-width: 60px;
}

.dkc-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    animation: dkcDot 1.2s infinite ease-in-out;
}
.dkc-typing span:nth-child(1) { animation-delay: 0s; }
.dkc-typing span:nth-child(2) { animation-delay: 0.2s; }
.dkc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dkcDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ---- ZONE INPUT BAS ---- */
.dkc-input-area {
    flex-shrink: 0;
    background: #1a1a20;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 16px 14px;
}

.dkc-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dkc-field-wrapper {
    flex: 1;
    background: #26262e;
    border-radius: 25px;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    transition: border-color 0.2s;
}

/* Quand le wrapper contient un champ file, on passe en colonne */
.dkc-field-wrapper.dkc-has-file {
    border-radius: 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 16px;
}

/* Hint texte "Formats acceptés / Max" */
.dkc-file-hint {
    font-size: 11px;
    color: #9a9ab0;
    font-family: monospace;
    margin: 0;
    line-height: 1.5;
    width: 100%;
}

.dkc-field-wrapper:focus-within {
    border-color: var(--tg-primary, #00f3ff);
    box-shadow: 0 0 0 3px rgba(0, 243, 255, 0.1);
}

/* Input texte simple */
.dkc-text-input {
    width: 100%;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: #fff !important;
    font-family: var(--tg-font-body, 'Inter', sans-serif) !important;
    font-size: 14px !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.dkc-text-input::placeholder { color: rgba(255,255,255,0.3) !important; }

/* Champs spéciaux dans l'input area */
.dkc-field-wrapper .tg-input-field {
    background: transparent !important;
    border: none !important;
    border-bottom: none !important;
    outline: none !important;
    color: #fff !important;
    font-size: 14px !important;
    padding: 0 !important;
    width: 100% !important;
    box-shadow: none !important;
}

.dkc-field-wrapper select.tg-input-field {
    cursor: pointer;
}

.dkc-field-wrapper .tg-radio-group,
.dkc-field-wrapper .tg-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.dkc-field-wrapper .tg-radio-item,
.dkc-field-wrapper .tg-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ddd;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.15);
    transition: 0.2s;
}

.dkc-field-wrapper .tg-radio-item:hover,
.dkc-field-wrapper .tg-checkbox-item:hover {
    border-color: var(--tg-primary, #00f3ff);
    background: rgba(0, 243, 255, 0.08);
}

/* Bouton ENVOYER */
.dkc-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--tg-primary, #00f3ff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    color: #000;
    /* Fallback dur si variable CSS non chargée */
    background-color: #00f3ff;
}

.dkc-send-btn svg {
    width: 18px;
    height: 18px;
    transform: translateX(1px);
    display: block;
    fill: #000;
    color: #000;
    pointer-events: none;
}

.dkc-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
    background: #fff;
}

.dkc-send-btn:active {
    transform: scale(0.92);
}

.dkc-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Bouton soumettre final */
.dkc-submit-row {
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.dkc-submit-final {
    width: 100% !important;
    padding: 16px !important;
    font-size: 14px !important;
    border-radius: 12px !important;
    clip-path: none !important;
    background: linear-gradient(135deg, var(--tg-primary, #00f3ff), var(--tg-secondary, #ff00ff)) !important;
}

/* Formulaire caché */
.dkc-hidden-form { display: none !important; }

/* Erreur de champ dans l'input row */
.dkc-field-wrapper.dkc-field-error {
    border-color: #ff5252 !important;
    box-shadow: 0 0 0 3px rgba(255, 82, 82, 0.2) !important;
    animation: dkcShake 0.4s ease;
}

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

/* Animations d'entrée des messages */
@keyframes dkcMsgIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .dokany-form-container.dokany-exp-chat .tg-panel {
        height: 100svh !important;
        max-height: 100svh !important;
        border-radius: 0 !important;
        border: none !important;
        max-width: 100% !important;
    }
    .dkc-msg { max-width: 90%; }
    .dkc-msg-user { max-width: 85%; }
}

/* --- ADVANCED FIELDS CSS --- */
.tg-switch { position: relative; display: inline-block; width: 50px; height: 24px; }
.tg-switch input { opacity: 0; width: 0; height: 0; }
.tg-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 34px; }
.tg-slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .tg-slider { background-color: var(--tg-primary); }
input:checked + .tg-slider:before { transform: translateX(26px); }

.tg-rating { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 10px; }
.tg-rating input { display: none; }
.tg-rating label { cursor: pointer; width: 30px; height: 30px; background: #222; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); transition: 0.3s; }
.tg-rating input:checked ~ label, .tg-rating label:hover, .tg-rating label:hover ~ label { background: var(--tg-primary); box-shadow: 0 0 15px var(--tg-primary); }

.tg-signature-pad { background: #000; border: 1px solid var(--tg-border); border-radius: 8px; cursor: crosshair; touch-action: none; width: 100%; height: 150px; }

/* --- HUD UTILS --- */
.hidden { display: none !important; }
.field-error-HUD { border-color: var(--tg-error) !important; }
.field-error-HUD input, .field-error-HUD textarea, .field-error-HUD select { border-color: var(--tg-error) !important; box-shadow: 0 0 8px rgba(255,0,85,0.4); }

@keyframes tgZoomIn { from { opacity:0; transform: scale(0.97) translateY(10px); } to { opacity:1; transform: scale(1) translateY(0); } }
@keyframes tgSlideLeft { from { opacity:0; transform: translateX(-40px); } to { opacity:1; transform: translateX(0); } }
@keyframes tg-power-on { 0% { opacity: 0; transform: translateY(30px); } 100% { opacity: 1; transform: translateY(0); } }

/* 📱 RESPONSIVE HUD v5.1 */
@media (max-width: 768px) {
    #dokany-form-container { padding: 10px !important; min-height: 100vh !important; }
    .tg-panel { padding: 20px 15px !important; border-radius: 10px !important; transform: none !important; }
    .tg-title { font-size: 24px !important; }
    .tg-input-field { font-size: 16px !important; padding: 12px !important; }
    
    .dokany-exp-chat .tg-panel { height: 100vh !important; max-width: 100% !important; border-radius: 0 !important; border: none !important; }
    .dokany-exp-chat .tg-field-group { max-width: 90% !important; }
}
