:root {
    --bg-color: #f8fafc;
    --app-bg: #ffffff;
    --glass-border: rgba(226, 232, 240, 0.8);
    --accent-color: #2563eb;
    --text-primary: #0f172a;
    --text-secondary: #4b5563;
    --user-msg-bg: #2563eb;
    --user-msg-text: #ffffff;
    --ai-msg-bg: #ffffff;
    --input-bg: #f1f5f9;
    --header-bg: #ffffff;
    --font-main: 'Inter', sans-serif;
}

.dark-theme {
    --bg-color: #020617;
    --app-bg: #0f172a;
    --glass-border: rgba(51, 65, 85, 0.5);
    --accent-color: #3b82f6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --user-msg-bg: #3b82f6;
    --ai-msg-bg: rgba(255, 255, 255, 0.05);
    --input-bg: #1e293b;
    --header-bg: rgba(15, 23, 42, 0.8);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

header {
    flex-shrink: 0;
    padding: 12px 24px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.lang-selector {
    display: flex;
    background: var(--input-bg);
    border-radius: 100px;
    padding: 3px;
    border: 1px solid var(--glass-border);
}

.lang-selector button {
    background: transparent;
    border: none;
    padding: 5px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 100px;
    transition: all 0.3s ease;
}

.lang-selector button.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.engine-selector-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.engine-selector {
    display: flex;
    gap: 4px;
    background: var(--input-bg);
    padding: 3px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.engine-selector button {
    background: transparent;
    border: none;
    padding: 6px 14px;
    border-radius: 9px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.engine-selector button.active {
    background: var(--app-bg);
    color: var(--accent-color);
}

.icon-btn, .mini-info-btn {
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover, .mini-info-btn:hover {
    color: var(--accent-color);
    background: var(--input-bg);
}

main {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-color);
    width: 100%;
}

/* Rich Cards */
.rich-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    max-width: 260px;
    transition: transform 0.3s ease;
}

.rich-card:hover {
    transform: translateY(-5px);
}

.card-img-container {
    height: 120px;
    background-size: cover;
    background-position: center;
}

.dark-mode .rich-card {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .rich-card .text-muted {
    color: #94a3b8 !important;
}

/* Chat structure */
#chat-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto; /* Centratura assoluta */
    height: 100%;
    display: flex;
    flex-direction: column;
}

.welcome-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 900px;
    padding: 20px;
    z-index: 10;
}

.welcome-content {
    width: 100%;
    text-align: left;
}

.welcome-screen h2 {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 15px;
    letter-spacing: -0.04em;
}

.welcome-screen p {
    font-size: 1.15rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 35px;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    margin-top: 20px;
}

.suggestions button {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.suggestions button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

#messages {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 20px 0 100px 0;
    gap: 30px;
}

.message {
    width: 100%;
    animation: fadeIn 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

.user-message {
    align-items: flex-end;
}

.ai-message {
    align-items: flex-start;
}

.message-content {
    max-width: 85%;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.user-message .message-content {
    background: #f1f5f9;
    padding: 15px 25px;
    border-radius: 24px;
    color: var(--text-primary);
}

.ai-message .message-content {
    background: transparent;
    padding: 10px 0;
}

.dark-theme .user-message .message-content {
    background: #1e293b;
}

.dark-theme .ai-message .message-content {
    background: transparent;
}

footer {
    flex-shrink: 0;
    padding: 24px;
    background: var(--app-bg);
    border-top: 1px solid var(--glass-border);
}

.input-area {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--input-bg);
    padding: 10px 18px;
    border-radius: 22px;
    border: 1px solid var(--glass-border);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 10px 0;
    font-size: 1rem;
    color: var(--text-primary);
    resize: none;
    max-height: 150px;
}

/* Nuova Chat Button Style */
.reset-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    padding: 10px 18px;
    border-radius: 100px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #4338ca;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    margin-right: 10px;
    box-shadow: 0 2px 4px rgba(67, 56, 202, 0.05);
}

.reset-chat-btn:hover {
    background: #4338ca;
    color: white;
    border-color: #4338ca;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.2);
}

.dark-theme .reset-chat-btn {
    background: #312e81;
    border-color: #4338ca;
    color: #e0e7ff;
}

/* Confirm Modal Specifics */
.confirm-content {
    max-width: 400px;
    text-align: center;
    padding: 40px 30px;
}

.confirm-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
}

.confirm-btn {
    padding: 12px 25px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.confirm-btn.primary {
    background: var(--accent-color);
    color: white;
}

.confirm-btn.primary:hover {
    background: #1d4ed8;
}

.confirm-btn.secondary {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.confirm-btn.secondary:hover {
    background: #e2e8f0;
}

/* Voice & Reset Icon Style */
.input-action-btn {
    background: transparent;
    border: none;
    width: 42px;
    height: 42px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.input-action-btn:hover {
    color: var(--accent-color);
    background: rgba(37, 99, 235, 0.08);
}

.suggestion-pill {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 10px 20px;
    border-radius: 100px;
    font-size: 0.9rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.04);
}

.suggestion-pill:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

#mic-btn.listening {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#send-btn {
    background: var(--accent-color);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 15px;
    opacity: 0.7;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--app-bg);
    width: 100%;
    max-width: 1100px;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 32px;
    padding: 50px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}
.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background: var(--input-bg);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.close-modal:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg);
}

.pro-contra-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.engine-item {
    background: var(--input-bg);
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.pro-list, .contra-list {
    font-size: 0.85rem;
    padding: 12px;
    border-radius: 12px;
    margin-top: 10px;
}
.pro-list { background: rgba(16, 185, 129, 0.1); color: #065f46; }
.contra-list { background: rgba(239, 68, 68, 0.1); color: #991b1b; }

.svg-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

.message-actions {
    display: flex;
    gap: 12px;
    margin-top: 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ai-message:hover .message-actions {
    opacity: 1;
}

.action-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.action-icon-btn:hover {
    color: var(--accent-color);
}

.action-icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Markdown Styles */
.markdown-body p { margin-bottom: 12px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body ul, .markdown-body ol { margin-left: 20px; margin-bottom: 12px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body pre { background: var(--input-bg); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
.markdown-body code { background: var(--input-bg); padding: 2px 5px; border-radius: 4px; font-family: monospace; font-size: 0.85em; color: var(--accent-color); }
.dark-theme .markdown-body code { background: #1e293b; color: #60a5fa; }
.markdown-body a { color: var(--accent-color); text-decoration: none; font-weight: 500; }
.markdown-body a:hover { text-decoration: underline; }


.sun-icon, .moon-icon { display: flex; align-items: center; justify-content: center; }
.light-theme .moon-icon { display: none; }
.dark-theme .sun-icon { display: none; }

/* Professional Technical Table Styles */
.tech-table-container {
    width: 100%;
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: var(--app-bg);
}

.tech-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
    table-layout: fixed;
}

.tech-table th {
    background: var(--input-bg);
    padding: 20px 15px;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    border-bottom: 2px solid var(--glass-border);
}

.tech-table td {
    padding: 20px 15px;
    border-bottom: 1px solid var(--glass-border);
    line-height: 1.6;
    vertical-align: top;
    word-wrap: break-word;
}

.tech-table tr:last-child td {
    border-bottom: none;
}

.tech-table tr:hover {
    background: rgba(37, 99, 235, 0.03);
}

.text-pro {
    color: #059669;
    font-weight: 600;
    font-size: 0.85rem;
}

.text-contra {
    color: #dc2626;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Premium Scrollbar for Modals */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
    margin: 20px; /* Distanzia lo scrollbar dai bordi arrotondati */
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.dark-theme .modal-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Status Badge & Loading Overlay Restore */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--input-bg);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    white-space: nowrap;
}

.status-ready .dot {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    display: inline-block;
}

#loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--app-bg);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.5s ease;
}

.loader-content {
    text-align: center;
    width: 100%;
    max-width: 400px;
    padding: 40px;
}

.progress-container {
    width: 100%;
    height: 6px;
    background: var(--input-bg);
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

#progress-text {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-logo {
    height: 30px;
    width: auto;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.model-badge {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0.6;
}

.spinner-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--input-bg);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#progress-group {
    transition: opacity 0.3s ease;
}
.typing-active .message-content::after {
    content: '●';
    margin-left: 4px;
    font-size: 0.8rem;
    color: var(--accent-color);
    animation: cursor-blink 0.8s infinite;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.demo-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-color);
    color: white;
    padding: 8px 16px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.demo-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
    filter: brightness(1.1);
}

.demo-btn span {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .demo-btn span { display: none; }
    .demo-btn { padding: 8px; }
}
