/* ==========================================================================
   Stilfull AI Seksjon (Optimert og Responsiv)
   ========================================================================== */
.ai-section-stylish {
    padding: 60px 0;
    margin-top: -120px; /* Trekker seksjonen opp for en overlappende effekt */
    position: relative;
    z-index: 5;
}

#cr8-wizard-container {
    /* Generell container-styling */
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    min-height: 250px;
    padding: 20px;
    border-radius: 16px;

    /* Forbedret "glass"-effekt */
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
    
    /* Flexbox for å strukturere innholdet */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#chat-step-wrapper {
    margin-bottom: 1.5rem; /* Bruker rem for skalerbarhet */
    flex-grow: 1; /* Sørger for at meldingsområdet vokser */
}

/* ==========================================================================
   Meldinger og Bobler
   ========================================================================== */
.kai-message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 100%; /* Forhindrer overflow */
}

.kai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.1);
    margin-top: 5px;
    flex-shrink: 0; /* Forhindrer at avataren krymper */
}

.kai-message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0; /* Viktig for å la flex-items krympe korrekt */
}

.kai-name {
    font-size: 0.9rem;
    font-weight: bold;
    color: #425466;
    margin-bottom: 4px;
}

.kai-bubble {
    background-color: #e9ecef;
    color: #0a2540;
    padding: 12px 16px;
    border-radius: 18px;
    border-top-left-radius: 4px;
    max-width: 100%;
    text-align: left;
    font-size: 1rem;
    line-height: 1.5;
    word-break: break-word; /* Bryter lange ord for å unngå overflow */
}

/* ==========================================================================
   Input-felt og Knapp
   ========================================================================== */
#chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 20px;
}

#chat-input {
    flex-grow: 1;
    background-color: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #0a2540;
    border-radius: 20px;
    padding: 10px 15px;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    transition: all 0.2s ease;
    min-width: 0; /* Lar feltet krympe */
}
#chat-input:focus {
    outline: none;
    border-color: #6c56f7;
    background-color: #fff;
}

#chat-send-btn {
    background-color: #6c56f7;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0; /* Forhindrer at knappen krymper */
}
#chat-send-btn:hover {
    background-color: #5643d5;
}
#chat-send-btn svg {
    color: white;
}

/* ==========================================================================
   Animasjoner og Hjelpeklasser
   ========================================================================== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-10px); } }

#chat-current-step.fade-in { animation: fadeIn 0.4s ease-out forwards; }
#chat-current-step.fade-out { animation: fadeOut 0.4s ease-in forwards; }

.is-hidden { display: none !important; }

#chat-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 0, 0, 0.2);
    border-top-color: #0a2540;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); }}

/* ==========================================================================
   Responsivitet for mobil
   ========================================================================== */
@media (max-width: 768px) {
    .ai-section-stylish {
        padding: 40px 16px; /* Mindre padding på mobil */
        margin-top: -80px;
    }

    #cr8-wizard-container {
        padding: 16px;
    }
}