/* Evidenziazione opzione 'Usa solo documenti indicizzati' */
.highlight-only-indexed {
    border: 2px solid #e53935; /* rosso acceso */
    border-radius: 6px;
    padding: 4px 8px;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --user-msg-bg: #eff6ff;
    --bot-msg-bg: #f1f5f9;
}

[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #94a3b8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #0f172a;
    --panel-bg: #1e293b;
    --border-color: #334155;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --user-msg-bg: #1e3a8a;
    --bot-msg-bg: #1e293b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation; /* Migliora la reattività touch */
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--panel-bg);
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    flex: 1;
}

.header-left h1 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.version-badge {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: normal;
    opacity: 0.7;
}

.header-right {
    display: flex;
    align-items: center;
}

.user-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-right: 20px;
}

.header-right .logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    color: #1f2937;
    flex-shrink: 0;
}

.pill-button {
    background: transparent;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-weight: 600;
    padding: 2px 8px;
    position: relative;
    z-index: 1;
    min-width: auto;
    white-space: nowrap;
}

.pill-button:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.pill-button.hidden {
    display: none !important;
}

.donate-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: white;
    padding: 8px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    width: fit-content;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.donate-button-login {
    flex: 1;
    margin: 0;
    padding: 10px 16px;
    display: flex;
    justify-content: center;
}

.donate-buttons-container {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin: 12px 0;
}

.donate-buttons-container-header {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-shrink: 0;
}

.donate-button-paypal {
    background: linear-gradient(135deg, #0070ba 0%, #00457c 100%);
    box-shadow: 0 2px 6px rgba(0, 112, 186, 0.3);
}

.donate-button-paypal:hover {
    background: linear-gradient(135deg, #005ea6 0%, #003d5c 100%);
    box-shadow: 0 4px 12px rgba(0, 112, 186, 0.4);
}

.donate-button-satispay {
    background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
    box-shadow: 0 2px 6px rgba(0, 212, 170, 0.3);
    display: none; /* Nascosto su desktop */
}

.donate-button-satispay:hover {
    background: linear-gradient(135deg, #00c39a 0%, #00a085 100%);
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.4);
    transform: translateY(-1px);
}

.donate-button-satispay:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 212, 170, 0.3);
}

.language-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-right: 12px;
    background: var(--panel-bg);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.language-button:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.language-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.language-button-top-right {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    margin-right: 0;
}

.theme-toggle-button {
    position: fixed;
    top: 20px;
    right: 100px;
    z-index: 1000;
    padding: 8px 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    width: 44px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0;
}

.theme-toggle-button:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .theme-toggle-button {
    background: var(--panel-bg);
    border-color: var(--border-color);
}

.header h1 {
    font-size: 28px;
    margin-bottom: 12px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.header h1 .header-logo {
    height: 43.2px;
    width: auto;
    object-fit: contain;
}

.status-bar {
    display: flex;
    gap: 30px;
    font-size: 14px;
}

.status-indicator, .history-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-select-header {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.model-select-header:hover {
    border-color: var(--primary-color);
}

.model-select-header:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.credit-input {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    background: white;
    width: 120px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.credit-input:hover {
    border-color: var(--primary-color);
    background: #f8fafc;
}

.credit-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.btn-clear-history {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 14px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.7;
    margin-left: 4px;
}

.btn-clear-history:hover {
    background: rgba(239, 68, 68, 0.1);
    opacity: 1;
    transform: scale(1.1);
}
.documents-panel .documents-summary,
.indexed-panel .documents-summary {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.documents-panel {
    position: relative;
    transition: all 0.2s ease;
}

.documents-panel.drag-over {
    background: rgba(37, 99, 235, 0.1);
    border: 2px dashed var(--primary-color);
    border-radius: 12px;
}

.documents-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.doc-item {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.doc-item .doc-name {
    font-weight: 600;
    color: var(--text-color);
    word-break: break-all;
    font-size: 13px;
}

.doc-item .doc-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

.doc-item .doc-badge {
    background: #dbeafe;
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
}

.doc-item.empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    border-style: dashed;
    background: transparent;
}

/* LED Indicators */
.led {
    width: 14.4px;
    height: 14.4px;
    border-radius: 50%;
    display: inline-block;
}

.led-red {
    background: var(--danger-color);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.led-green {
    background: var(--success-color);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
}

/* Panels */
.panel {
    background: var(--panel-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.panel h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-color);
    font-weight: 600;
}

/* Upload Section */
.upload-section {
    margin-bottom: 16px;
}

.file-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.file-label input[type="file"] {
    display: none;
}

.file-button {
    background: var(--primary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
    min-width: 60px;
    text-align: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.file-button:hover {
    background: var(--primary-dark);
}

.file-name {
    color: var(--text-muted);
    font-size: 13px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Info Panel */
.info-panel .settings {
    margin-bottom: 12px;
}

.info-panel .settings:last-child {
    margin-bottom: 0;
}

.info-panel .info-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    flex-direction: row;
}

.info-panel .credit-input {
    width: 200px;
    min-width: 200px;
    max-width: 200px;
    flex: 0 0 200px;
    order: 1;
}

.info-panel .info-label span {
    order: 2;
    font-weight: 500;
    color: var(--text-color);
}

/* Settings */
.settings {
    margin-bottom: 16px;
}

.settings label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.settings input[type="number"],
.settings select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.settings input[type="number"]:focus,
.settings select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.checkbox-group {
    margin-bottom: 16px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    display: inline-block;
    touch-action: manipulation; /* Previene doppio tap su mobile */
    -webkit-tap-highlight-color: transparent; /* Rimuove highlight su tap iOS */
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    padding: 4px 10px;
    font-size: 12px;
    min-width: 70px;
    height: 28px;
    width: 100%;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-send {
    background: var(--success-color);
    color: white;
    padding: 4px 10px;
    font-size: 12px;
    min-width: 70px;
    height: 28px;
    width: 100%;
}

.btn-send:hover {
    background: #059669;
}

.btn:disabled {
    background: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

/* Pulsanti compatti per azioni rapide */
.btn-compact {
    width: auto !important;
    min-width: auto !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    display: inline-block !important;
}

.btn-danger:hover {
    background: #dc2626;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Chat Container */
.chat-container {
    background: var(--panel-bg);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.welcome-message {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.welcome-message h3 {
    color: var(--text-color);
    margin-bottom: 16px;
}

.welcome-message ul {
    list-style: none;
    text-align: left;
    display: inline-block;
    margin-top: 16px;
}

.welcome-message li {
    margin-bottom: 8px;
}

.donation-notice {
    margin-top: 24px !important;
    padding: 16px !important;
    background: rgba(255, 193, 7, 0.15) !important;
    border-left: 4px solid #ffc107 !important;
    border-radius: 4px !important;
    color: var(--text-color) !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    display: block !important;
    text-align: left !important;
}

/* Message Bubbles */
.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-bot {
    display: flex;
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.message-user .message-bubble {
    background: var(--user-msg-bg);
    border: 1px solid #bfdbfe;
}

.message-bot .message-bubble {
    background: var(--bot-msg-bg);
    border: 1px solid var(--border-color);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.message-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    flex: 1;
}

.copy-button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.6;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.copy-button:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

.copy-button:active {
    transform: scale(0.95);
}

.message-bot .copy-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.message-content {
    white-space: pre-wrap;
    line-height: 1.5;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 400;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 2000;
}


.login-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.login-modal {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}

.login-modal input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin: 15px 0;
    font-size: 1em;
}

.password-wrapper {
    position: relative;
    width: 100%;
    margin: 15px 0;
}

.password-wrapper input {
    width: 100%;
    padding-right: 45px;
    margin: 0;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    user-select: none;
    font-size: 18px;
    opacity: 0.6;
    transition: opacity 0.2s;
    z-index: 10;
    line-height: 1;
}

.password-toggle:hover {
    opacity: 1;
}

.password-toggle.active {
    opacity: 1;
}

.login-error {
    color: var(--danger-color);
    font-weight: 600;
    min-height: 1.2em;
}

.login-success {
    color: var(--success-color);
    font-weight: 600;
    min-height: 1.2em;
}

.login-toggle {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.login-toggle a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.donation-notice-login {
    margin: 16px 0;
    padding: 12px 16px;
    background: rgba(255, 193, 7, 0.15);
    border-left: 4px solid #ffc107;
    border-radius: 6px;
    color: #333;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
}

.login-toggle a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* Chat Input */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.chat-input-container > div {
    flex: 1 1 0; /* Occupa tutto lo spazio disponibile */
    min-width: 0; /* Permette alla textarea di ridursi se necessario */
    position: relative;
}

.chat-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    flex: 0 0 90px; /* Larghezza fissa piccola, non si espande */
    width: 90px;
    max-width: 90px;
}

#question-input {
    width: 100%;
    padding: 12px 40px 12px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    background: white;
}

#question-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-voice-input {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    color: var(--text-muted);
    z-index: 10;
}

.btn-voice-input:hover {
    background: var(--border-color);
    color: var(--primary-color);
}

.btn-voice-input.recording {
    background: var(--danger-color);
    color: white;
    animation: pulse 1.5s infinite;
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

#loading-text {
    color: white;
    margin-top: 20px;
    font-size: 16px;
}


/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .chat-container {
        height: 600px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .header-left {
        width: 100%;
    }
    
    .header h1 {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .header h1 .header-logo {
        height: 32px;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .status-bar > * {
        width: 100%;
        justify-content: flex-start;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .user-actions {
        margin-right: 0;
        width: 100%;
        align-items: center;
        flex-wrap: wrap;
    }
    
    .user-pill {
        width: 100%;
        justify-content: space-between;
    }
    
    .donate-buttons-container,
    .donate-buttons-container-header {
        width: 100%;
        flex-direction: row;
        gap: 6px;
    }
    
    .language-button-top-right {
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 1000;
    }
    
    .theme-toggle-button {
        position: fixed;
        top: 10px;
        right: 70px;
        z-index: 1000;
    }
    
    .donate-button,
    .donate-button-login {
        flex: 1;
        text-align: center;
        font-size: 13px;
        padding: 10px 12px;
    }
    
    .donate-button-satispay {
        display: flex; /* Mostrato solo su mobile */
    }
    
    .language-button-top-right {
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 1000;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .panel {
        padding: 16px;
        margin-bottom: 15px;
    }
    
    .panel h2 {
        font-size: 16px;
        margin-bottom: 16px;
    }
    
    .chat-container {
        height: calc(100vh - 300px);
        min-height: 400px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .chat-input-container {
        padding: 12px;
        flex-direction: column;
        gap: 10px;
    }
    
    .chat-input-container textarea {
        font-size: 16px; /* Previene zoom su iOS */
        min-height: 80px;
        width: 100%;
    }
    
    .chat-input-container .btn-send {
        width: 100%;
        margin-top: 0;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px; /* Touch target minimo */
    }
    
    .file-button {
        padding: 12px 16px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .login-modal {
        max-width: 95%;
        padding: 20px;
        margin: 20px;
    }
    
    .login-modal input {
        font-size: 16px; /* Previene zoom su iOS */
        padding: 12px 14px;
        min-height: 44px;
    }
    
    .settings input[type="number"],
    .settings select {
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
    }
    
    .model-select-header,
    .credit-input {
        font-size: 14px;
        padding: 8px;
        min-height: 36px;
    }
    
    .welcome-message {
        padding: 20px 15px;
    }
    
    .welcome-message h3 {
        font-size: 18px;
    }
    
    .message {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .message-content {
        font-size: 14px;
    }
    
    .message-bubble {
        max-width: 90%;
    }
    
    .copy-button {
        min-width: 36px;
        height: 36px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .header {
        padding: 12px 15px;
        border-radius: 8px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .header h1 .header-logo {
        height: 28px;
    }
    
    .status-bar {
        font-size: 12px;
    }
    
    .status-indicator,
    .history-indicator {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .panel {
        padding: 12px;
        border-radius: 8px;
    }
    
    .panel h2 {
        font-size: 15px;
        margin-bottom: 12px;
    }
    
    .chat-container {
        height: calc(100vh - 280px);
        min-height: 350px;
        border-radius: 8px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .chat-input-container {
        padding: 10px;
        flex-direction: column;
        gap: 8px;
    }
    
    .chat-input-container textarea {
        min-height: 70px;
        font-size: 16px;
        width: 100%;
    }
    
    .chat-input-container .btn-send {
        width: 100%;
        margin-top: 0;
    }
    
    .btn-send {
        min-height: 44px;
        font-size: 16px;
    }
    
    .file-button {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .file-label {
        flex-direction: column;
        align-items: stretch;
    }
    
    .file-name {
        margin-top: 8px;
        text-align: center;
    }
    
    .language-button-top-right {
        top: 8px;
        right: 8px;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .theme-toggle-button {
        top: 8px;
        right: 60px;
        width: 36px;
        height: 32px;
        font-size: 16px;
    }
    
    .button-group {
        gap: 10px;
    }
    
    .login-modal {
        padding: 15px;
        border-radius: 12px;
    }
    
    .login-modal h2 {
        font-size: 20px;
    }
    
    .login-modal p {
        font-size: 14px;
    }
    
    .donation-notice-login {
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .user-pill {
        font-size: 14px;
        padding: 8px 12px;
    }
    
    .language-button-top-right {
        top: 8px;
        right: 8px;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .message {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .message-content {
        font-size: 13px;
    }
    
    .message-bubble {
        max-width: 95%;
        padding: 10px 14px;
    }
    
    .message-time {
        font-size: 10px;
    }
    
    .welcome-message {
        padding: 15px 10px;
    }
    
    .welcome-message h3 {
        font-size: 16px;
    }
    
    .welcome-message p,
    .welcome-message li {
        font-size: 13px;
    }
    
    .donation-notice {
        font-size: 12px;
        padding: 10px;
    }
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Tooltip personalizzato con sfondo oro */
.tooltip-container {
    position: relative;
}

.tooltip-container span[data-tooltip] {
    position: relative;
}

.tooltip-container span[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #1e293b;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    animation: tooltipFadeIn 0.15s ease-out forwards;
}

.tooltip-container span[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    border: 6px solid transparent;
    border-top-color: #ffd700;
    z-index: 1001;
    opacity: 0;
    animation: tooltipFadeIn 0.15s ease-out forwards;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

