﻿/* --- css/chat.css --- */

/* Area Messaggi */
.chat-messages-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: rgba(13, 20, 30, 0.4); /* Sfondo leggermente trasparente */
    scroll-behavior: smooth;
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
.chat-messages-area::-webkit-scrollbar { display: none; }

/* Bolla Messaggio Base */
.chat-bubble {
    max-width: 85%;
    padding: 15px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

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

/* Messaggio Utente (Destra) */
.chat-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: #ffffff;
    border-bottom-right-radius: 2px;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Messaggio AI (Sinistra - Stile Magistralis) */
.chat-bubble.ai {
    align-self: flex-start;
    background-color: #0d141e; /* Blu scurissimo istituzionale */
    color: #ffffff; 
    border-bottom-left-radius: 2px;
    border: 1px solid #c5b89a; /* Bordo dorato sottile */
    border-left: 4px solid #c5a059; /* Accento ORO laterale */
}

/* Player podcast inline nella chat */
.podcast-player {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(14, 22, 38, 0.95);
    border: 1px solid rgba(197, 160, 89, 0.25);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.podcast-player-title {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #c5a059;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.podcast-player-icon {
    font-size: 1rem;
}

.podcast-player audio {
    display: none;
}

.podcast-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.podcast-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(197, 160, 89, 0.25);
    background: rgba(8, 14, 24, 0.7);
    color: #c5a059;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.podcast-btn:hover {
    color: #ffd277;
    border-color: rgba(197, 160, 89, 0.55);
    text-shadow: 0 0 8px rgba(197, 160, 89, 0.6);
}

.podcast-btn:active {
    color: #0d141e;
    background: #c5a059;
}

.podcast-restart {
    font-size: 1rem;
}

.podcast-progress {
    position: relative;
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(197, 160, 89, 0.15);
    border: 1px solid rgba(197, 160, 89, 0.25);
    cursor: pointer;
}

.podcast-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, #77530a, #c5a059, #ffd277);
    transition: width 0.1s linear;
}

.podcast-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffd277;
    border: 1px solid #c5a059;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px rgba(197, 160, 89, 0.6);
    transition: left 0.1s linear;
    pointer-events: none;
}

.podcast-proposal {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(14, 22, 38, 0.95);
    border: 1px solid rgba(197, 160, 89, 0.25);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.podcast-proposal-actions {
    display: flex;
    gap: 10px;
}

.podcast-proposal-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(197, 160, 89, 0.25);
    background: rgba(8, 14, 24, 0.7);
    color: #c5a059;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.podcast-proposal-btn:hover {
    color: #ffd277;
    border-color: rgba(197, 160, 89, 0.55);
}

.podcast-proposal-yes {
    border-color: #c5a059;
}

.suggested-questions .podcast-proposal-actions {
    gap: 8px;
}

.suggested-question-btn {
    text-align: left;
    white-space: normal;
    line-height: 1.4;
}

.podcast-time {
    display: flex;
    justify-content: space-between;
    font-size: 0.80rem;
    font-weight: 600;
    color: #c5b89a;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0px;
}

/* Header interno alla bolla */
.chat-bubble-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* LOGO NELL'HEADER AI */
.chat-ai-logo-img {
    height: 35px; /* Dimensione logo */
    width: auto;
    display: block;
}

.chat-user-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #b3e5fc;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    text-align: right;
}

/* Area Input (Footer) */
.chat-input-container {
    padding: 15px;
    background: #0d141e;
    border-top: 1px solid #c5b89a;
    display: flex;
    gap: 10px;
    align-items: center;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    z-index: 10;
}

.chat-input-field {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #c5b89a;
    border-radius: 8px;
    padding: 12px 15px;
    color: white;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.3s;
}

.chat-input-field:focus {
    outline: none;
    border-color: #c5a059;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 10px #c5b89a;
}

/* Tasto invio tondo */
.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid #c5a059;
    background: linear-gradient(135deg, #1e2b38, #0d141e);
    color: #c5a059;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-send-btn:hover { transform: scale(1.05); background: #c5a059; color: #0d141e; }
.chat-send-btn:disabled { border-color: #555; color: #555; background: #141e30; cursor: not-allowed; }

/* Indicatore Thinking */
.typing-indicator {
    display: inline-block;
    width: 6px; height: 6px;
    background-color: #c5a059;
    border-radius: 50%;
    animation: typing 1s infinite;
    margin: 0 3px;
}
.typing-indicator:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-6px); opacity: 1; } }

/* Contenitore Bottoni Funzionali nel Footer */
.chat-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px; /* Spazio tra i bottoni spin */
    padding: 10px 0;
    background: #090f16; /* Fondo scurissimo */
    border-top: 1px solid #c5b89a;
}

/* Area Anteprima File (Sopra l'input) */
.file-preview-container {
    background-color: #15202b;
    border-top: 1px solid #c5b89a;
    padding: 0 15px;
    max-height: 0; /* Nascosto di default */
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.file-preview-container.active {
    padding: 10px 15px;
    max-height: 100px; /* Altezza quando ci sono file */
    overflow-y: auto;
}

/* Chip del file allegato */
.file-chip {
    background: #c5b89a;
    border: 1px solid #c5a059;
    color: #c5a059;
    border-radius: 15px;
    padding: 5px 10px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

.file-chip span {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-remove-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
}

.file-remove-btn:hover {
    color: #ff6b6b;
}

/* Pulsante Graffetta (Allegati) */
.chat-attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.chat-attach-btn:hover {
    color: #c5a059;
    border-color: #c5a059;
    background: #c5b89a;
}

/* Nascondiamo l'input file nativo brutto */
#chat-file-input {
    display: none;
}