/* ============================================
   CarExpo AI Assistant - Hero Component
   Design Apple/Tesla - Glassmorphism 2026
   ============================================ */

/* === SECTION PRINCIPALE === */
.ai-hero {
    position: relative;
    padding: 80px 40px 100px;
    overflow: hidden;
    background: linear-gradient(180deg, var(--home-bg) 0%, #0d0d10 100%);
}

.ai-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 150%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(232, 255, 71, 0.08) 0%, transparent 50%);
    pointer-events: none;
    animation: aiGlow 10s ease-in-out infinite;
}

@keyframes aiGlow {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.3; transform: translateX(-50%) scale(1.1); }
}

/* Particules flottantes subtiles */
.ai-hero__particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.ai-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--home-accent);
    border-radius: 50%;
    opacity: 0.3;
    animation: particleFloat 15s linear infinite;
}

.ai-particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 20s; }
.ai-particle:nth-child(2) { left: 25%; animation-delay: 2s; animation-duration: 18s; }
.ai-particle:nth-child(3) { left: 40%; animation-delay: 4s; animation-duration: 22s; }
.ai-particle:nth-child(4) { left: 55%; animation-delay: 1s; animation-duration: 19s; }
.ai-particle:nth-child(5) { left: 70%; animation-delay: 3s; animation-duration: 21s; }
.ai-particle:nth-child(6) { left: 85%; animation-delay: 5s; animation-duration: 17s; }

@keyframes particleFloat {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10% { opacity: 0.3; }
    90% { opacity: 0.3; }
    100% { transform: translateY(-100px) scale(1); opacity: 0; }
}

/* === HEADER SECTION === */
.ai-hero__header {
    position: relative;
    z-index: 2;
    text-align: center;
    margin-bottom: 48px;
}

.ai-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(232, 255, 71, 0.1);
    border: 1px solid rgba(232, 255, 71, 0.2);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--home-accent);
    margin-bottom: 24px;
}

.ai-hero__badge-dot {
    width: 8px;
    height: 8px;
    background: var(--home-accent);
    border-radius: 50%;
    animation: pulseDot 2s ease-in-out infinite;
    box-shadow: 0 0 12px var(--home-accent);
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
}

.ai-hero__title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ai-hero__title em {
    font-style: normal;
    background: linear-gradient(135deg, var(--home-accent) 0%, var(--home-accent-2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ai-hero__subtitle {
    font-size: 1.1rem;
    color: var(--home-text-muted);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
}

/* === CONTAINER CHAT PRINCIPAL === */
.ai-chat-container {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
}

/* === GLASSMORPHISM BOX === */
.ai-chat-box {
    position: relative;
    background: rgba(28, 28, 31, 0.6);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 32px 64px -32px rgba(0, 0, 0, 0.5);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-box:focus-within {
    border-color: rgba(232, 255, 71, 0.3);
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(232, 255, 71, 0.1) inset,
        0 0 60px -20px rgba(232, 255, 71, 0.2),
        0 32px 64px -32px rgba(0, 0, 0, 0.5);
}

/* Bordure subtile au focus (sans animation) */
.ai-chat-box:focus-within {
    border-color: rgba(232, 255, 71, 0.3);
}

/* === ZONE DE MESSAGES === */
.ai-messages {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-messages.active {
    max-height: 400px;
    overflow-y: auto;
}

.ai-messages-inner {
    padding: 24px 24px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar custom */
.ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* === MESSAGES === */
.ai-message {
    display: flex;
    gap: 12px;
    animation: messageSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.ai-message--user {
    flex-direction: row-reverse;
}

.ai-message__avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.ai-message--assistant .ai-message__avatar {
    background: linear-gradient(135deg, var(--home-accent), var(--home-accent-2));
    color: var(--home-bg);
}

.ai-message--user .ai-message__avatar {
    background: var(--home-surface);
    border: 1px solid var(--home-border);
    color: var(--home-text-muted);
}

.ai-message__content {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.ai-message--assistant .ai-message__content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px 18px 18px 4px;
}

.ai-message--user .ai-message__content {
    background: var(--home-accent);
    color: var(--home-bg);
    border-radius: 18px 18px 4px 18px;
}

/* Typing indicator */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.ai-typing span {
    width: 8px;
    height: 8px;
    background: var(--home-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* === ZONE INPUT === */
.ai-input-area {
    padding: 20px 24px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    border-top: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.ai-messages.active + .ai-input-area {
    border-top-color: rgba(255, 255, 255, 0.05);
}

.ai-input-wrapper {
    flex: 1;
    position: relative;
}

.ai-input {
    width: 100%;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    color: var(--home-text);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 56px;
    max-height: 150px;
    transition: all 0.3s ease;
    line-height: 1.5;
}

.ai-input::placeholder {
    color: var(--home-text-muted);
}

.ai-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(232, 255, 71, 0.3);
}

/* Bouton envoi */
.ai-send-btn {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--home-accent);
    border: none;
    border-radius: 16px;
    color: var(--home-bg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.ai-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(232, 255, 71, 0.3);
}

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

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ai-send-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.ai-send-btn:hover svg {
    transform: translateX(2px);
}

/* Loading state */
.ai-send-btn.loading svg {
    display: none;
}

.ai-send-btn.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(10, 10, 11, 0.3);
    border-top-color: var(--home-bg);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === SUGGESTIONS === */
.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 20px;
}

.ai-suggestion {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    font-size: 0.85rem;
    color: var(--home-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-suggestion:hover {
    background: rgba(232, 255, 71, 0.1);
    border-color: rgba(232, 255, 71, 0.3);
    color: var(--home-accent);
}

.ai-suggestion:active {
    transform: scale(0.97);
}

/* === CARTES VÉHICULES RECOMMANDÉS === */
.ai-vehicles {
    display: none;
    padding: 16px 24px 24px;
    gap: 12px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-vehicles.active {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    animation: fadeInUp 0.4s ease;
}

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

.ai-vehicles__title {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--home-accent);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-vehicles__title::before {
    content: '🚗';
}

.ai-vehicle-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.ai-vehicle-card:hover {
    border-color: var(--home-accent);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.ai-vehicle-card__image {
    aspect-ratio: 16/10;
    overflow: hidden;
    position: relative;
}

.ai-vehicle-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.ai-vehicle-card:hover .ai-vehicle-card__image img {
    transform: scale(1.05);
}

.ai-vehicle-card__score {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: linear-gradient(135deg, var(--home-accent), var(--home-accent-2));
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--home-bg);
}

.ai-vehicle-card__content {
    padding: 12px;
}

.ai-vehicle-card__title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--home-text);
}

.ai-vehicle-card__meta {
    font-size: 0.75rem;
    color: var(--home-text-muted);
    margin-bottom: 8px;
}

.ai-vehicle-card__price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--home-accent);
}

/* Responsive grid */
@media (max-width: 600px) {
    .ai-vehicles.active {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ai-vehicle-card__content {
        padding: 10px;
    }
    
    .ai-vehicle-card__title {
        font-size: 0.8rem;
    }
    
    .ai-vehicle-card__price {
        font-size: 0.9rem;
    }
}

/* Véhicules inline dans les messages */
.ai-vehicle-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 6px;
    background: rgba(232, 255, 71, 0.1);
    border: 1px solid rgba(232, 255, 71, 0.2);
    border-radius: 8px;
    color: var(--home-accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9em;
    transition: all 0.2s ease;
    margin: 2px 0;
}

.ai-vehicle-inline:hover {
    background: rgba(232, 255, 71, 0.2);
    border-color: var(--home-accent);
    transform: translateY(-1px);
}

.ai-vehicle-inline__thumb {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}

.ai-vehicle-inline__arrow {
    opacity: 0.6;
    font-size: 0.8em;
}

/* === FOOTER INFO === */
.ai-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--home-text-muted);
}

.ai-footer svg {
    width: 14px;
    height: 14px;
    opacity: 0.5;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .ai-hero {
        padding: 60px 20px 80px;
    }
    
    .ai-hero__title {
        font-size: clamp(1.75rem, 6vw, 2.5rem);
    }
    
    .ai-chat-box {
        border-radius: 20px;
    }
    
    .ai-messages.active {
        max-height: 300px;
    }
    
    .ai-messages-inner {
        padding: 16px 16px 0;
    }
    
    .ai-input-area {
        padding: 16px;
    }
    
    .ai-input {
        padding: 14px 16px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .ai-send-btn {
        width: 48px;
        height: 48px;
        border-radius: 14px;
    }
    
    .ai-suggestions {
        padding: 0 16px 16px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .ai-suggestion {
        flex-shrink: 0;
    }
    
    .ai-message__content {
        max-width: 85%;
        padding: 12px 14px;
        font-size: 0.9rem;
    }
    
    .ai-message__avatar {
        width: 32px;
        height: 32px;
        border-radius: 10px;
        font-size: 0.8rem;
    }
    
    .ai-vehicle-card {
        flex: 0 0 220px;
    }
}

/* === ANIMATIONS D'ENTRÉE === */
.ai-hero__badge,
.ai-hero__title,
.ai-hero__subtitle,
.ai-chat-box {
    opacity: 0;
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ai-hero__badge { animation-delay: 0.1s; }
.ai-hero__title { animation-delay: 0.2s; }
.ai-hero__subtitle { animation-delay: 0.3s; }
.ai-chat-box { animation-delay: 0.4s; }

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

/* === MODE COMPACT (intégré dans la page sans la section) === */
.ai-chat-compact {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    width: 400px;
    max-width: calc(100vw - 48px);
}

.ai-chat-compact .ai-chat-box {
    border-radius: 24px;
}

.ai-chat-compact .ai-messages.active {
    max-height: 350px;
}

/* Bouton flottant pour ouvrir */
.ai-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 998;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--home-accent), var(--home-accent-2));
    border: none;
    border-radius: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(232, 255, 71, 0.3);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(232, 255, 71, 0.4);
}

.ai-fab svg {
    width: 28px;
    height: 28px;
    color: var(--home-bg);
}

.ai-fab.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}
