/* ====================================================
   MYETV AI BOT - STILE DEFINITIVO
   Colori: Goldenrod & Dark Goldenrod
   ==================================================== */

:root {
    --myetv-goldenrod: #DAA520;
    --myetv-dark-goldenrod: #B8860B;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ====================================================
   1. GABBIA FLEXBOX ANTI-ROTTURA
   ==================================================== */
html, body {
    height: 100dvh !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.container-fluid.p-0.d-flex.h-100 {
    height: 100dvh !important;
    overflow: hidden !important;
}

#chatArea {
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
    flex: 1 1 0 !important;
}

#chatHeader, #inputArea {
    flex: 0 0 auto !important;
    min-height: min-content !important;
}

#messagesContainer {
    flex: 1 1 0px !important;
    min-height: 0 !important;
    height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* ====================================================
   2. UTILITY COLORI E PULSANTI
   ==================================================== */
.bg-goldenrod {
    background: linear-gradient(135deg, var(--myetv-goldenrod) 0%, var(--myetv-dark-goldenrod) 100%) !important;
}

.text-goldenrod {
    color: var(--myetv-goldenrod) !important;
}

.custom-btn-goldenrod {
    background: linear-gradient(135deg, var(--myetv-goldenrod), var(--myetv-dark-goldenrod));
    color: white !important;
    border: none;
    transition: all 0.3s ease;
}

    .custom-btn-goldenrod:hover, .custom-btn-goldenrod:focus {
        background: linear-gradient(135deg, var(--myetv-dark-goldenrod), var(--myetv-goldenrod));
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(218, 165, 32, 0.4);
    }

/* ====================================================
   3. STILE ELEMENTI CRONOLOGIA
   ==================================================== */
.chat-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    background: #495057;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    position: relative;
    color: #f8f9fa;
}

    .chat-item:hover {
        background: #6c757d;
        border-left-color: var(--myetv-goldenrod);
        transform: translateX(3px);
    }

    .chat-item.active {
        background: rgba(218, 165, 32, 0.2);
        border-left-color: var(--myetv-goldenrod);
    }

.chat-item-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

.chat-item-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.chat-item-preview {
    font-size: 12px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ====================================================
   4. STILE CHAT E MESSAGGI
   ==================================================== */
.message {
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
    max-width: 100%;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-bot {
    display: flex;
    justify-content: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 15px 20px;
    border-radius: 1.25rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
    font-size: 0.95rem;
    line-height: 1.5;
}

.message-user .message-content {
    background: linear-gradient(135deg, var(--myetv-goldenrod), var(--myetv-dark-goldenrod));
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message-bot .message-content {
    background: white;
    color: #212529;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 0.25rem;
}

    .message-bot .message-content a {
        color: var(--myetv-dark-goldenrod);
        text-decoration: underline;
        word-break: break-all;
    }

.message-user .message-content a {
    color: rgba(255,255,255,0.9);
    text-decoration: underline;
    word-break: break-all;
}

.message-time, .message-tokens {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 8px;
}

.message-user .message-time, .message-user .message-tokens {
    color: rgba(255, 255, 255, 0.8);
}

.prompt-suggestion {
    transition: all 0.2s ease;
    border-color: var(--myetv-goldenrod);
    color: #333;
}

    .prompt-suggestion:hover {
        background: var(--myetv-goldenrod);
        color: white;
        transform: translateY(-2px);
    }

.message-error {
    background: #f8d7da !important;
    color: #842029 !important;
    border: 1px solid #f5c2c7 !important;
}

.message-warning {
    background: #fff3cd !important;
    color: #664d03 !important;
    border: 1px solid #ffecb5 !important;
}

.message-info {
    background: #e7f3ff !important;
    color: #0c5460 !important;
    border: 1px solid #bee5eb !important;
    padding: 12px 15px;
    border-radius: 15px;
    margin-top: 10px;
}

/* ====================================================
   5. AREA DI INPUT
   ==================================================== */
#messageInput {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #dee2e6;
    border-radius: 1rem;
    font-size: 1rem;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    transition: all 0.2s;
    background-color: #f8f9fa;
    color: #212529;
    font-family: inherit;
    box-shadow: none;
}

    #messageInput:focus {
        outline: none;
        background-color: #ffffff;
        box-shadow: 0 0 0 0.25rem rgba(218, 165, 32, 0.25);
        border-color: var(--myetv-goldenrod);
    }

    #messageInput.error {
        border-color: #dc3545 !important;
        background-color: #f8d7da;
    }

    #messageInput.warning {
        border-color: #ffc107 !important;
    }

.file-input {
    position: absolute;
    left: -9999px;
}

.file-item {
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.file-item-remove {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

/* ====================================================
   6. ANIMAZIONI E ADSENSE
   ==================================================== */
.highlight-message {
    animation: highlight-fade 3s ease-in-out;
    border-left: 4px solid var(--myetv-goldenrod) !important;
    border-radius: 1.25rem;
}

@keyframes highlight-fade {
    0% {
        background-color: rgba(218, 165, 32, 0.4);
    }

    50% {
        background-color: rgba(218, 165, 32, 0.2);
    }

    100% {
        background-color: transparent;
    }
}

.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: white;
    border-radius: 20px;
    max-width: fit-content;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    color: #6c757d;
    font-size: 14px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dot {
    width: 6px;
    height: 6px;
    background: var(--myetv-goldenrod);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite both;
}

    .loading-dot:nth-child(1) {
        animation-delay: -0.32s;
    }

    .loading-dot:nth-child(2) {
        animation-delay: -0.16s;
    }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.streaming-cursor {
    display: inline-block;
    width: 8px;
    height: 15px;
    background-color: var(--myetv-goldenrod);
    margin-left: 4px;
    animation: blink 1s step-end infinite;
    vertical-align: middle;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

ins.adsbygoogle[data-ad-status="filled"] {
    z-index: 9999;
}

/* ====================================================
   7. RESPONSIVE MOBILE (< 768px)
   ==================================================== */
@media (max-width: 768px) {
    .container-fluid.p-0.d-flex.h-100 {
        height: 100dvh !important;
        overflow: hidden !important;
    }

    #chatArea {
        height: 100dvh !important;
        min-height: 0 !important;
        flex: 1 1 0 !important;
    }
}
