/**
 * Chat AI Module CSS
 * Integrazione con sistema modulare Bologna Marathon
 */

/* Chat Container Base */
.chat-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    border: 2px solid var(--border, #e5e7eb);
    border-radius: 0.75rem;
    background: var(--bg-chat, #ffffff);
    box-shadow: var(--shadow, 0 4px 6px rgba(0, 0, 0, 0.1));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Chat Area */
.chat-area {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: var(--bg-main, #f9fafb);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
}

/* Message Styles */
.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease-in;
}

.message.user {
    flex-direction: row-reverse;
    font-size: 14px;
}

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

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.avatar.user {
    background: linear-gradient(135deg, var(--primary, #23a8eb), var(--secondary, #dc335e));
    color: white;
}

.avatar.ai {
    background: var(--bg-ai, #f3f4f6);
    color: var(--primary, #23a8eb);
    border: 2px solid var(--primary, #23a8eb);
}

/* Message Content */
.message-content {
    max-width: 91%;
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--secondary);
    color: white;
    border-bottom-right-radius: 0;
    padding: var(--space-xs) var(--space-md);
}

.message.ai .message-content {
    /* background: #00000014; */
    /* color: var(--text-dark, #111827); */
    border-bottom-left-radius: 0.25rem;
    font-family: var(--accent-rgb);
}

/* Message Text */
.message-text {
    line-height: 1.5;
    word-wrap: break-word;
}

/* Markdown styling */
.message-content strong {
    font-weight: 700;
    color: var(--primary, #23a8eb);
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content ul, .message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin: 0.25rem 0;
}

.message.ai .message-content strong {
    color: var(--primary, #23a8eb);
}

.message.user .message-content strong {
    color: white;
    text-decoration: underline;
}

/* Typing Indicator */
.typing {
    display: inline-flex;
    gap: 0.25rem;
}

.typing span,
.typing .typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-light, #6b7280);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing span:nth-child(2),
.typing .typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing span:nth-child(3),
.typing .typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
.input-area {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border, #e5e7eb);
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 0.75rem;
    border: 2px solid var(--border, #e5e7eb);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--primary, #23a8eb);
}

.send-button {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary, #23a8eb), var(--secondary, #dc335e));
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(35, 168, 235, 0.4);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-button {
    padding: 0.75rem;
    background: var(--bg-ai, #f3f4f6);
    color: var(--text-dark, #374151);
    border: 2px solid var(--border, #e5e7eb);
    border-radius: 0.5rem;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-button:hover {
    background: var(--primary, #23a8eb);
    color: white;
    border-color: var(--primary, #23a8eb);
}

/* Chat AI Area (per elementi esistenti) */
.chat-ai-area {
    position: relative;
    /* border: 1px solid var(--border, #e5e7eb); */
    /* border-radius: 0.5rem; */
    padding: 7rem 1rem 5rem 1rem;
    /* background: var(--bg-main, #f9fafb); */
    /* font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; */
    transition: all 0.3s ease-in-out;
}




/* Welcome Message */
.welcome {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-light, #6b7280);
}

.welcome h2 {
    color: var(--text-dark, #111827);
    margin-bottom: 1rem;
    font-size: 1.75rem;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.suggestion {
    background: var(--bg-ai, #f3f4f6);
    padding: 1rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.suggestion:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow, 0 1px 3px rgba(0, 0, 0, 0.1));
    border-color: var(--primary, #23a8eb);
}

.suggestion-title {
    font-weight: 600;
    color: var(--primary, #23a8eb);
    margin-bottom: 0.25rem;
}

/* Scrollbar */
.chat-area::-webkit-scrollbar {
    width: 8px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--border, #e5e7eb);
    border-radius: 4px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-light, #6b7280);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        border-radius: 0;
    }
    
    .chat-area {
        padding: 0.5rem;
        max-height: 300px;
    }
    
    .message-content {
        max-width: 96%;
        padding: 12px 6px;
    }
    
    .input-area {
        padding: 0.5rem;
    }
    
    .send-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    .swiper-slide {
        padding: 0 10px!important;
    }
    .chat-area--container{
        min-height: 100vh!important;
    }
    .swiper.chat-swiper {
    min-height: 100%;
}
}

/* Theme Variants */
.chat-container.theme-dark {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

.chat-container.theme-dark .chat-area {
    background: #111827;
}

.chat-container.theme-dark .input-area {
    background: #1f2937;
    border-color: #374151;
}

.chat-container.theme-dark .chat-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

.chat-container.theme-dark .chat-input:focus {
    border-color: var(--primary, #23a8eb);
}

/* Size Variants */
.chat-container.size-small {
    height: 250px;
}

.chat-container.size-medium {
    height: 400px;
}

.chat-container.size-large {
    height: 500px;
}

.chat-container.size-full {
    height: 100vh;
}

/* Loading States */
.message.loading .message-content {
    opacity: 0.7;
}

/* Error States */
.message.error .message-content {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Success States */
.message.success .message-content {
    background: #d1fae5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

/* ===== CLASSI CSS PER JAVASCRIPT (NO INLINE STYLES) ===== */

/* Chat Area States */
.chat-area--hidden {
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
}

.chat-area--visible {
    opacity: 1;
    height: auto;
    /* max-height: var(--chat-height, 300px); */
    overflow: auto;
    transition: all 0.3s ease-in-out;
}

.chat-area--block {
    /* display: block; */
}

.chat-area--none {
    display: none;
}

.chat-area--positioned {
    position: relative;
}

/* Textarea States */
.textarea--hidden {
    display: none;
}

.textarea--auto-height {
    height: auto;
    min-height: 40px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
}

.textarea--dynamic-height {
    height: auto;
    min-height: 40px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
}

/* Input Area Layout */
.input-area--layout {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-light, #f8f9fa);
    border-top: 1px solid var(--border-light, #e5e7eb);
}

/* New Textarea Styles */
.new-textarea--style {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 0.75rem;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
}

.new-textarea--style:focus {
    border-color: var(--primary, #23a8eb);
    box-shadow: 0 0 0 3px rgba(35, 168, 235, 0.1);
}

/* Send Button Styles */
.send-button--style {
    padding: 0.75rem 1.5rem;
    background: var(--primary, #23a8eb);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.send-button--style:hover {
    background: var(--primary-dark, #1e8bc3);
    transform: translateY(-1px);
}

.send-button--style:disabled {
    background: var(--text-muted, #9ca3af);
    cursor: not-allowed;
    transform: none;
}



/* File Input Hidden */
.file-input--hidden {
    display: none;
}


/* Close Button Styles */
.close-button--style {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    /* background: rgba(0, 0, 0, 0.1); */
    /* color: #666; */

    border-radius: 50%;
    cursor: pointer;




    z-index: 10;
}




/* Chat Area Container */
.chat-area--container {
    position: relative;
    background: var(--gradient-dark);
    /* border-radius: 0.75rem; */
    /* box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); */
    overflow: hidden;
    /* max-width: 800px; */
    right: 0px;
    margin: auto;
    margin-right: 0;
}

/* Container Display */
.container--flex {
    display: flex;
}
.chat_contest_hide_menu  .swiper-slide {
    border-left: solid 1px #ffffff1a;
    padding: var(--space-md);
    /* max-width: 491px; */
}
.chat_contest_hide_menu .swiper-slide {
    border-left: 1px solid #ffffff26;
    padding: var(--space-xs) var(--space-md);
}