/* Modern Chat UI - Full height within content area */

/* Reset */
* {
    box-sizing: border-box;
}

/* Chat section within content area */
.chat-section {
    height: calc(100vh - 120px); /* Account for navbar/footer */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: white;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

/* Simple modern header */
.chat-header {
    background: #3498db;
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-shrink: 0;
    position: relative;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.chat-header__left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header__logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-header__logo-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.chat-header__content h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.2;
}

.chat-header__content p {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.9;
    line-height: 1.1;
}

.chat-header__actions {
    display: flex;
    gap: 0.25rem;
}

.header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.header-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(52, 152, 219, 0.1);
    border-bottom: 1px solid rgba(52, 152, 219, 0.2);
    flex-shrink: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #27ae60;
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 0.8rem;
    color: #3498db;
    font-weight: 500;
}

.session-counter {
    margin-left: auto;
    font-size: 0.75rem;
    color: #6c757d;
    background: rgba(255,255,255,0.8);
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-weight: 500;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Quick actions bar */
.quick-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-action-btn {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.quick-action-btn:hover {
    background: #3498db;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

/* Messages container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: linear-gradient(to bottom, #f8f9fa, #ffffff);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
    min-height: 0; /* Important for flex scrolling */
    position: relative;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    margin: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #3498db, #2980b9);
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #2980b9, #21618c);
}

/* Message bubbles - clean design */
.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    position: relative;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message--user {
    background: #3498db;
    color: white;
    align-self: flex-end;
    margin-left: 20%;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
}

.message--ai {
    background: #f8f9fa;
    color: #2c3e50;
    border: 1px solid #e9ecef;
    align-self: flex-start;
    margin-right: 20%;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.message--welcome {
    background: #27ae60;
    color: white;
    align-self: flex-start;
    margin-right: 20%;
    text-align: left;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.25);
    max-width: 80%;
}

/* Message content formatting */
.message strong {
    font-weight: 600;
}

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

.message li {
    margin-bottom: 0.25rem;
}

/* Enhanced typing indicator */
.typing-indicator {
    display: flex;
    justify-content: flex-start;
    padding: 0 1rem;
    margin-bottom: 1rem;
}

.typing-bubble {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.typing-bubble::before {
    content: "L'assistente sta scrivendo";
    font-size: 0.8rem;
    color: #6c757d;
    margin-right: 0.5rem;
}

.dot {
    width: 8px;
    height: 8px;
    background: #3498db;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
.dot:nth-child(3) { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Modern input area */
.chat-input {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 1rem;
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
}

.input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: #f8f9fa;
    border-radius: 25px;
    padding: 0.5rem;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.input-container:focus-within {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.input-container__textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    font-family: inherit;
}

.input-container__textarea::placeholder {
    color: #adb5bd;
}

.input-container__actions {
    display: flex;
    gap: 0.5rem;
}

.action-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #6c757d;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.action-button--send {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.action-button--send:hover {
    background: linear-gradient(135deg, #2980b9 0%, #21618c 100%);
}

.action-button--send:disabled {
    background: #dee2e6;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.action-button--send.sending {
    background: #6c757d;
    animation: buttonPulse 1s infinite;
}

@keyframes buttonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Input footer */
.input-footer {
    display: flex;
    justify-content: center;
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.input-footer small {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
}

/* Error states */
.error-message {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 0.75rem;
    border-radius: 12px;
    margin: 0.5rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    animation: slideInShake 0.5s ease-out;
    box-shadow: 0 2px 10px rgba(220, 53, 69, 0.3);
    border: 1px solid rgba(255,255,255,0.2);
}

@keyframes slideInShake {
    0% { 
        transform: translateY(-20px) translateX(0);
        opacity: 0;
    }
    70% {
        transform: translateY(0) translateX(0);
        opacity: 1;
    }
    80% { transform: translateX(-3px); }
    90% { transform: translateX(3px); }
    100% { transform: translateX(0); }
}

/* Welcome message styling */
.welcome-content {
    text-align: left;
    line-height: 1.5;
}

.welcome-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.welcome-content p {
    margin: 0.3rem 0;
    font-size: 0.9rem;
}

.welcome-content p:last-child {
    margin-bottom: 0;
}

/* Remove visual feedback bars for cleaner look */
.message--ai {
    position: relative;
}

.message--user {
    position: relative;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chat-section {
        height: calc(100vh - 100px); /* Adjust for mobile navbar */
    }
    
    .chat-header {
        padding: 0.75rem;
    }
    
    .chat-header__logo {
        width: 40px;
        height: 40px;
    }
    
    .chat-header__content h2 {
        font-size: 1rem;
    }
    
    .chat-header__content p {
        font-size: 0.8rem;
    }
    
    .chat-messages {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .message {
        max-width: 90%;
        padding: 0.7rem 0.9rem;
        font-size: 0.85rem;
    }
    
    .message--user {
        margin-left: 10%;
    }
    
    .message--ai,
    .message--welcome {
        margin-right: 10%;
    }
    
    .quick-actions {
        padding: 0.75rem;
    }
    
    .quick-action-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
    
    .chat-input {
        padding: 0.75rem;
    }
    
    .header-btn {
        width: 36px;
        height: 36px;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .status-indicator {
        padding: 0.4rem 0.75rem;
    }
    
    .status-text {
        font-size: 0.75rem;
    }
    
    .message {
        max-width: 95%;
        padding: 0.65rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .message--user {
        margin-left: 5%;
    }
    
    .message--ai,
    .message--welcome {
        margin-right: 5%;
    }
    
    .input-container__textarea {
        font-size: 0.85rem;
        padding: 0.625rem 0.875rem;
    }
    
    .action-button {
        width: 40px;
        height: 40px;
    }
    
    .welcome-content h3 {
        font-size: 1rem;
    }
    
    .welcome-content li {
        font-size: 0.8rem;
    }
}

/* Loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.chat-container.loading {
    position: relative;
}

.chat-container.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}