/*
------------------------------------------------------------
Copyright (c) 2025 BI@Work Srl Socio Unico
All rights reserved.

This software is part of the E17 project.
E17 is a registered trademark of BI@Work Srl Socio Unico.
------------------------------------------------------------
*/

/* === Welcome message spacing === */
.welcome-section-separator {
  margin-top: 24px;
  display: block;
}

.welcome-mode-item {
  margin-bottom: 6px;
  display: block;
}

/* === 📱 Feedback visivo mobile (2-tap) === */
.mobile-btn-selected {
  border: 2px solid #28a745 !important;
  box-shadow: 0 0 10px rgba(40, 167, 69, 0.6) !important;
  animation: mobile-pulse 1.5s infinite;
  position: relative;
}

.mobile-btn-selected::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -8px;
  background: #28a745;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes mobile-pulse {
  0%, 100% {
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.6);
  }
  50% {
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.9);
  }
}

/* Dark mode */
body.dark-mode .mobile-btn-selected {
  border-color: #3ddc84 !important;
  box-shadow: 0 0 12px rgba(61, 220, 132, 0.7) !important;
}

body.dark-mode .mobile-btn-selected::after {
  background: #3ddc84;
}

/* === Uploaded file banner (light + dark) === */
#currentFile.current-file {
  background: #e8f7ee; /* più visibile */
  color: #0f5132;
  border: 2px solid #2ecc71;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0 14px 0;
  box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.15);
}
#currentFile .file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#currentFile .file-message strong {
  font-weight: 700;
}

/* Dark mode: high contrast for banner */
body.dark-mode #currentFile.current-file {
  background: #1f3a29;
  color: #d8f3dc;
  border: 2px solid #27ae60;
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.25);
}
body.dark-mode #currentFile .file-message { color: #e8eaed; }
body.dark-mode #currentFile .file-message strong { color: #f0f3f7; }

/* Close button visibility in dark mode */
#currentFile #removeFile.btn.btn-sm.btn-outline-danger {
  border-radius: 8px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 10px;
}
body.dark-mode #currentFile #removeFile.btn.btn-sm.btn-outline-danger {
  color: #ff6b6b;
  border-color: #596175;
  background: transparent;
}
body.dark-mode #currentFile #removeFile.btn.btn-sm.btn-outline-danger:hover,
body.dark-mode #currentFile #removeFile.btn.btn-sm.btn-outline-danger:focus {
  background: #2d3342;
  color: #ff8080;
  border-color: #6a7288;
}
body.dark-mode #currentFile #removeFile.btn.btn-sm.btn-outline-danger:active {
  background: #3a4150;
  border-color: #77809a;
}
/* Multi-colonna per livelli (archivi) */
#archivesTree.multi-column {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 1fr);
    gap: 8px;
    overflow-x: auto;
}

#archivesTree.multi-column .level-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#archivesTree .archive-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
    line-height: 1.1;
    white-space: nowrap;
}

#archivesTree .archive-item label {
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-mode #archivesTree.multi-column {
    background-color: #0f172a;
}

/* Variante: figli sulla stessa riga */
#archivesTree.inline-children .archives-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 4px 0;
}

#archivesTree.inline-children .archives-parent {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 200px;
    font-size: 0.95rem;
}

#archivesTree.inline-children .archives-children {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px 10px;
}

#archivesTree.inline-children .child-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 260px;
    white-space: nowrap;
}

#archivesTree.inline-children .child-item label,
#archivesTree.inline-children .archives-parent label {
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-mode #archivesTree.inline-children .archives-row { border-color: #1f2937; }
/* === DARK MODE: Foresta archivi EXTRA (chat) === */
body.dark-mode #archivesTree {
    background-color: #232c33 !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text) !important;
}
body.dark-mode #archivesTree > div,
body.dark-mode #archivesTree span {
    color: var(--color-text) !important;
}
body.dark-mode #archivesTree input[type="checkbox"] {
    accent-color: var(--e17-green-soft, #5CC31A);
}
body.dark-mode #archivesTree input[type="checkbox"][disabled] + span,
body.dark-mode #archivesTree input[type="checkbox"][disabled] {
    opacity: 0.6;
}
#archivesTree > div { padding: 2px 0; }
/* Font personalizzato Automata Display (disponibile per uso futuro) */
@font-face {
    font-family: 'AutomataDisplay';
    src: local('AutomataDisplay'),
         url('/chat-static/fonts/automata_display_sJTLK62OfI.woff2') format('woff2'),
         url('/chat-static/fonts/automata_display_sJTLK62OfI.woff') format('woff'),
         url('/static/fonts/automata_display_sJTLK62OfI.woff2') format('woff2'),
         url('/static/fonts/automata_display_sJTLK62OfI.woff') format('woff'),
         url('/chat-static/fonts/automata_display_sJTLK62OfI.ttf') format('truetype'),
         url('/static/fonts/automata_display_sJTLK62OfI.ttf') format('truetype'),
         url('/chat-static/fonts/automata_display_sJTLK62OfI.otf') format('opentype'),
         url('/static/fonts/automata_display_sJTLK62OfI.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
/* Mappa anche weight 500 allo stesso file per evitare fallback */
@font-face {
    font-family: 'AutomataDisplay';
    src: local('AutomataDisplay'),
         url('/chat-static/fonts/automata_display_sJTLK62OfI.woff2') format('woff2'),
         url('/chat-static/fonts/automata_display_sJTLK62OfI.woff') format('woff'),
         url('/static/fonts/automata_display_sJTLK62OfI.woff2') format('woff2'),
         url('/static/fonts/automata_display_sJTLK62OfI.woff') format('woff'),
         url('/chat-static/fonts/automata_display_sJTLK62OfI.ttf') format('truetype'),
         url('/static/fonts/automata_display_sJTLK62OfI.ttf') format('truetype'),
         url('/chat-static/fonts/automata_display_sJTLK62OfI.otf') format('opentype'),
         url('/static/fonts/automata_display_sJTLK62OfI.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
/* Migliora visibilità link in tema scuro (tempo risposta + link WEB) */
body.dark-mode .time-info a.retry-web-link {
    color: #06B6D4;
    text-decoration: underline;
}
body.dark-mode .time-info a.retry-web-link:hover,
body.dark-mode .time-info a.retry-web-link:focus {
    color: #22D3EE;
    text-decoration: underline;
    outline: none;
}

/* Link generali nei messaggi in tema scuro */
body.dark-mode .message-content a {
    color: #06B6D4;
    text-decoration: underline;
}
body.dark-mode .message-content a:hover,
body.dark-mode .message-content a:focus {
    color: #22D3EE;
}
/* ===== Template color coding (pills + legend) ===== */
.filter-results-list .pill-source {
  border-color: var(--e17-cyan) !important;
  color: #0b6d88 !important;
}
.filter-results-list .pill-source.selected {
  background-color: var(--e17-cyan) !important;
  color: #fff !important;
}
.filter-results-list .pill-dest {
  border-color: var(--e17-magenta) !important;
  color: #8a0b4b !important;
}
.filter-results-list .pill-dest.selected {
  background-color: var(--e17-magenta) !important;
  color: #fff !important;
}
.filter-results-list .pill-selected-only {
  background-color: #FFF7CC !important; /* giallo post-it */
  border-color: #F59F00 !important;
  color: #5b3d00 !important;
}
.filter-results-list .pill-paired::after {
  content: "\25CF"; /* dot */
  display: inline-block;
  margin-left: 6px;
  color: rebeccapurple;
  font-size: 0.8em;
}

/* legend chips in toolbar */
.template-legend { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.template-legend .chip { display:inline-flex; align-items:center; gap:6px; padding:2px 6px; border:1px solid #ccc; border-radius:10px; font-size:12px; }
.template-legend .chip-source { border-color: var(--e17-cyan); color:#0b6d88; }
.template-legend .chip-dest { border-color: var(--e17-magenta); color:#8a0b4b; }
.template-legend .chip-selected { background:#FFF7CC; border-color:#F59F00; color:#5b3d00; }
.template-legend .chip-paired::after { content:"\25CF"; margin-left:4px; color: rebeccapurple; }

body.dark-mode .filter-results-list .pill-source { color:#cdefff !important; }
body.dark-mode .filter-results-list .pill-dest { color:#ffd2ea !important; }
body.dark-mode .filter-results-list .pill-selected-only {
  background-color: #5a4b1a !important; /* giallo scurito per dark */
  border-color: #F59F00 !important;
  color:#ffdf8a !important;
}

/* Offcanvas Template (dark mode) */
body.dark-mode #templatePanel .offcanvas-header {
  background-color: #1f2937 !important;
  color: #eaf1f7 !important;
  border-bottom: 1px solid var(--color-border) !important;
}
body.dark-mode #templatePanel .offcanvas-body {
  background-color: #232c33 !important;
  color: var(--color-text) !important;
}
body.dark-mode #templatePanel .list-group-item {
  background-color: #27323a !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}
body.dark-mode #templatePanel .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}
/* Card contenente selettore coppia/tono - scurita in dark */
body.dark-mode #templatePanel .card {
  background-color: #232c33 !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
}
body.dark-mode #templatePanel .card .card-body {
  background-color: #232c33 !important;
  color: var(--color-text) !important;
}

/* Legend chips (dark mode) */
body.dark-mode .template-legend .chip {
  border-color: #6b7280 !important;
  color: #eaf1f7 !important;
}
body.dark-mode .template-legend .chip-source { border-color: var(--e17-cyan) !important; color:#8be7ff !important; }
body.dark-mode .template-legend .chip-dest { border-color: var(--e17-magenta) !important; color:#ffc1e2 !important; }
body.dark-mode .template-legend .chip-selected { background:#5a4b1a !important; border-color:#F59F00 !important; color:#ffdf8a !important; }
body.dark-mode .template-legend .chip-paired::after { color: #b19cd9; }

/* Template panel controls (dark mode) */
body.dark-mode #templatePanel select.form-select,
body.dark-mode #templatePanel input.form-control {
  background-color: #232c33 !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
}
body.dark-mode #templatePanel .form-check-input {
  background-color: #232c33 !important;
  border-color: var(--color-border) !important;
  accent-color: var(--e17-cyan);
}
body.dark-mode #templatePanel .form-check-label { color: var(--color-text) !important; opacity: 1 !important; }
body.dark-mode #templatePanel .btn.btn-primary {
  background-color: var(--e17-magenta) !important;
  border-color: var(--e17-magenta) !important;
  color: #fff !important;
}
/* Chevron chiaro per select in dark mode (tono e altri) */
body.dark-mode #templatePanel select.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23eaf1f7'%3e%3cpath d='M3.204 5h9.592L8 10.481 3.204 5z'/%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right .75rem center !important;
  background-size: 16px 12px !important;
}
/* Target specifico per il selettore tono, per evitare opacità/contrasti errati */
body.dark-mode #templatePanel #templateToneSelect.form-select {
  color: #eaf1f7 !important;
  background-color: #232c33 !important;
  border-color: var(--color-border) !important;
}

/* Accent di modalità per i controlli (light + dark) */
#templatePanel.mode-magenta select.form-select { border-color: var(--e17-magenta) !important; }
#templatePanel.mode-green   select.form-select { border-color: var(--e17-green-soft) !important; }
#templatePanel.mode-cyan    select.form-select { border-color: var(--e17-cyan) !important; }
#templatePanel select.form-select:focus { box-shadow: none !important; }
#templatePanel .btn.btn-primary { background-color: var(--e17-magenta) !important; border-color: var(--e17-magenta) !important; }

/* ===== User Settings Modal: dark mode fix ===== */
body.dark-mode #userSettingsModal .modal-content {
  background-color: #1f2937 !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
}
body.dark-mode #userSettingsModal .modal-header,
body.dark-mode #userSettingsModal .modal-footer {
  background-color: #1f2937 !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}
body.dark-mode #userSettingsModal .modal-body {
  background-color: #232c33 !important;
  color: var(--color-text) !important;
}
body.dark-mode #userSettingsModal .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}
/* Contenitore "I tuoi prompt" (cards generate via JS) */
body.dark-mode #userSettingsModal .card {
  background-color: #27323a !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
}
body.dark-mode #userSettingsModal .card .card-body {
  background-color: #27323a !important;
  color: var(--color-text) !important;
}
/* Input/select all'interno della modale */
body.dark-mode #userSettingsModal .form-control,
body.dark-mode #userSettingsModal .form-select {
  background-color: #232c33 !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
}
/* Bottone outline primary coerente col brand in dark */
body.dark-mode #userSettingsModal .btn-outline-primary {
  color: var(--e17-magenta) !important;
  border-color: var(--e17-magenta) !important;
}
body.dark-mode #userSettingsModal .btn-outline-primary:hover,
body.dark-mode #userSettingsModal .btn-outline-primary:focus {
  background-color: var(--e17-magenta) !important;
  color: #fff !important;
}
/* Testi attenuati leggibili su scuro */
body.dark-mode #userSettingsModal .text-muted,
body.dark-mode #userSettingsModal .form-text.text-muted {
  color: #c3c9d1 !important;
}
/* Status bar (processing) - themable */
.gpt4all-status-bar {
    background: var(--status-bar-bg, #f5f8fb);
    color: var(--status-bar-text, #4a5568);
    border-left: 4px solid var(--composer-accent) !important;
    border-radius: 10px;
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.gpt4all-status-bar .thinking-dots span { color: inherit; }

/* Dark mode overrides */
body.dark-mode .gpt4all-status-bar, .dark-mode .gpt4all-status-bar {
    --status-bar-bg: #2b3740;
    --status-bar-text: #cbd5e1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
/* app/frontend/chat/static/css/chat_style.css */
:root {
    --color-antracite: #314551;
    --color-azzurro: #71cbf4;
    --color-azzurro-light: #a8e0ff;
    --color-azzurro-dark: #4a9fd4;
    --color-background: #f8fafc;
    --color-text: #2d3748;
    --color-text-light: #718096;
    --color-border: #e2e8f0;
    --color-success: #48bb78;
    --color-error: #f56565;
    /* Gradients per modalità */
    --grad-docs: linear-gradient(135deg, rgba(16,185,129,0.10) 0%, rgba(16,185,129,0.04) 100%);
    --grad-chat: linear-gradient(135deg, rgba(190,24,93,0.10) 0%, rgba(190,24,93,0.04) 100%);
    --grad-web:  linear-gradient(135deg, rgba(6,182,212,0.10) 0%, rgba(6,182,212,0.04) 100%);
    /* E17 brand modal colors */
    --e17-magenta: #E71984; /* 231,25,132 */
    --e17-cyan:    #00ACE9; /* 0,172,233 */
    --e17-green:   #83F01A; /* 131,240,26 - verde acido per avatar/decorazioni */
    --e17-green-soft: #5CC31A; /* verde non-acido per dark mode */
    --e17-green-ui: #49A814; /* verde scuro per bottoni tema light (contrasto 4.9:1) */
    /* Composer accent (input + send button) - default RAG */
    --composer-accent: var(--e17-green);
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--color-background);
    padding-top: 60px; /* allineato a navbar 60px */
    font-family: var(--chat-font-family, Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, Noto Sans, sans-serif);
    color: var(--color-text);
}

body.dark-mode {
    --color-background: #232c33;
    --color-antracite: #232c33;
    --color-text: #eaf1f7;
    --color-text-light: #b0bac2;
    --color-border: #3a4a56;
    --color-azzurro: #71cbf4;
    --color-azzurro-dark: #4a9fd4;
    --color-azzurro-light: #a8e0ff;
    --e17-magenta: #E71984;
    --e17-cyan:    #00ACE9;
    --e17-green:   #83F01A;
    --e17-green-soft: #5CC31A;
}

body.dark-mode {
    background-color: var(--color-background);
    color: var(--color-text);
}

body.dark-mode .navbar {
    background-color: var(--color-antracite) !important;
    color: var(--color-text);
}

body.dark-mode .chat-container {
    background-color: #27323a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

body.dark-mode .user-message {
    background-color: #232c33;
    color: var(--color-azzurro);
    border: 1px solid var(--color-border);
    /* border-left gestito dinamicamente da JavaScript per le 3 modalità */
}

body.dark-mode .assistant-message {
    background-color: #232c33;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

body.dark-mode .thought-message,
body.dark-mode .assistant-toc-box {
    background: linear-gradient(135deg, #1a2332 0%, #2a3a46 100%);
    color: var(--color-text-light);
    border-left: 4px solid var(--color-azzurro);
    border: 1px solid #3a4a56;
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.12);
}

body.dark-mode .assistant-toc-box::before {
    opacity: 0.7;
}

body.dark-mode .assistant-toc-box h1, 
body.dark-mode .assistant-toc-box h2, 
body.dark-mode .assistant-toc-box h3 {
    color: #4a9eff;
}

body.dark-mode .assistant-toc-box li::marker {
    color: #4a9eff;
}

body.dark-mode .message-avatar.user-message {
    background: var(--color-azzurro);
    color: #232c33;
}
body.dark-mode .message-avatar.assistant-message {
    background: #314551;
    color: #fff;
}
body.dark-mode .message-avatar.thought-message {
    background: #1b2329;
    color: var(--color-azzurro);
}

body.dark-mode #userInput {
    background: #232c33;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

body.dark-mode #sendBtn {
    background-color: #1976d2;
    color: #fff;
}
body.dark-mode #sendBtn:hover {
    background-color: #1451a3;
}

body.dark-mode .input-group {
    background: #232c33;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

body.dark-mode .show-toc-btn {
    background: linear-gradient(135deg, #232c33 0%, #2a3a46 100%);
    color: #4a9eff;
    border: 2px solid #3a4a56;
}

body.dark-mode .show-toc-btn::before {
    opacity: 0.8;
}

body.dark-mode .show-toc-btn:hover {
    background: linear-gradient(135deg, #2a3a46 0%, #314551 100%);
    color: #6bb6ff;
    border-color: #4a9eff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.2);
}

body.dark-mode .show-toc-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(74, 158, 255, 0.15);
}

body.dark-mode .sources {
    background: #232c33;
    color: var(--color-text-light);
    border-left: 3px solid var(--color-azzurro);
}

/* Dark mode: messaggio nessuna categoria disponibile */
body.dark-mode .no-categories-message {
    background: #27323a !important;
    color: #b0bac2 !important;
    border: 1px solid #3a4a56 !important;
    border-radius: 6px !important;
}

body.dark-mode .time-info {
    color: var(--color-text-light);
}

body.dark-mode .message-action-btn:hover {
    background: #27323a;
    color: var(--color-azzurro);
}

body.dark-mode .navbar .btn-outline-light {
    color: #fff;
    border-color: #b0bac2;
}
body.dark-mode .navbar .btn-outline-light:hover {
    background: #27323a;
    color: var(--color-azzurro);
    border-color: var(--color-azzurro);
}

body.dark-mode footer {
    background: #232c33;
    color: #b0bac2;
}

body.dark-mode footer .text-muted {
    color: #b0bac2 !important;
}

body.dark-mode #userInput::placeholder {
    color: #b0bac2;
    opacity: 1;
}

/* Navbar aligned to 60px like dashboard */
.navbar {
    background-color: var(--color-antracite) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1030;
    height: 60px;       /* fissa a 60px su desktop */
    padding-top: 0;
    padding-bottom: 0;
    display: flex;
    align-items: center; /* centra verticalmente */
}
/* Mobile-specific navbar adjustments */
@media (max-width: 600px) {
  .navbar { height: auto !important; padding: 4px 8px !important; }
  .navbar .ms-auto { flex-wrap: wrap; gap: 6px; }
  .navbar .btn { padding: 4px 8px !important; margin-right: 6px !important; }
  .navbar .btn .nav-text { display: none; }
  .container { margin-top: 72px !important; }
}

.mode-indicators {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 🔍 Stili per le lenti di Deep Search nella navbar */
.mode-indicators #modeLabel {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 1.2em;
    line-height: 1;
}

.mode-indicators .deep-search-lenses {
    display: inline-flex;
    align-items: center;
    margin-left: 3px;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.mode-indicators .deep-search-lenses:hover {
    opacity: 1;
}

.file-indicator {
    font-size: 1.4em !important;
    margin-left: 0.2rem !important;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.file-indicator:hover {
    opacity: 1;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Forza altezza logo come dashboard */
.navbar-brand img {
    max-height: 54px;
    height: 54px;
}

/* Stile bottoni modalità inline (DOCS/CHAT) riusato per WEB */
.mode-toggle-btn-inline {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 8px 0 0 0;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid var(--color-border);
    border-right: none;
    background: var(--color-background);
    color: var(--color-text);
    white-space: nowrap;
    min-width: 60px;
    line-height: 1;
    position: relative;
    vertical-align: middle;
}
#modeToggleBtn.llm-mode,
#modeToggleBtn.web-mode,
#modeToggleBtn { background: transparent !important; box-shadow: none !important; }
.mode-toggle-btn-inline .mode-icon { font-size: 1.6rem; line-height: 1; }
.mode-toggle-btn-inline .mode-text { font-weight: 600; font-size: 0.9rem; }

/* Stato attivo per WEB: evidenziazione chiara anche in dark mode */
#webToggleBtn.active,
body.dark-mode #webToggleBtn.active {
    background: linear-gradient(135deg, var(--color-azzurro-dark) 0%, var(--color-azzurro) 100%);
    color: #0a2030;
    border-color: var(--color-azzurro-light) !important;
    box-shadow: 0 0 0 2px rgba(113,203,244,0.25);
}
#webToggleBtn.active .mode-icon { filter: drop-shadow(0 0 4px rgba(10,32,48,0.25)); }
#webToggleBtn.active .mode-text { color: #0a2030; }

/* Glow animation per evidenziare WEB attivo */
@keyframes webGlow {
  0% { box-shadow: 0 0 8px rgba(113,203,244,0.2); }
  50% { box-shadow: 0 0 16px rgba(113,203,244,0.45); }
  100% { box-shadow: 0 0 8px rgba(113,203,244,0.2); }
}
#webToggleBtn.active { animation: webGlow 1.8s ease-in-out infinite; }

.brand-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: white;
    font-family: 'AutomataDisplay', var(--font-family);
}
/* Forza Automata sulla navbar come in dashboard */
.navbar .brand-text { font-family: 'AutomataDisplay', var(--font-family) !important; letter-spacing: 0.02em; font-weight: 400 !important; }

.logo-ivi {
    color: #1976d2;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    text-shadow: 0 2px 8px #71cbf4;
    font-size: 2.1rem;
}
.logo-dot17 {
    color: #314551;
    font-weight: 400;
    font-size: 2.1rem;
    margin-left: 2px;
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 98vw !important;
    width: 100%;
    padding: 1rem;
}

.chat-container { flex-grow: 1; overflow-y: auto; padding: 1rem; background-color: white; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,.05); max-width: 98vw !important; width: 100%; margin-bottom: 1rem; padding-bottom: 2rem; }

.message {
    margin: 0.75rem 0;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    max-width: 85%;
    width: fit-content;
    min-width: 180px;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,.05);
    animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message { background-color: white; color: #1976d2; margin-left: auto; border-bottom-right-radius: 4px; border: 1px solid var(--color-border); box-shadow: 0 2px 4px rgba(0,0,0,.03); }

.assistant-message { background-color: white; color: var(--color-text); margin-right: auto; border: 1px solid var(--color-border); border-bottom-left-radius: 4px; }

.thought-message {
    background-color: #f8fafc;
    color: var(--color-text);
    margin-right: auto;
    font-style: normal;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-azzurro);
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    font-size: 0.95em;
    line-height: 1.5;
    max-width: 90%;
    box-shadow: 0 2px 4px rgba(0,0,0,.03);
}

.thought-message .thought-content {
    margin-bottom: 10px;
}

.thought-message .placeholder {
    color: #6c757d;
    font-style: italic;
    padding: 8px 0;
}

.thought-message .actual-content {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #dee2e6;
    white-space: pre-wrap;
}

.thought-message.hidden {
    display: none;
}

.cot-message { /* Stile per il placeholder/contenuto CoT */
    background-color: #f0f2f5; 
    color: #4A5568;    
    border-left: 4px solid #7F9CF5; 
    padding: 10px 15px; /* Aumentato un po' il padding */
    font-size: 0.9em;
    margin-left: 25px; 
    margin-right: auto;
    border-radius: 0 8px 8px 0; 
    cursor: default; 
    margin-bottom: 8px;
    /* Non mettere display: none qui; è gestito da JS o dal contenuto placeholder */
}
.cot-message em { /* Per il testo placeholder del CoT */
    color: #718096;
    font-style: italic; /* Assicura che sia corsivo */
}

.assistant-message .sources {
    font-size: 0.85em;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #ced4da;
    color: #495057;
}
.assistant-message .sources strong {
    display: block;
    margin-bottom: 5px;
}
.assistant-message .sources ul,
.assistant-message .sources ol {
    margin: 0.2em 0 0.2em 1.2em !important;
    padding: 0 !important;
}
.assistant-message .sources li {
    margin-bottom: 3px;
    white-space: pre-wrap;
    word-break: break-all;
}
.assistant-message .sources ul li,
.assistant-message .sources ol li {
    margin-bottom: 0.05em !important;
    line-height: 1.2 !important;
    padding: 0 !important;
}

.input-group {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,.05);
    padding: 0.5rem;
    margin-top: 1rem;
}

#userInput {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 1rem;
    resize: none;
    min-height: 40px;
    max-height: 150px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

#userInput:focus {
    border-color: var(--color-azzurro);
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.2);
    outline: none;
}

#sendBtn {
    background-color: #1976d2;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

#sendBtn:hover {
    background-color: #1451a3;
}

.form-check-input:checked {
    background-color: var(--color-azzurro);
    border-color: var(--color-azzurro);
}

.btn-outline-light {
    border-color: rgba(255,255,255,0.5);
    color: white;
}

/* System messages */
.system-message {
    background-color: #e3f2fd;
    color: #1976d2;
    margin: 0.5rem auto;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #1976d2;
    max-width: 90%;
    font-size: 0.95em;
    line-height: 1.5;
}

.system-message .message-content {
    margin: 0;
}

.system-message strong {
    display: block;
    margin-bottom: 0.25rem;
}

.system-message em {
    color: #666;
    font-style: italic;
}

.btn-outline-light:hover {
    background-color: rgba(255,255,255,0.1);
    border-color: white;
    color: white;
}

.time-info {
    font-size: 0.8em;
    color: var(--color-text-light);
    margin: 0.25rem 0 1rem 0;
    padding-left: 1rem;
}

.message-actions {
    display: flex;
    gap: 0.5rem;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    color: var(--color-text-light);
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.message-action-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--color-azzurro);
}

/* Dark mode: sezione "Documenti dalle fonti consultate" */
body.dark-mode #sourceDocumentsSection {
    background: #27323a !important;
    border-color: var(--color-border) !important;
    color: var(--color-text) !important;
}
body.dark-mode #sourceDocumentsSection strong {
    color: var(--color-text) !important;
}

/* Avatar: rimuovi sfondo circolare scuro in tutte le modalità */
.message-avatar,
.message-avatar.user-message,
.message-avatar.assistant-message,
.message-avatar.thought-message {
    background: transparent !important;
    box-shadow: none !important;
}
.message-avatar .avatar-circle {
    background: transparent !important;
    box-shadow: none !important;
}

/* User avatar image */
.msg-avatar { 
    width: 20px; 
    height: 20px; 
    border-radius: 50%; 
    object-fit: cover; 
    display: inline-block; 
    padding: 2px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
.nav-user-avatar { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; display: inline-block; padding: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
body.dark-mode .message-avatar .msg-avatar { box-shadow: 0 0 0 1px rgba(255,255,255,.85); }
body.dark-mode .nav-user-avatar { box-shadow: 0 0 0 1px rgba(255,255,255,.85); }

/* Avatar picker grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    max-height: 120px;
    overflow-y: auto;
    padding: 4px 2px;
}
@media (max-width: 575.98px) {
    .avatar-grid { grid-template-columns: repeat(5, 1fr); }
}
.avatar-item {
    width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    border: 2px solid transparent; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.avatar-item.selected { border-color: var(--color-azzurro, #71cbf4); box-shadow: 0 0 0 2px rgba(113,203,244,.25); }
.avatar-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thinking-indicator-after-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    /* border-left gestito dinamicamente da JavaScript per le 3 modalità */
    border-radius: 8px;
    color: var(--color-azzurro);
    font-size: 0.95em;
    font-style: italic;
    box-shadow: 0 2px 4px rgba(0,0,0,.03);
}

/* === Composer Accent Overrides (ensure persistent color) === */
.input-section #sendBtn {
    background-color: var(--composer-accent) !important;
    border-color: var(--composer-accent) !important;
}
.input-section #sendBtn:hover,
.input-section #sendBtn:focus,
.input-section #sendBtn:active {
    background-color: var(--composer-accent) !important;
    border-color: var(--composer-accent) !important;
    filter: brightness(0.95);
}
body.dark-mode .input-section #sendBtn,
body.dark-mode .input-section #sendBtn:hover,
body.dark-mode .input-section #sendBtn:focus,
body.dark-mode .input-section #sendBtn:active {
    background-color: var(--composer-accent) !important;
    border-color: var(--composer-accent) !important;
}

/* RAG (mode-docs): verde meno "acido" SOLO per il bottone */
.mode-docs .input-section #sendBtn {
    background-color: #5CC31A !important; /* base */
    border-color: #5CC31A !important;
}
.mode-docs .input-section #sendBtn:hover {
    background-color: #49A814 !important; /* hover */
    border-color: #49A814 !important;
}
.mode-docs .input-section #sendBtn:active {
    background-color: #3E9311 !important; /* active */
    border-color: #3E9311 !important;
}
.mode-docs .input-section #sendBtn:focus {
    box-shadow: 0 0 0 0.2rem rgba(92,195,26,0.30) !important; /* focus ring */
}

/* Dark mode: stesso verde meno "acido" solo per bottone in RAG */
body.dark-mode.mode-docs .input-section #sendBtn {
    background-color: #5CC31A !important;
    border-color: #5CC31A !important;
}
body.dark-mode.mode-docs .input-section #sendBtn:hover {
    background-color: #49A814 !important;
    border-color: #49A814 !important;
}
body.dark-mode.mode-docs .input-section #sendBtn:active {
    background-color: #3E9311 !important;
    border-color: #3E9311 !important;
}
body.dark-mode.mode-docs .input-section #sendBtn:focus {
    box-shadow: 0 0 0 0.2rem rgba(92,195,26,0.30) !important;
}

/* Dark mode override per indicatore di elaborazione */
body.dark-mode .thinking-indicator-after-user, .dark-mode .thinking-indicator-after-user {
    background: #2b3740;
    color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0,0,0,.4);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-azzurro-light);
    border-top-color: var(--color-azzurro);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.assistant-toc-box {
    background: linear-gradient(135deg, #f8fbff 0%, #f0f7ff 100%);
    border: 1px solid #e1ecf7;
    border-left: 4px solid var(--composer-accent);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    font-size: 0.95em;
    color: var(--color-text);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.08);
    position: relative;
    overflow: hidden;
}

.assistant-toc-box::before {
    content: "🤔";
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.2em;
    opacity: 0.6;
}

.assistant-toc-box h1, .assistant-toc-box h2, .assistant-toc-box h3 {
    color: var(--color-azzurro);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.assistant-toc-box p {
    margin-bottom: 0.8rem;
}

.assistant-toc-box ul, .assistant-toc-box ol {
    margin-left: 1rem;
    margin-bottom: 0.8rem;
}

.assistant-toc-box li {
    margin-bottom: 0.4rem;
    position: relative;
}

.assistant-toc-box li::marker {
    color: var(--color-azzurro);
}

.show-toc-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    color: var(--color-azzurro);
    border: 2px solid var(--color-azzurro-light);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.show-toc-btn::before {
    content: "🧠";
    font-size: 1.1em;
}

.show-toc-btn:hover {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f3ff 100%);
    color: var(--color-azzurro-dark);
    border-color: var(--color-azzurro);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.show-toc-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.1);
}

.sources {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-left: 3px solid var(--color-azzurro);
    border-radius: 8px;
    font-size: 0.9em;
    color: var(--color-text-light);
}

.sources strong {
    color: var(--color-text);
    display: block;
    margin-bottom: 0.5rem;
}

.sources ul {
    margin: 0;
    padding-left: 1.25rem;
}

.sources li {
    margin: 0.25rem 0;
}

/* Stili per le citazioni migliorate */
.source-citation {
    display: inline-block;
    font-weight: 500;
    color: var(--color-azzurro-dark);
    cursor: help;
    transition: all 0.2s ease;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    background: rgba(0, 123, 255, 0.05);
    border: 1px solid rgba(0, 123, 255, 0.1);
}

.source-citation:hover {
    background: rgba(0, 123, 255, 0.1);
    border-color: rgba(0, 123, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

/* Dark mode per le citazioni */
body.dark-mode .source-citation {
    color: #4dabf7;
    background: rgba(77, 171, 247, 0.1);
    border-color: rgba(77, 171, 247, 0.2);
}

body.dark-mode .source-citation:hover {
    background: rgba(77, 171, 247, 0.15);
    border-color: rgba(77, 171, 247, 0.3);
    box-shadow: 0 2px 4px rgba(77, 171, 247, 0.15);
}

/* Stili specifici per i link ai documenti */
.source-citation a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.source-citation a:hover {
    color: inherit;
    text-decoration: none;
}

.source-citation a:focus {
    outline: 2px solid var(--color-azzurro);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Miglioramento accessibilità per i link ai documenti */
.source-citation a[href]:hover {
    transform: scale(1.02);
}

.source-citation a[href]:active {
    transform: scale(0.98);
}

body.dark-mode .source-citation a:focus {
    outline-color: #4dabf7;
}

@media (max-width: 600px) {
    body {
        min-height: auto !important;
        height: auto !important;
        padding-top: 56px !important;
        overflow-y: auto !important;
    }
    .container, .chat-container {
        padding: 0.5rem;
    }
    .message {
        max-width: 98vw !important;
        padding: 0.5rem 0.7rem;
        font-size: 0.98em;
    }
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
        margin-right: 7px;
    }
    .input-group {
        width: 100%;
        box-sizing: border-box;
    }
    #userInput {
        font-size: 1.1em;
        min-height: 80px;
        padding: 0.7rem;
        width: 100%;
        box-sizing: border-box;
        display: block;
    }
    #sendBtn {
        font-size: 1.1em;
        padding: 0.7rem 1.2rem;
        width: 100%;
        margin-top: 0.3rem;
    }
    .navbar .btn, .navbar .btn-outline-light {
        font-size: 1.2em;
        padding: 0.4rem 0.7rem;
    }
    .navbar .nav-icon {
        display: inline !important;
    }
    .navbar .nav-text,
    .navbar .btn span:not(.nav-icon),
    .navbar .btn-outline-light span:not(.nav-icon) {
        display: none !important;
    }
    #modeLabel {
        font-size: 1.6em;
        padding: 0 0.2em;
        min-width: 2.5em;
        text-align: center;
    }
    
    .file-indicator {
        font-size: 1.4em !important;
        margin-left: 0.2rem !important;
    }
    
    .deep-search-indicator {
        font-size: 1.4em !important;
        margin-left: 0.3rem !important;
        color: #71cbf4 !important;
    }
    .brand-text, .ivi-blu, .ivi-antracite {
        font-size: 1.2rem !important;
    }
    .chat-container {
        min-height: 300px;
        max-height: calc(100vh - 220px);
        overflow-y: auto;
        padding-top: 2.5rem !important;
    }
    .chat-container .message:first-child {
        margin-top: 0.5rem !important;
    }
    
    /* Fix dropdown overlap su mobile */
    .saved-conversations {
        width: 280px !important;
        right: -10px !important;
    }
}

/* === DIMENSIONI INTERMEDIE (601px - 900px) === */
@media (min-width: 601px) and (max-width: 900px) {
    /* Fix critico: Evita che il dropdown si sovrapponga al bottone "Nuova Chat" */
    .saved-conversations {
        right: 60px !important; /* Sposta il dropdown a sinistra del bottone */
        width: 300px !important;
        max-width: calc(100vw - 120px) !important;
    }
    
    /* Assicura che i bottoni navbar siano sempre cliccabili */
    .navbar .btn, .navbar .btn-outline-light {
        position: relative;
        z-index: 1100 !important; /* Sopra i dropdown */
        pointer-events: auto !important;
    }
    
    /* Riduce leggermente la dimensione dei bottoni per evitare sovrapposizioni */
    .navbar .btn, .navbar .btn-outline-light {
        padding: 0.375rem 0.6rem;
        font-size: 0.9rem;
    }
    
    /* Nasconde il testo sui bottoni se lo spazio è limitato */
    .navbar .nav-text {
        display: none;
    }
    
    .navbar .nav-icon {
        display: inline !important;
    }
}

/* === DIMENSIONI MEDIE (901px - 1200px) === */
@media (min-width: 901px) and (max-width: 1200px) {
    /* Ripristina il testo sui bottoni */
    .navbar .nav-text {
        display: inline;
    }
    
    /* Assicura posizionamento corretto del dropdown */
    .saved-conversations {
        right: 0 !important;
        width: 320px !important;
    }
}

@media (max-width: 400px) {
    .message {
        font-size: 0.93em;
        padding: 0.3rem 0.4rem;
    }
    .message-avatar {
        width: 22px;
        height: 22px;
        font-size: 0.9rem;
        margin-right: 4px;
    }
    #userInput {
        font-size: 1em;
        min-height: 40px;
        padding: 0.5rem;
    }
    #sendBtn {
        font-size: 1em;
        padding: 0.5rem 0.7rem;
    }
    .brand-text, .ivi-blu, .ivi-antracite {
        font-size: 1rem !important;
    }
}

.form-check-label {
    cursor: pointer;
}

.message + .time-info { 
    margin-top: -10px; 
    margin-bottom: 15px;
    padding-left: 20px; 
}

/* Stili per il markdown */
.message pre {
    background-color: #f8f9fa;
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.8em 0;
    border: 1px solid #dee2e6;
}

/* Dark mode: migliora visibilità blocchi pre e code (citazioni lunghe spesso renderizzate come pre) */
body.dark-mode .message pre {
    background-color: #27323a !important;
    color: var(--color-text) !important;
    border: 1px solid var(--color-border) !important;
}
body.dark-mode .message code {
    background-color: #27323a !important;
    color: var(--color-text) !important;
}

.message code {
    background-color: #f8f9fa;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
}

.message pre code {
    background-color: transparent;
    padding: 0;
    border: none;
}

.message ul, .message ol {
    padding-left: 1.5em;
    margin: 0.8em 0;
}

.message li {
    margin: 0.4em 0;
    line-height: 1.5;
}

.message h1, .message h2, .message h3 {
    margin: 1em 0 0.5em 0;
    line-height: 1.3;
}

.message h1 {
    font-size: 1.5em;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.3em;
}

.message h2 {
    font-size: 1.3em;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.2em;
}

.message h3 {
    font-size: 1.1em;
}

.message p {
    margin: 0.8em 0;
    line-height: 1.5;
}

.message blockquote {
    border-left: 4px solid #dee2e6;
    margin: 0.8em 0;
    padding: 0.5em 0 0.5em 1em;
    color: #6c757d;
}

/* Dark mode: migliora visibilità delle citazioni */
body.dark-mode .message blockquote {
    border-left: 4px solid var(--color-azzurro);
    background: #27323a;
    color: var(--color-text);
}
body.dark-mode .message blockquote em {
    color: var(--color-text);
}

.message table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.message th, .message td {
    border: 1px solid #dee2e6;
    padding: 0.5em;
    text-align: left;
}

.message th {
    background-color: #f8f9fa;
}
/* Dark mode: header tabella scuro e testo chiaro, come File Utente */
body.dark-mode .message table { color: #e5e7eb; }
body.dark-mode .message thead th { color: #e5e7eb; border-color: #374151; background-color: #111827; font-weight: 600; }
body.dark-mode .message tbody td, 
body.dark-mode .message tbody th { border-color: #374151; }
body.dark-mode .message table { --bs-table-bg: #0f172a; --bs-table-border-color: #374151; }
body.dark-mode .message tbody tr>td,
body.dark-mode .message tbody tr>th { background-color: var(--bs-table-bg) !important; }

/* Stili per il bottone Mostra/Nascondi Pensieri */
#toggleCotButton {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
    margin: 10px 0;
}

#toggleCotButton:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

#toggleCotButton:active {
    transform: translateY(0);
}

/* Stili per le fonti */
.sources {
    margin-top: 1em;
    padding: 0.5em 1em;
    background: #f8f9fa;
    border-left: 3px solid #007bff;
    font-size: 0.95em;
}

.sources ul {
    margin: 0.2em 0 0 1.2em;
    padding: 0;
}

.sources li {
    list-style: disc;
}

.toggle-cot-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
    margin-top: 8px;
    display: inline-block;
}

.toggle-cot-btn:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle-cot-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.blinking-cursor {
    display: inline-block;
    width: 1ch;
    animation: blink-cursor 1s steps(1) infinite;
    color: #007bff;
    font-weight: bold;
}
@keyframes blink-cursor {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.thinking-dots {
    display: inline-block;
    font-size: 1.5em;
    letter-spacing: 2px;
    vertical-align: middle;
}
.thinking-dots span {
    opacity: 0.2;
    animation: thinking-blink 1.2s infinite;
    margin-right: 2px;
}
.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes thinking-blink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}



.text-primary { color: #009cff; font-weight: bold; }

body.dark-mode .thought-bubble {
    background: #1b2329;
    color: #b0bac2;
    border: 1.5px solid #314551;
}

.thought-bubble {
  background: #f7fafd;
  border: 1.5px solid #b6d4fa;
  border-radius: 22px;
  padding: 18px 24px 14px 24px;
  margin: 16px 0 10px 0;
  max-width: 98vw;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  color: #26344a;
  font-size: 1.08em;
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  line-height: 1.6;
}
.thought-bubble-label {
  font-size: 1em;
  color: #4a90e2;
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
  letter-spacing: 0.01em;
  opacity: 0.85;
}
.thought-bubble .thinking-dots {
  margin-left: 10px;
  vertical-align: middle;
}
.thought-bubble .thinking-dots span {
  font-size: 1.15em;
}

@media (max-width: 600px) {
  .container, .chat-container, .message, .thought-bubble {
    max-width: 100vw !important;
    padding-left: 6px;
    padding-right: 6px;
  }
}

.message-actions {
  display: flex;
  gap: 8px;
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 2;
}
.message:hover .message-actions {
  visibility: visible;
  opacity: 1;
}
.message .message-actions {
  visibility: hidden;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.message-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1em;
  color: #6c757d;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}
.message-action-btn:hover {
  background: #e9ecef;
  color: #007bff;
}
.copied-feedback {
  display: inline-block;
  margin-left: 6px;
  color: #009c47;
  font-size: 0.95em;
  font-weight: 500;
  opacity: 0.85;
  animation: fadeOut 1.2s forwards;
}
@keyframes fadeOut {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
@media (max-width: 600px) {
  .message .message-actions {
    visibility: visible;
    opacity: 1;
    position: static;
    margin-top: 4px;
    justify-content: flex-end;
  }
}

.reasoning-inline-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.97em;
  color: #4a4a4a;
  background: none;
  border: none;
  margin: 2px 0 2px 8px;
  padding: 0;
}
.reasoning-inline-time {
  color: #4a90e2;
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}
.reasoning-inline-link {
  color: #007bff;
  background: none;
  border: none;
  font-size: 0.97em;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 8px;
  padding: 0 2px;
  transition: color 0.2s;
}
.reasoning-inline-link:hover {
  color: #0056b3;
}
.reasoning-inline-cot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.97em;
  color: #4a4a4a;
  background: none;
  border: none;
  margin: 2px 0 2px 8px;
  padding: 0;
  word-break: break-word;
}
.reasoning-inline-close {
  background: none;
  border: none;
  color: #6c757d;
  font-size: 1.1em;
  cursor: pointer;
  margin-left: 6px;
  padding: 0 2px;
  border-radius: 3px;
  transition: background 0.2s;
}
.reasoning-inline-close:hover {
  background: #e9ecef;
  color: #007bff;
}

.assistant-toc-box {
    background: linear-gradient(135deg, #f8fbff 0%, #f0f7ff 100%);
    border: 1px solid #e1ecf7;
    border-left: 4px solid var(--color-azzurro);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    font-size: 0.95em;
    color: var(--color-text);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.08);
    position: relative;
    overflow: hidden;
}

.assistant-toc-box::before {
    content: "🤔";
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.2em;
    opacity: 0.6;
}

.assistant-toc-box h1, .assistant-toc-box h2, .assistant-toc-box h3 {
    color: var(--color-azzurro);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.assistant-toc-box p {
    margin-bottom: 0.8rem;
}

.assistant-toc-box ul, .assistant-toc-box ol {
    margin-left: 1rem;
    margin-bottom: 0.8rem;
}

.assistant-toc-box li {
    margin-bottom: 0.4rem;
    position: relative;
}

.assistant-toc-box li::marker {
    color: var(--color-azzurro);
}

.show-toc-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    color: var(--color-azzurro);
    border: 2px solid var(--color-azzurro-light);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.show-toc-btn::before {
    content: "🧠";
    font-size: 1.1em;
}

.show-toc-btn:hover {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f3ff 100%);
    color: var(--color-azzurro-dark);
    border-color: var(--color-azzurro);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.show-toc-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.1);
}

.sources {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-left: 3px solid var(--color-azzurro);
    border-radius: 8px;
    font-size: 0.9em;
    color: var(--color-text-light);
}

.sources strong {
    color: var(--color-text);
    display: block;
    margin-bottom: 0.5rem;
}

.sources ul {
    margin: 0;
    padding-left: 1.25rem;
}

.sources li {
    margin: 0.25rem 0;
}

/* Stili per le citazioni migliorate */
.source-citation {
    display: inline-block;
    font-weight: 500;
    color: var(--color-azzurro-dark);
    cursor: help;
    transition: all 0.2s ease;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    background: rgba(0, 123, 255, 0.05);
    border: 1px solid rgba(0, 123, 255, 0.1);
}

.source-citation:hover {
    background: rgba(0, 123, 255, 0.1);
    border-color: rgba(0, 123, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

/* Dark mode per le citazioni */
body.dark-mode .source-citation {
    color: #4dabf7;
    background: rgba(77, 171, 247, 0.1);
    border-color: rgba(77, 171, 247, 0.2);
}

body.dark-mode .source-citation:hover {
    background: rgba(77, 171, 247, 0.15);
    border-color: rgba(77, 171, 247, 0.3);
    box-shadow: 0 2px 4px rgba(77, 171, 247, 0.15);
}

/* Stili specifici per i link ai documenti */
.source-citation a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.source-citation a:hover {
    color: inherit;
    text-decoration: none;
}

.source-citation a:focus {
    outline: 2px solid var(--color-azzurro);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Miglioramento accessibilità per i link ai documenti */
.source-citation a[href]:hover {
    transform: scale(1.02);
}

.source-citation a[href]:active {
    transform: scale(0.98);
}

body.dark-mode .source-citation a:focus {
    outline-color: #4dabf7;
}

@media (max-width: 600px) {
    body {
        min-height: auto !important;
        height: auto !important;
        padding-top: 56px !important;
        overflow-y: auto !important;
    }
    .container, .chat-container {
        padding: 0.5rem;
    }
    .message {
        max-width: 98vw !important;
        padding: 0.5rem 0.7rem;
        font-size: 0.98em;
    }
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
        margin-right: 7px;
    }
    .input-group {
        width: 100%;
        box-sizing: border-box;
    }
    #userInput {
        font-size: 1.1em;
        min-height: 80px;
        padding: 0.7rem;
        width: 100%;
        box-sizing: border-box;
        display: block;
    }
    #sendBtn {
        font-size: 1.1em;
        padding: 0.7rem 1.2rem;
        width: 100%;
        margin-top: 0.3rem;
    }
    .navbar .btn, .navbar .btn-outline-light {
        font-size: 1.2em;
        padding: 0.4rem 0.7rem;
    }
    .navbar .nav-icon {
        display: inline !important;
    }
    .navbar .nav-text,
    .navbar .btn span:not(.nav-icon),
    .navbar .btn-outline-light span:not(.nav-icon) {
        display: none !important;
    }
    #modeLabel {
        font-size: 1.6em;
        padding: 0 0.2em;
        min-width: 2.5em;
        text-align: center;
    }
    
    .file-indicator {
        font-size: 1.4em !important;
        margin-left: 0.2rem !important;
    }
    
    .deep-search-indicator {
        font-size: 1.4em !important;
        margin-left: 0.3rem !important;
        color: #71cbf4 !important;
    }
    .brand-text, .ivi-blu, .ivi-antracite {
        font-size: 1.2rem !important;
    }
    .chat-container {
        min-height: 300px;
        max-height: calc(100vh - 220px);
        overflow-y: auto;
        padding-top: 2.5rem !important;
    }
    .chat-container .message:first-child {
        margin-top: 0.5rem !important;
    }
    
    /* Fix dropdown overlap su mobile */
    .saved-conversations {
        width: 280px !important;
        right: -10px !important;
    }
}

/* === DIMENSIONI INTERMEDIE (601px - 900px) === */
@media (min-width: 601px) and (max-width: 900px) {
    /* Fix critico: Evita che il dropdown si sovrapponga al bottone "Nuova Chat" */
    .saved-conversations {
        right: 60px !important; /* Sposta il dropdown a sinistra del bottone */
        width: 300px !important;
        max-width: calc(100vw - 120px) !important;
    }
    
    /* Assicura che i bottoni navbar siano sempre cliccabili */
    .navbar .btn, .navbar .btn-outline-light {
        position: relative;
        z-index: 1100 !important; /* Sopra i dropdown */
        pointer-events: auto !important;
    }
    
    /* Riduce leggermente la dimensione dei bottoni per evitare sovrapposizioni */
    .navbar .btn, .navbar .btn-outline-light {
        padding: 0.375rem 0.6rem;
        font-size: 0.9rem;
    }
    
    /* Nasconde il testo sui bottoni se lo spazio è limitato */
    .navbar .nav-text {
        display: none;
    }
    
    .navbar .nav-icon {
        display: inline !important;
    }
}

/* === DIMENSIONI MEDIE (901px - 1200px) === */
@media (min-width: 901px) and (max-width: 1200px) {
    /* Ripristina il testo sui bottoni */
    .navbar .nav-text {
        display: inline;
    }
    
    /* Assicura posizionamento corretto del dropdown */
    .saved-conversations {
        right: 0 !important;
        width: 320px !important;
    }
}

@media (max-width: 400px) {
    .message {
        font-size: 0.93em;
        padding: 0.3rem 0.4rem;
    }
    .message-avatar {
        width: 22px;
        height: 22px;
        font-size: 0.9rem;
        margin-right: 4px;
    }
    #userInput {
        font-size: 1em;
        min-height: 40px;
        padding: 0.5rem;
    }
    #sendBtn {
        font-size: 1em;
        padding: 0.5rem 0.7rem;
    }
    .brand-text, .ivi-blu, .ivi-antracite {
        font-size: 1rem !important;
    }
}

.form-check-label {
    cursor: pointer;
}

.message + .time-info { 
    margin-top: -10px; 
    margin-bottom: 15px;
    padding-left: 20px; 
}

/* Stili per il markdown */
.message pre {
    background-color: #f8f9fa;
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.8em 0;
    border: 1px solid #dee2e6;
}

.message code {
    background-color: #f8f9fa;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
}

.message pre code {
    background-color: transparent;
    padding: 0;
    border: none;
}

.message ul, .message ol {
    padding-left: 1.5em;
    margin: 0.8em 0;
}

.message li {
    margin: 0.4em 0;
    line-height: 1.5;
}

.message h1, .message h2, .message h3 {
    margin: 1em 0 0.5em 0;
    line-height: 1.3;
}

.message h1 {
    font-size: 1.5em;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.3em;
}

.message h2 {
    font-size: 1.3em;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.2em;
}

.message h3 {
    font-size: 1.1em;
}

.message p {
    margin: 0.8em 0;
    line-height: 1.5;
}

.message blockquote {
    border-left: 4px solid #dee2e6;
    margin: 0.8em 0;
    padding: 0.5em 0 0.5em 1em;
    color: #6c757d;
}

.message table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.message th, .message td {
    border: 1px solid #dee2e6;
    padding: 0.5em;
    text-align: left;
}

.message th {
    background-color: #f8f9fa;
}

/* Stili per il bottone Mostra/Nascondi Pensieri */
#toggleCotButton {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
    margin: 10px 0;
}

#toggleCotButton:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

#toggleCotButton:active {
    transform: translateY(0);
}

/* Stili per le fonti */
.sources {
    margin-top: 1em;
    padding: 0.5em 1em;
    background: #f8f9fa;
    border-left: 3px solid #007bff;
    font-size: 0.95em;
}

.sources ul {
    margin: 0.2em 0 0 1.2em;
    padding: 0;
}

.sources li {
    list-style: disc;
}

.toggle-cot-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
    margin-top: 8px;
    display: inline-block;
}

.toggle-cot-btn:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle-cot-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.blinking-cursor {
    display: inline-block;
    width: 1ch;
    animation: blink-cursor 1s steps(1) infinite;
    color: #007bff;
    font-weight: bold;
}
@keyframes blink-cursor {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.thinking-dots {
    display: inline-block;
    font-size: 1.5em;
    letter-spacing: 2px;
    vertical-align: middle;
}
.thinking-dots span {
    opacity: 0.2;
    animation: thinking-blink 1.2s infinite;
    margin-right: 2px;
}
.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes thinking-blink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}



.text-primary { color: #009cff; font-weight: bold; }

body.dark-mode .thought-bubble {
    background: #1b2329;
    color: #b0bac2;
    border: 1.5px solid #314551;
}

.thought-bubble {
  background: #f7fafd;
  border: 1.5px solid #b6d4fa;
  border-radius: 22px;
  padding: 18px 24px 14px 24px;
  margin: 16px 0 10px 0;
  max-width: 98vw;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  color: #26344a;
  font-size: 1.08em;
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  line-height: 1.6;
}
.thought-bubble-label {
  font-size: 1em;
  color: #4a90e2;
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
  letter-spacing: 0.01em;
  opacity: 0.85;
}
.thought-bubble .thinking-dots {
  margin-left: 10px;
  vertical-align: middle;
}
.thought-bubble .thinking-dots span {
  font-size: 1.15em;
}

@media (max-width: 600px) {
  .container, .chat-container, .message, .thought-bubble {
    max-width: 100vw !important;
    padding-left: 6px;
    padding-right: 6px;
  }
}

.message-actions {
  display: flex;
  gap: 8px;
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 2;
}
.message:hover .message-actions {
  visibility: visible;
  opacity: 1;
}
.message .message-actions {
  visibility: hidden;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.message-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1em;
  color: #6c757d;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}
.message-action-btn:hover {
  background: #e9ecef;
  color: #007bff;
}
.copied-feedback {
  display: inline-block;
  margin-left: 6px;
  color: #009c47;
  font-size: 0.95em;
  font-weight: 500;
  opacity: 0.85;
  animation: fadeOut 1.2s forwards;
}
@keyframes fadeOut {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
@media (max-width: 600px) {
  .message .message-actions {
    visibility: visible;
    opacity: 1;
    position: static;
    margin-top: 4px;
    justify-content: flex-end;
  }
}

.reasoning-inline-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.97em;
  color: #4a4a4a;
  background: none;
  border: none;
  margin: 2px 0 2px 8px;
  padding: 0;
}
.reasoning-inline-time {
  color: #4a90e2;
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}
.reasoning-inline-link {
  color: #007bff;
  background: none;
  border: none;
  font-size: 0.97em;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 8px;
  padding: 0 2px;
  transition: color 0.2s;
}
.reasoning-inline-link:hover {
  color: #0056b3;
}
.reasoning-inline-cot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.97em;
  color: #4a4a4a;
  background: none;
  border: none;
  margin: 2px 0 2px 8px;
  padding: 0;
  word-break: break-word;
}
.reasoning-inline-close {
  background: none;
  border: none;
  color: #6c757d;
  font-size: 1.1em;
  cursor: pointer;
  margin-left: 6px;
  padding: 0 2px;
  border-radius: 3px;
  transition: background 0.2s;
}
.reasoning-inline-close:hover {
  background: #e9ecef;
  color: #007bff;
}

.assistant-toc-box {
    background: linear-gradient(135deg, #f8fbff 0%, #f0f7ff 100%);
    border: 1px solid #e1ecf7;
    border-left: 4px solid var(--color-azzurro);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    font-size: 0.95em;
    color: var(--color-text);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.08);
    position: relative;
    overflow: hidden;
}

.assistant-toc-box::before {
    content: "🤔";
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.2em;
    opacity: 0.6;
}

.assistant-toc-box h1, .assistant-toc-box h2, .assistant-toc-box h3 {
    color: var(--color-azzurro);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.assistant-toc-box p {
    margin-bottom: 0.8rem;
}

.assistant-toc-box ul, .assistant-toc-box ol {
    margin-left: 1rem;
    margin-bottom: 0.8rem;
}

.assistant-toc-box li {
    margin-bottom: 0.4rem;
    position: relative;
}

.assistant-toc-box li::marker {
    color: var(--color-azzurro);
}

.show-toc-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    color: var(--color-azzurro);
    border: 2px solid var(--color-azzurro-light);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.show-toc-btn::before {
    content: "🧠";
    font-size: 1.1em;
}

.show-toc-btn:hover {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f3ff 100%);
    color: var(--color-azzurro-dark);
    border-color: var(--color-azzurro);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.show-toc-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.1);
}

.assistant-message ul,
.assistant-message ol {
    margin-top: 0.8em !important;
    margin-bottom: 0.8em !important;
    padding-left: 1.7em !important;
    list-style-position: inside !important;
}
.assistant-message ul li,
.assistant-message ol li {
    margin-bottom: 0.2em !important;
    line-height: 1.4 !important;
    padding: 0 !important;
}

/* Cursore retrò stile WarGames */
.retro-cursor {
  display: inline-block;
  width: 1ch;
  font-size: 2.2em;
  color: #00ff00;
  background: #111;
  font-family: 'Consolas', 'Courier New', monospace;
  font-weight: bold;
  animation: retro-blink 0.7s steps(1) infinite;
  vertical-align: middle;
  border-radius: 2px;
  box-shadow: 0 0 8px #00ff00;
}
@keyframes retro-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Spinner a pallini animati per risposta in arrivo */
.spinner-dots {
  display: inline-block;
  width: 32px;
  text-align: center;
  vertical-align: middle;
}
.spinner-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 2px;
  background: #00b894;
  border-radius: 50%;
  animation: spinner-dots-bounce 1.2s infinite both;
}
.spinner-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.spinner-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes spinner-dots-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

.matrix2-spinner {
  /* Nessun effetto: underscore normale */
}

.ivi-blu {
    color: #71cbf4;
    font-weight: 600;
    font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
    font-size: 2rem;
}
.ivi-antracite {
    color: #fff;
    font-weight: 600;
    font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
    font-size: 2rem;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: #e3f2fd;
    margin-right: 12px;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(25, 118, 210, 0.08);
}
.user-message .message-avatar {
    background: #71cbf4;
    color: #fff;
}
.assistant-message .message-avatar {
    background: #314551;
    color: #fff;
}

/* Allineamento icona assistente rispetto al testo */
.assistant-message .msg-fav { position: relative; top: 2px; }

.message-content-wrapper {
    display: flex;
    align-items: flex-start;
}

/* Copyright styling */
.assistant-message .message-content {
    position: relative;
}

.assistant-message .message-content::after {
    content: attr(data-copyright);
    display: block;
    font-size: 0.8em;
    color: var(--color-text-light);
    margin-top: 0.5em;
    text-align: right;
}

body.dark-mode .assistant-message .message-content::after {
    color: var(--color-text-light);
}

body.dark-mode .text-muted {
    color: #b0bac2 !important;
}

.deep-research-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    padding: 0.75rem 1rem;
    background: #faf1f1;
    border-left: 4px solid #314551;
    border-radius: 8px;
    color: #314551;
    font-size: 1em;
    font-style: italic;
    box-shadow: 0 2px 4px rgba(49, 69, 81, 0.15);
}

.deep-research-bar .thinking-dots {
    margin-left: 0.5em;
}

.deep-research-bar .deep-research-inline-time {
    margin-left: 0.7em;
    font-size: 0.95em;
    color: #314551;
    font-style: normal;
}

/* === MODALITÀ COMPATTA === */
body.compact-mode .message {
    margin-bottom: 0.2rem !important;
    padding: 0.4rem !important;
    font-size: 0.9em;
    line-height: 1.3;
}

body.compact-mode .message-avatar {
    width: 24px !important;
    height: 24px !important;
    font-size: 0.7rem !important;
}

body.compact-mode .message-content {
    padding: 0.3rem 0 !important;
}

body.compact-mode .show-toc-btn {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.75rem !important;
    margin: 0.25rem 0 !important;
}

body.compact-mode .assistant-toc-box {
    padding: 0.5rem !important;
    font-size: 0.85em !important;
}

body.compact-mode .chat-container {
    padding: 0.3rem !important;
}

body.compact-mode .input-group {
    margin-bottom: 0.2rem !important;
}

body.compact-mode #userInput {
    padding: 0.4rem !important;
    min-height: 32px !important;
    font-size: 0.9em !important;
}

body.compact-mode .navbar {
    padding: 0.1rem 0.5rem !important;
}

body.compact-mode .navbar .btn {
    padding: 0.15rem 0.3rem !important;
    font-size: 0.7rem !important;
    margin: 0 0.1rem !important;
}

body.compact-mode .brand-text {
    font-size: 0.8rem !important;
}

body.compact-mode .container {
    padding: 0.5rem !important;
}

/* Compact mode indicator */
body.compact-mode::before {
    content: "📐 Modalità Compatta";
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-azzurro);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.7rem;
    z-index: 1001;
    animation: compactModeIndicator 3s ease-in-out;
}

@keyframes compactModeIndicator {
    0%, 80% { opacity: 1; }
    100% { opacity: 0; }
}

/* === STREAMING REASONING BOX === */
.reasoning-streaming-box {
    background: linear-gradient(135deg, #f8fbff 0%, #f0f7ff 100%) !important;
    border: 1px solid #e1ecf7 !important;
    border-left: 4px solid var(--composer-accent) !important;
    border-radius: 12px !important;
    padding: 1.5rem !important;
    margin-bottom: 1rem !important;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace !important;
    font-size: 0.9em !important;
    line-height: 1.5 !important;
    white-space: pre-wrap !important;
    max-height: 250px !important;
    overflow-y: auto !important;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.08) !important;
    animation: reasoningBoxAppear 0.3s ease-out !important;
    position: relative !important;
}

body.dark-mode .reasoning-streaming-box {
    background: linear-gradient(135deg, #1a2332 0%, #2a3a46 100%) !important;
    border: 1px solid #3a4a56 !important;
    border-left: 4px solid #4a9eff !important;
    color: #e1e5e9 !important;
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.12) !important;
}

.reasoning-streaming-box .reasoning-content {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(113, 203, 244, 0.05);
    border-radius: 4px;
    border-left: 3px solid var(--color-azzurro);
    min-height: 40px;
}

body.dark-mode .reasoning-streaming-box .reasoning-content {
    background: rgba(113, 203, 244, 0.1);
}

@keyframes reasoningBoxAppear {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Compact mode specific adjustments */
body.compact-mode .reasoning-streaming-box {
    padding: 0.5rem !important;
    margin-bottom: 0.5rem !important;
    font-size: 0.8em !important;
    max-height: 150px !important;
}

/* === PWA SUPPORT === */
@media (display-mode: standalone) {
    body {
        padding-top: 0;
    }
    
    .navbar {
        position: relative;
        top: auto;
    }
    
    .container {
        margin-top: 0;
    }
}

/* === FOCUS IMPROVEMENTS === */
#userInput:focus {
    outline: none;
    border-color: var(--color-azzurro);
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.3);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.3);
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .search-history.show {
        animation: none;
    }
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === LOADING STATES === */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

body.dark-mode .skeleton {
    background: linear-gradient(90deg, #3a4a56 25%, #2a3a46 50%, #3a4a56 75%);
    background-size: 200% 100%;
}

/* === NOTIFICATION IMPROVEMENTS === */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--color-success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    background: var(--color-error);
}

.notification.warning {
    background: #f59e0b;
}

/* === IMPROVED MOBILE NAVIGATION === */
@media (max-width: 768px) {
    .navbar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.2rem;
    }
    
    .nav-item {
        flex: none;
    }
    
    .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 60px !important;
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
        max-height: 50vh;
        overflow-y: auto;
    }
}

/* Mobile: bubble readability padding */
@media (max-width: 576px){
  .chat-container .message{ padding: 0.75rem 0.9rem; }
  .chat-container .message .message-content-wrapper{ border-radius: 10px; }
  /* Rimuovi sfondi fissi per lasciare visibile il gradiente della modalità */
  .user-message, .assistant-message { background: transparent !important; }
  body.dark-mode .user-message, body.dark-mode .assistant-message { background: transparent !important; }
}

@media (max-width: 600px){
  .user-message, .assistant-message { background: transparent !important; }
  body.dark-mode .user-message, body.dark-mode .assistant-message { background: transparent !important; }
}

@media (max-width: 768px){
  .user-message, .assistant-message { background: transparent !important; }
  body.dark-mode .user-message, body.dark-mode .assistant-message { background: transparent !important; }
}

@media (max-width: 480px){
  .user-message, .assistant-message { background: transparent !important; }
  body.dark-mode .user-message, body.dark-mode .assistant-message { background: transparent !important; }
}

/* Mobile: applica direttamente i gradienti alle bubble in base alla modalità (esclude welcome/thought) */
@media (max-width: 768px){
  body.mode-docs .assistant-message:not([data-message-id^="welcome-"]):not(.thought-message),
  body.mode-docs .user-message { background: var(--grad-docs) !important; }
  body.mode-chat .assistant-message:not([data-message-id^="welcome-"]):not(.thought-message),
  body.mode-chat .user-message { background: var(--grad-chat) !important; }
  body.mode-web  .assistant-message:not([data-message-id^="welcome-"]):not(.thought-message),
  body.mode-web  .user-message { background: var(--grad-web)  !important; }
}

/* === CRONOLOGIA RICERCHE === */
.search-history {
    display: none; /* Nascosto - funzionalità rimossa */
}

.search-history-item {
    display: none; /* Nascosto - funzionalità rimossa */
}

.search-history-header {
    display: none; /* Nascosto - funzionalità rimossa */
}

.search-history-clear {
    display: none; /* Nascosto - funzionalità rimossa */
}

/* === CONVERSAZIONI SALVATE === */
.saved-conversations {
    display: none; /* Nascosto - funzionalità rimossa */
}

.saved-conversation-item {
    display: none; /* Nascosto - funzionalità rimossa */
}

.saved-conversation-preview {
    display: none; /* Nascosto - funzionalità rimossa */
}

.saved-conversation-meta {
    display: none; /* Nascosto - funzionalità rimossa */
}

.saved-conversation-count {
    display: none; /* Nascosto - funzionalità rimossa */
}

.saved-conversations-header {
    display: none; /* Nascosto - funzionalità rimossa */
}

/* === AUTO-SAVE INDICATOR === */
.auto-save-indicator {
    display: none; /* Nascosto - funzionalità rimossa */
}

/* === DARK MODE SUPPORT PER ELEMENTI RIMOSSI === */
body.dark-mode .search-history,
body.dark-mode .saved-conversations {
    display: none; /* Nascosto - funzionalità rimossa */
}

body.dark-mode .search-history-item:hover,
body.dark-mode .saved-conversation-item:hover {
    display: none; /* Nascosto - funzionalità rimossa */
}

body.dark-mode .search-history-header,
body.dark-mode .saved-conversations-header {
    display: none; /* Nascosto - funzionalità rimossa */
}

/* === MODAL PREFERENZE === */
.preferences-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.preferences-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.preferences-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    position: relative;
}

.preferences-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

/* === DARK MODE: Bootstrap modal for user settings === */
body.dark-mode .modal-content {
	background-color: #232c33;
	color: var(--color-text);
	border: 1px solid var(--color-border);
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
	border-color: var(--color-border);
}

body.dark-mode .modal-title {
	color: var(--color-text);
}

body.dark-mode .modal-body .form-control,
body.dark-mode .modal-body .form-select {
	background-color: #3a4a56 !important;
	border: 1px solid #4a5a67 !important;
	color: var(--color-text) !important;
}

body.dark-mode .modal-body .form-control:focus,
body.dark-mode .modal-body .form-select:focus {
	background-color: #3a4a56 !important;
	border-color: var(--color-azzurro) !important;
	color: var(--color-text) !important;
	box-shadow: 0 0 0 0.2rem rgba(113, 203, 244, 0.25) !important;
}

body.dark-mode .modal-body .form-text,
body.dark-mode .modal-body .text-muted {
	color: var(--color-text-light) !important;
}

/* Dark mode: campi della sezione comandi (elenco documenti) */
body.dark-mode #cmdFilterName,
body.dark-mode #cmdFilterContent {
	background-color: #3a4a56 !important;
	border: 1px solid #4a5a67 !important;
	color: var(--color-text) !important;
}

body.dark-mode #cmdFilterName:focus,
body.dark-mode #cmdFilterContent:focus {
	background-color: #3a4a56 !important;
	border-color: var(--color-azzurro) !important;
	color: var(--color-text) !important;
	box-shadow: 0 0 0 0.2rem rgba(113, 203, 244, 0.25) !important;
}

body.dark-mode #cmdFilterName::placeholder,
body.dark-mode #cmdFilterContent::placeholder {
	color: #b0bac2 !important;
	opacity: 1;
}

/* Dark mode: filtri aggiuntivi (anno, mese e estensione) */
body.dark-mode #cmdFilterYear,
body.dark-mode #cmdFilterMonth,
body.dark-mode #cmdFilterExtension {
    background-color: #3a4a56 !important;
    border: 1px solid #4a5a67 !important;
    color: var(--color-text) !important;
}

body.dark-mode #cmdFilterYear:focus,
body.dark-mode #cmdFilterMonth:focus,
body.dark-mode #cmdFilterExtension:focus {
    background-color: #3a4a56 !important;
    border-color: var(--color-azzurro) !important;
    color: var(--color-text) !important;
    box-shadow: 0 0 0 0.2rem rgba(113, 203, 244, 0.25) !important;
}

/* Stili specifici per il filtro mese */
#cmdFilterMonth {
    background-color: #fff !important;
    border: 1px solid #ced4da !important;
    color: #495057 !important;
}

#cmdFilterMonth:focus {
    background-color: #fff !important;
    border-color: var(--color-azzurro) !important;
    color: #495057 !important;
    box-shadow: 0 0 0 0.2rem rgba(113, 203, 244, 0.25) !important;
}

/* Stili per i trimestri nel filtro mese */
#cmdFilterMonth option[value^="Q"] {
    font-weight: bold !important;
    color: #007bff !important;
    background-color: #e3f2fd !important;
}

body.dark-mode #cmdFilterMonth option[value^="Q"] {
    color: #64b5f6 !important;
    background-color: #1a237e !important;
}

/* Stili per il separatore mesi */
#cmdFilterMonth option[disabled] {
    font-weight: bold !important;
    color: #666 !important;
    background-color: #f8f9fa !important;
}

body.dark-mode #cmdFilterMonth option[disabled] {
    color: #aaa !important;
    background-color: #2d3748 !important;
}

/* Stili per i mesi individuali */
#cmdFilterMonth option:not([value^="Q"]):not([disabled]) {
    padding-left: 16px !important;
}

/* Stili per le categorie del filtro estensioni */
#cmdFilterExtension option[value^="category:"] {
    font-weight: bold !important;
    color: #007bff !important;
    background-color: #e3f2fd !important;
    padding: 4px 8px !important;
    cursor: pointer !important;
}

body.dark-mode #cmdFilterExtension option[value^="category:"] {
    color: #64b5f6 !important;
    background-color: #1a237e !important;
}

#cmdFilterExtension option:not([value^="category:"]) {
    padding-left: 16px !important;
    font-family: monospace !important;
}

/* Hover effect per le categorie estensioni */
#cmdFilterExtension option[value^="category:"]:hover {
    background-color: #bbdefb !important;
}

body.dark-mode #cmdFilterExtension option[value^="category:"]:hover {
    background-color: #283593 !important;
}

/* === ACCORDION ARCHIVI EXTRA === */
.archives-accordion {
	border: 1px solid #dee2e6;
	border-radius: 6px;
	background-color: #f8f9fa;
	overflow: hidden;
}

.archives-accordion-header {
	padding: 8px 12px;
	background-color: #e9ecef;
	border-bottom: 1px solid #dee2e6;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.archives-accordion-header:hover {
	background-color: #dee2e6;
}

.archives-counter {
	font-size: 0.85rem;
	color: #6c757d;
	font-weight: 500;
	margin: 0 8px;
}

.archives-separator {
	color: #adb5bd;
	font-weight: 300;
	font-size: 0.9rem;
	margin: 0 4px;
}

.archives-toggle-btn {
	padding: 2px 6px;
	font-size: 0.8rem;
	min-width: 24px;
	height: 24px;
	border: 1px solid #adb5bd;
	background-color: #fff;
}

.archives-toggle-btn:hover {
	background-color: #f8f9fa;
	border-color: #6c757d;
}

.archives-toggle-icon {
	transition: transform 0.2s ease;
	font-size: 0.7rem;
}

.archives-accordion-content {
	transition: max-height 0.3s ease, opacity 0.2s ease;
	overflow: hidden;
}

.archives-accordion-content.collapsed {
	max-height: 0;
	opacity: 0;
}

.archives-accordion-content.expanded {
	max-height: 300px;
	opacity: 1;
}

/* Dark mode per accordion archivi */
body.dark-mode .archives-accordion {
	background-color: #2b3740;
	border-color: var(--color-border);
}

body.dark-mode .archives-accordion-header {
	background-color: #3a4a56;
	border-bottom-color: var(--color-border);
}

body.dark-mode .archives-accordion-header:hover {
	background-color: #4a5a67;
}

body.dark-mode .archives-counter {
	color: var(--color-text-light);
}

body.dark-mode .archives-separator {
	color: var(--color-text-light);
	opacity: 0.6;
}

body.dark-mode .archives-toggle-btn {
	background-color: #3a4a56;
	border-color: var(--color-border);
	color: var(--color-text);
}

body.dark-mode .archives-toggle-btn:hover {
	background-color: #4a5a67;
	border-color: var(--color-azzurro);
	color: var(--color-azzurro);
}

/* Stili per bottone "Trova documenti" */
#cmdListDocsBtn {
	background-color: #5CC31A !important;
	border-color: #5CC31A !important;
	color: white !important;
	font-weight: 500;
	transition: all 0.2s ease;
}

#cmdListDocsBtn:hover {
	background-color: #49A814 !important;
	border-color: #49A814 !important;
	color: white !important;
	transform: translateY(-1px);
	box-shadow: 0 2px 4px rgba(92, 195, 26, 0.3);
}

#cmdListDocsBtn:active {
	background-color: #3E9311 !important;
	border-color: #3E9311 !important;
	transform: translateY(0);
}

#cmdListDocsBtn:focus {
	box-shadow: 0 0 0 0.2rem rgba(92, 195, 26, 0.3) !important;
}

/* Dark mode per bottone "Trova documenti" */
body.dark-mode #cmdListDocsBtn {
	background-color: #5CC31A !important;
	border-color: #5CC31A !important;
	color: white !important;
}

body.dark-mode #cmdListDocsBtn:hover {
	background-color: #49A814 !important;
	border-color: #49A814 !important;
	color: white !important;
}

body.dark-mode #cmdListDocsBtn:active {
	background-color: #3E9311 !important;
	border-color: #3E9311 !important;
}

/* === DARK MODE: Tabelle dentro ai modal (File Utente) === */
body.dark-mode #userFilesModal .table,
body.dark-mode .modal .table {
	background-color: #232c33;
	color: var(--color-text);
	border-color: var(--color-border);
}
body.dark-mode #userFilesModal .table thead th,
body.dark-mode #userFilesModal .table thead td,
body.dark-mode .modal .table thead th,
body.dark-mode .modal .table thead td {
	background-color: #2b3137;
	color: var(--color-text) !important;
	border-color: var(--color-border) !important;
}
body.dark-mode #userFilesModal .table tbody tr,
body.dark-mode .modal .table tbody tr { background-color: #232c33 !important; }
body.dark-mode #userFilesModal .table tbody tr:nth-of-type(odd),
body.dark-mode .modal .table tbody tr:nth-of-type(odd) { background-color: #20282f !important; }
body.dark-mode #userFilesModal .table-hover tbody tr:hover,
body.dark-mode .modal .table-hover tbody tr:hover { background-color: #2a333a !important; }
body.dark-mode #userFilesModal .table td, 
body.dark-mode #userFilesModal .table th,
body.dark-mode .modal .table td, 
body.dark-mode .modal .table th { border-color: var(--color-border) !important; }

/* Imposta variabili Bootstrap della tabella per dark mode (elimina residui chiari) */
body.dark-mode #userFilesModal .table {
    --bs-table-bg: #232c33;
    --bs-table-color: var(--color-text);
    --bs-table-border-color: #3a4a56;
    --bs-table-striped-bg: #20282f;
    --bs-table-striped-color: var(--color-text);
    --bs-table-hover-bg: #2a333a;
    --bs-table-hover-color: var(--color-text);
}

/* Forza zebra e testate anche se Bootstrap inietta stili inline */
body.dark-mode #userFilesModal table.table-striped>tbody>tr:nth-of-type(odd)>* { --bs-table-accent-bg: #20282f; color: var(--color-text); }
body.dark-mode #userFilesModal table.table-hover>tbody>tr:hover>* { --bs-table-accent-bg: #2a333a; color: var(--color-text); }

.preferences-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.preferences-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.preferences-close:hover {
    background-color: var(--color-border);
    color: var(--color-text);
}

.preference-group {
    margin-bottom: 1.5rem;
}

.preference-label {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    display: block;
}

.preference-description {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-bottom: 0.8rem;
}

.preference-control {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.preference-select {
    flex: 1;
    padding: 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: white;
    color: var(--color-text);
    font-size: 0.9rem;
}

.preference-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.preference-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.preference-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.preference-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .preference-slider {
    background-color: var(--color-azzurro);
}

input:checked + .preference-slider:before {
    transform: translateX(24px);
}

.preferences-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.btn-secondary {
    background-color: var(--color-border);
    color: var(--color-text);
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: var(--color-text-light);
}

.btn-primary {
    background-color: var(--color-azzurro);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary:hover {
    background-color: var(--color-azzurro-dark);
}

body.dark-mode .preferences-content {
    background-color: #27323a;
}

body.dark-mode .preference-select {
    background-color: #232c33;
    border-color: var(--color-border);
    color: var(--color-text);
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-history.show {
    animation: slideDown 0.2s ease;
}

/* === REMOVED: Deep Search Controls (sostituiti da interfaccia unificata) === */

/* ===== CATEGORY FILTERS STYLES ===== */

.enhanced-search-controls {
    background: rgba(113, 203, 244, 0.05);
    border: 1px solid rgba(113, 203, 244, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.enhanced-search-controls:hover {
    background: rgba(113, 203, 244, 0.08);
    border-color: rgba(113, 203, 244, 0.3);
}

.category-filters {
    display: none;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
}

.category-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.category-filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.category-select {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: white;
    color: var(--color-text);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.category-select:focus {
    outline: none;
    border-color: var(--color-azzurro);
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.2);
}

.category-select:hover {
    border-color: var(--color-azzurro-dark);
}

#categoryFilterBtn {
    position: relative;
    transition: all 0.3s ease;
}

#categoryFilterBtn.active {
    background-color: var(--color-azzurro);
    border-color: var(--color-azzurro);
    color: white;
}

#categoryFilterBtn.has-filters {
    background-color: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

#categoryFilterBtn.has-filters::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid white;
}

.filter-status {
    font-size: 0.85rem;
    color: var(--color-success);
    font-weight: 500;
    margin-left: 8px;
}

.search-status-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Dark mode styles for category filters */
body.dark-mode .enhanced-search-controls {
    background: rgba(113, 203, 244, 0.08);
    border-color: rgba(113, 203, 244, 0.3);
}

body.dark-mode .enhanced-search-controls:hover {
    background: rgba(113, 203, 244, 0.12);
    border-color: rgba(113, 203, 244, 0.4);
}

body.dark-mode .category-filters {
    background: rgba(35, 44, 51, 0.95);
    border-color: var(--color-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .category-filter-label {
    color: var(--color-text);
}

body.dark-mode .category-select {
    background: #232c33;
    color: var(--color-text);
    border-color: var(--color-border);
}

body.dark-mode .category-select:focus {
    border-color: var(--color-azzurro);
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.3);
}

body.dark-mode .category-select:hover {
    border-color: var(--color-azzurro-light);
}

body.dark-mode .filter-status {
    color: var(--color-azzurro-light);
}

/* Mobile responsive styles for category filters */
@media (max-width: 768px) {
    .enhanced-search-controls .d-flex {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }
    
    .category-filters {
        flex-direction: column;
        gap: 8px;
    }
    
    .category-filter-group {
        min-width: auto;
        width: 100%;
    }
    
    .search-status-info {
        justify-content: center;
        text-align: center;
    }
    
    #categoryFilterBtn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .enhanced-search-controls {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .category-filters {
        padding: 8px;
        margin-top: 6px;
    }
    
    .category-filter-label {
        font-size: 0.8rem;
    }
    
    .category-select {
        padding: 5px 8px;
        font-size: 0.85rem;
    }
}

/* Animation for filter dropdown */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Filter button hover effects */
#categoryFilterBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(113, 203, 244, 0.3);
}

#categoryFilterBtn:active {
    transform: translateY(0);
}

/* Enhanced search controls layout improvements */
.enhanced-search-controls .d-flex.align-items-center {
    gap: 16px;
}

.enhanced-search-controls .me-3 {
    margin-right: 0 !important;
}

.enhanced-search-controls .mb-2 {
    margin-bottom: 0 !important;
}

/* Floating preferences button compatibility */
.floating-preferences {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-azzurro);
    color: white;
    border: none;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(113, 203, 244, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
}

.floating-preferences:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(113, 203, 244, 0.6);
}

body.dark-mode .floating-preferences {
    background: var(--color-azzurro-dark);
    box-shadow: 0 4px 12px rgba(74, 159, 212, 0.4);
}

body.dark-mode .floating-preferences:hover {
    box-shadow: 0 6px 16px rgba(74, 159, 212, 0.6);
}

/* ===== FILTER FEEDBACK STYLES ===== */

.filter-feedback {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: 8px;
    animation: fadeInOut 5s ease-in-out;
}

.filter-feedback-success {
    background-color: rgba(72, 187, 120, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(72, 187, 120, 0.3);
}

.filter-feedback-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.filter-feedback-error {
    background-color: rgba(245, 101, 101, 0.1);
    color: var(--color-error);
    border: 1px solid rgba(245, 101, 101, 0.3);
}

/* Dark mode styles for filter feedback */
body.dark-mode .filter-feedback-success {
    background-color: rgba(72, 187, 120, 0.15);
    color: #68d391;
    border-color: rgba(72, 187, 120, 0.4);
}

body.dark-mode .filter-feedback-warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}

body.dark-mode .filter-feedback-error {
    background-color: rgba(245, 101, 101, 0.15);
    color: #f87171;
    border-color: rgba(245, 101, 101, 0.4);
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-5px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-5px); }
}

/* ===== ENHANCED INGESTION SUGGESTION ===== */

.enhanced-ingestion-suggestion {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid var(--color-azzurro-light);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    box-shadow: 0 4px 12px rgba(113, 203, 244, 0.15);
    animation: slideInFromTop 0.5s ease-out;
}

.suggestion-content h4 {
    color: var(--color-azzurro-dark);
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.suggestion-content p {
    color: var(--color-text);
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

.suggestion-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.suggestion-actions .btn-primary,
.suggestion-actions .btn-secondary {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.suggestion-actions .btn-primary {
    background-color: var(--color-azzurro);
    color: white;
}

.suggestion-actions .btn-primary:hover {
    background-color: var(--color-azzurro-dark);
    transform: translateY(-1px);
}

.suggestion-actions .btn-secondary {
    background-color: transparent;
    color: var(--color-azzurro-dark);
    border: 1px solid var(--color-azzurro-light);
}

.suggestion-actions .btn-secondary:hover {
    background-color: var(--color-azzurro-light);
    color: white;
    transform: translateY(-1px);
}

/* Dark mode styles for enhanced ingestion suggestion */
body.dark-mode .enhanced-ingestion-suggestion {
    background: linear-gradient(135deg, #1a2332 0%, #2a3a46 100%);
    border-color: var(--color-azzurro);
    box-shadow: 0 4px 12px rgba(113, 203, 244, 0.2);
}

body.dark-mode .suggestion-content h4 {
    color: var(--color-azzurro-light);
}

body.dark-mode .suggestion-content p {
    color: var(--color-text);
}

body.dark-mode .suggestion-actions .btn-primary {
    background-color: var(--color-azzurro-dark);
}

body.dark-mode .suggestion-actions .btn-primary:hover {
    background-color: var(--color-azzurro);
}

body.dark-mode .suggestion-actions .btn-secondary {
    color: var(--color-azzurro-light);
    border-color: var(--color-azzurro);
}

body.dark-mode .suggestion-actions .btn-secondary:hover {
    background-color: var(--color-azzurro);
    color: white;
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsive styles for suggestions */
@media (max-width: 768px) {
    .enhanced-ingestion-suggestion {
        padding: 1rem;
        margin: 0.5rem 0;
    }
    
    .suggestion-content h4 {
        font-size: 1rem;
    }
    
    .suggestion-content p {
        font-size: 0.9rem;
    }
    
    .suggestion-actions {
        flex-direction: column;
    }
    
    .suggestion-actions .btn-primary,
    .suggestion-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }
}

/* === CATEGORY FILTERS HORIZONTAL INTERFACE === */

.category-filters-horizontal {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.category-filters-horizontal:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.filters-categories {
    display: block;
}

.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.category-btn {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 3px;
}

.category-btn:hover {
    border-color: var(--color-azzurro);
    background: var(--color-azzurro-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(113, 203, 244, 0.25);
}

.category-btn.active {
    background: var(--color-azzurro);
    border-color: var(--color-azzurro-dark);
    color: white;
    box-shadow: 0 2px 6px rgba(113, 203, 244, 0.3);
}

.category-btn.active:hover {
    background: var(--color-azzurro-dark);
    transform: translateY(-1px);
}

/* Dark Mode Styles */
body.dark-mode .category-filters-horizontal {
    background: linear-gradient(135deg, #232c33 0%, #27323a 100%);
    border-color: var(--color-border);
}

body.dark-mode .category-filters-horizontal .filters-header h3 {
    color: var(--color-text);
}

body.dark-mode .toggle-slider {
    background-color: #4a5568;
}

body.dark-mode input:checked + .toggle-slider {
    background-color: var(--color-azzurro);
}

body.dark-mode .category-btn {
    background: #232c33;
    border-color: var(--color-border);
    color: var(--color-text);
}

body.dark-mode .category-btn:hover {
    background: #27323a;
    border-color: var(--color-azzurro);
}

body.dark-mode .category-btn.active {
    background: var(--color-azzurro);
    border-color: var(--color-azzurro-dark);
    color: #232c33;
}

body.dark-mode .filter-select-compact {
    background: #232c33;
    border-color: var(--color-border);
    color: var(--color-text);
}

body.dark-mode .filter-select-compact:focus {
    border-color: var(--color-azzurro);
}

/* Responsive Design */
@media (max-width: 768px) {
    .category-buttons {
        gap: 6px;
    }
    
    .category-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .filters-secondary {
        gap: 8px;
    }
    
    .filter-select-compact {
        min-width: 80px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .category-filters-horizontal .filters-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .category-buttons {
        gap: 4px;
    }
    
    .category-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    .filters-secondary {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        width: 100%;
    }
    
    .filter-group-inline {
        width: 100%;
        justify-content: space-between;
    }
    
    .filter-select-compact {
        flex: 1;
        min-width: 0;
    }
}

/* === UNIFIED SEARCH CONTROLS (Categorie in alto + Deep Search) === */

.unified-search-controls {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
}

.unified-search-controls:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

/* === ETICHETTA CATEGORIE IN ALTO === */

.categories-header {
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.categories-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    display: block;
}

/* === WRAPPER CONTROLLI === */

.search-controls-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* === SEZIONE CATEGORIE (SENZA ETICHETTA INLINE) === */

.categories-section {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.category-btn {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 3px;
}

.category-btn:hover {
    border-color: var(--color-azzurro);
    background: var(--color-azzurro-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(113, 203, 244, 0.25);
}

.category-btn.active {
    background: var(--color-azzurro);
    border-color: var(--color-azzurro-dark);
    color: white;
    box-shadow: 0 2px 6px rgba(113, 203, 244, 0.3);
}

.category-btn.active:hover {
    background: var(--color-azzurro-dark);
    transform: translateY(-1px);
}

/* === SEPARATORE VERTICALE === */

.vertical-separator {
    font-size: 1.2rem;
    color: var(--color-text-light);
    font-weight: 300;
    margin: 0 8px;
    opacity: 0.6;
}

/* === SEZIONE DEEP SEARCH (EMOJI + NUMERO) === */

.advanced-search-section {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.search-level-buttons {
    display: flex;
    gap: 4px;
}

.search-level-btn {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 35px;
    text-align: center;
    line-height: 1;
}

.search-level-btn:hover {
    border-color: var(--color-azzurro);
    background: var(--color-azzurro-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(113, 203, 244, 0.25);
}

.search-level-btn.active {
    background: var(--color-azzurro);
    border-color: var(--color-azzurro-dark);
    color: white;
    box-shadow: 0 2px 6px rgba(113, 203, 244, 0.3);
    font-weight: 600;
}

.search-level-btn.active:hover {
    background: var(--color-azzurro-dark);
    transform: translateY(-1px);
}

/* === NOTA DINAMICA DEEP SEARCH === */

.deep-search-note {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(113, 203, 244, 0.1);
    border: 1px solid rgba(113, 203, 244, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--color-azzurro-dark);
    font-weight: 500;
    animation: fadeInNote 0.3s ease;
}

@keyframes fadeInNote {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === DARK MODE STYLES === */

body.dark-mode .unified-search-controls {
    background: linear-gradient(135deg, #232c33 0%, #27323a 100%);
    border-color: var(--color-border);
}

body.dark-mode .categories-header {
    border-bottom-color: rgba(255,255,255,0.1);
}

body.dark-mode .categories-title {
    color: var(--color-text);
}

body.dark-mode .vertical-separator {
    color: var(--color-text-light);
}

body.dark-mode .search-level-btn {
    background: #232c33;
    border-color: var(--color-border);
    color: var(--color-text);
}

body.dark-mode .search-level-btn:hover {
    background: #27323a;
    border-color: var(--color-azzurro);
}

body.dark-mode .search-level-btn.active {
    background: var(--color-azzurro);
    border-color: var(--color-azzurro-dark);
    color: #232c33;
}

body.dark-mode .category-btn {
    background: #232c33;
    border-color: var(--color-border);
    color: var(--color-text);
}

body.dark-mode .category-btn:hover {
    background: #27323a;
    border-color: var(--color-azzurro);
}

body.dark-mode .category-btn.active {
    background: var(--color-azzurro);
    border-color: var(--color-azzurro-dark);
    color: #232c33;
}

body.dark-mode .deep-search-note {
    background: rgba(113, 203, 244, 0.15);
    border-color: rgba(113, 203, 244, 0.4);
    color: var(--color-azzurro-light);
}

/* === RESPONSIVE DESIGN === */

@media (max-width: 768px) {
    .search-controls-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .categories-section,
    .advanced-search-section {
        width: 100%;
    }
    
    .vertical-separator {
        display: none; /* Nasconde il separatore su mobile */
    }
    
    .category-buttons {
        gap: 6px;
        justify-content: flex-start;
    }
    
    .category-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .search-level-buttons {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }
    
    .search-level-btn {
        min-width: 40px;
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .unified-search-controls {
        padding: 8px 12px;
    }
    
    .categories-title {
        font-size: 0.8rem;
    }
    
    .search-level-btn {
        padding: 6px 8px;
        font-size: 0.8rem;
        min-width: 35px;
    }
    
    .category-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    .deep-search-note {
        font-size: 0.75rem;
        padding: 5px 8px;
    }
}

/* === STILI PER CONTROLLI RIMOSSI - ORA INTEGRATI NEL FLUSSO NORMALE === */

/* Area di input del messaggio - non più sticky */

/* Container Unificato: Filtri + Input */
.unified-input-container {
    position: relative;
    margin-top: 20px;
    margin-bottom: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

body.dark-mode .unified-input-container {
    background: #2d3748;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Sezione Filtri */
.filters-section {
    padding: 1rem 1rem 0.75rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(113, 203, 244, 0.02);
}

body.dark-mode .filters-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(113, 203, 244, 0.05);
}

/* Adattamenti per i filtri nel nuovo container */
.filters-section .unified-search-controls {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    border-radius: 0;
}

.filters-section .categories-header {
    margin-bottom: 0.75rem;
}

.filters-section .categories-title {
    font-size: 0.9rem;
    color: var(--color-text-light);
    font-weight: 500;
}

body.dark-mode .filters-section .categories-title {
    color: var(--color-text-light);
}

/* Pulsante Toggle Modalità RAG/LLM */
.mode-toggle-btn-inline {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 8px 0 0 0;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid var(--color-border);
    border-right: none;
    background: var(--color-background);
    color: var(--color-text);
    white-space: nowrap;
    min-width: 60px;
    line-height: 1;
    position: relative;
    vertical-align: middle;
}

.mode-toggle-btn-inline .mode-icon {
    font-size: 16px;
    line-height: 1;
}

.mode-toggle-btn-inline .mode-text {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    margin-top: 1px;
}

.mode-toggle-btn-inline:hover {
    background: var(--color-azzurro-light);
    border-color: var(--color-azzurro);
    color: var(--color-azzurro-dark);
    z-index: 2;
}

.mode-toggle-btn-inline:focus {
    z-index: 3;
    border-color: var(--color-azzurro);
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.2);
}

/* Cornice del toggle in base alla modalità corrente (aggiunta classi dinamiche) */
.mode-toggle-btn-inline.llm-mode { border-color: var(--e17-magenta); }
.mode-toggle-btn-inline.web-mode { border-color: var(--e17-cyan); }
.mode-toggle-btn-inline.green-mode { border-color: var(--e17-green-soft); }

/* Bottone LLM - STESSO STILE degli altri 3 toggle (usa variabili CSS) */
.mode-toggle-btn-inline.llm-mode {
    /* Gli stili sono già definiti da .mode-toggle-btn-inline */
}

.mode-toggle-btn-inline.llm-mode:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .mode-toggle-btn-inline.llm-mode:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Pulsante Toggle Filtri Inline */
.filters-toggle-btn-inline {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 0;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid var(--color-border);
    border-left: none;
    border-right: 1px solid var(--color-border);
    background: var(--color-background);
    color: var(--color-text);
    white-space: nowrap;
    min-width: 60px;
    line-height: 1;
    position: relative;
    vertical-align: middle;
}

.filters-toggle-btn-inline:hover {
    background: var(--color-azzurro-light);
    border-color: var(--color-azzurro);
    color: var(--color-azzurro-dark);
    z-index: 2;
}

.filters-toggle-btn-inline:focus {
    z-index: 3;
    border-color: var(--color-azzurro);
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.2);
}

.filters-toggle-btn-inline .toggle-icon {
    font-size: 16px;
    letter-spacing: 3px;
    line-height: 1;
    margin-bottom: 2px;
}

.filters-toggle-btn-inline .toggle-text {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    margin-top: 1px;
}

.filters-toggle-btn-inline .toggle-arrow {
    font-size: 8px;
    transition: transform 0.3s ease;
    position: absolute;
    top: 2px;
    right: 2px;
    line-height: 1;
}

/* Rimuovo la rotazione dato che ora uso simboli diversi */

body.dark-mode .mode-toggle-btn-inline {
    background: var(--color-antracite);
    border: 1px solid var(--color-border);
    border-right: none;
    color: var(--color-text);
}

body.dark-mode .mode-toggle-btn-inline:hover {
    background: var(--color-azzurro-dark);
    border-color: var(--color-azzurro);
    color: white;
}

body.dark-mode .mode-toggle-btn-inline:focus {
    border-color: var(--color-azzurro);
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.3);
}


body.dark-mode .filters-toggle-btn-inline {
    background: var(--color-antracite);
    border: 1px solid var(--color-border);
    border-left: none;
    color: var(--color-text);
}

body.dark-mode .filters-toggle-btn-inline:hover {
    background: var(--color-azzurro-dark);
    border-color: var(--color-azzurro);
    color: white;
}

body.dark-mode .filters-toggle-btn-inline:focus {
    border-color: var(--color-azzurro);
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.3);
}

/* Sezione Filtri Collassabile */
.filters-section {
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    max-height: 1000px;
    margin-bottom: 12px;
}

.filters-section.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Sezione Input */
.input-section {
    padding: 0.75rem 1rem 1rem 1rem;
}

.input-section .input-group {
    background: transparent;
    border-radius: 8px;
    box-shadow: none;
    padding: 0;
    margin: 0;
    border: none;
}

.input-section #userInput {
    border: 1px solid var(--color-border);
    border-left: none;
    border-right: none;
    border-radius: 0;
    padding: 0.75rem;
    font-size: 1rem;
    resize: none;
    min-height: 40px;
    max-height: 150px;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--grad-docs);
}

.input-section #userInput:focus {
    border-color: var(--color-azzurro);
    border-left: none;
    border-right: none;
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.2);
    outline: none;
}

body.dark-mode .input-section #userInput {
    background: var(--grad-docs);
    border-color: rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
}

body.dark-mode .input-section #userInput:focus {
    border-color: var(--color-azzurro);
    border-left: none;
    border-right: none;
    box-shadow: 0 0 0 2px rgba(113, 203, 244, 0.3);
}

.input-section #sendBtn {
    background-color: var(--composer-accent);
    border: 1px solid var(--composer-accent);
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s;
    color: white;
}

.input-section #sendBtn:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}

.input-section #sendBtn:active {
    transform: translateY(0);
}

/* Session ID styling */
.input-section .text-muted {
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

body.dark-mode .input-section .text-muted {
    color: #a0aec0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .unified-input-container {
        margin-top: 15px;
        margin-bottom: 15px;
        border-radius: 10px;
    }
    
    .mode-toggle-btn-inline {
        padding: 6px 8px;
        min-width: 45px;
    }
    
    .mode-toggle-btn-inline .mode-text {
        display: inline;
    }
    
    .mode-toggle-btn-inline .mode-icon {
        font-size: 16px;
    }
    
    .filters-toggle-btn-inline {
        padding: 6px 8px;
        min-width: 45px;
    }
    
    .filters-toggle-btn-inline .toggle-text {
        display: inline;
    }
    
    .filters-toggle-btn-inline .toggle-icon {
        font-size: 14px;
        letter-spacing: 3px;
    }
    
    .filters-toggle-btn-inline .toggle-arrow {
        top: 1px;
        right: 1px;
        font-size: 7px;
    }
    
    .filters-section {
        padding: 0.75rem 0.75rem 0.5rem 0.75rem;
    }
    
    .filters-section .categories-title {
        font-size: 0.85rem;
    }
    
    .filters-section .category-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .filters-section .search-level-btn {
        padding: 8px 10px;
        min-width: 40px;
    }
    
    .input-section {
        padding: 0.5rem 0.75rem 0.75rem 0.75rem;
    }
    
    .input-section #userInput {
        padding: 0.6rem;
        font-size: 0.95rem;
    }
    
    .input-section #sendBtn {
        padding: 0.4rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .unified-input-container {
        margin-top: 10px;
        margin-bottom: 10px;
        border-radius: 8px;
    }
    
    .mode-toggle-btn-inline {
        padding: 5px 6px;
        min-width: 35px;
    }
    
    .mode-toggle-btn-inline .mode-icon {
        font-size: 16px;
    }
    
    .filters-toggle-btn-inline {
        padding: 5px 6px;
        min-width: 35px;
    }
    
    .filters-toggle-btn-inline .toggle-icon {
        font-size: 14px;
        letter-spacing: 2px;
    }
    
    .filters-toggle-btn-inline .toggle-arrow {
        font-size: 6px;
        top: 1px;
        right: 1px;
    }
    
    .filters-section {
        padding: 0.5rem 0.5rem 0.25rem 0.5rem;
    }
    
    .filters-section .categories-title {
        font-size: 0.8rem;
    }
    
    .filters-section .category-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    .filters-section .search-level-btn {
        padding: 6px 8px;
        font-size: 0.8rem;
        min-width: 35px;
    }
    
    .filters-section .search-controls-wrapper {
        flex-direction: column;
        gap: 8px;
    }
    
    .filters-section .vertical-separator {
        display: none;
    }
    
    .input-section {
        padding: 0.25rem 0.5rem 0.5rem 0.5rem;
    }
    
    .input-section #userInput {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    .input-section #sendBtn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* ===== STREAMING ANALYSIS STYLES ===== */
.streaming-indicator {
    color: var(--color-azzurro);
    font-weight: 500;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(113, 203, 244, 0.1) 0%, rgba(113, 203, 244, 0.05) 100%);
    border-left: 4px solid var(--color-azzurro);
    border-radius: 0 6px 6px 0;
    animation: streamingPulse 2s ease-in-out infinite;
}

@keyframes streamingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.streamed-content {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-top: 0.5rem;
    line-height: 1.6;
}

.streamed-content h1,
.streamed-content h2,
.streamed-content h3 {
    color: var(--color-antracite);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.streamed-content h1 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--color-azzurro);
    padding-bottom: 0.5rem;
}

.streamed-content h2 {
    font-size: 1.3rem;
    color: var(--color-azzurro-dark);
}

.streamed-content h3 {
    font-size: 1.1rem;
    color: var(--color-text);
}

.streamed-content ul,
.streamed-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.streamed-content li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.streamed-content strong {
    color: var(--color-antracite);
    font-weight: 600;
}

.streamed-content code {
    background: rgba(113, 203, 244, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.streamed-content pre {
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.streamed-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

/* Dark mode per streaming */
body.dark-mode .streaming-indicator {
    background: linear-gradient(135deg, rgba(113, 203, 244, 0.15) 0%, rgba(113, 203, 244, 0.08) 100%);
    color: var(--color-azzurro-light);
}

body.dark-mode .streamed-content {
    background: #27323a;
    border-color: var(--color-border);
    color: var(--color-text);
}

body.dark-mode .streamed-content h1,
body.dark-mode .streamed-content h2,
body.dark-mode .streamed-content h3 {
    color: var(--color-azzurro-light);
}

body.dark-mode .streamed-content h1 {
    border-bottom-color: var(--color-azzurro);
}

body.dark-mode .streamed-content strong {
    color: var(--color-azzurro-light);
}

body.dark-mode .streamed-content code {
    background: rgba(113, 203, 244, 0.15);
    color: var(--color-azzurro-light);
}

body.dark-mode .streamed-content pre {
    background: #232c33;
    border-color: var(--color-border);
}

/* Responsive per streaming */
@media (max-width: 768px) {
    .streaming-indicator {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    .streamed-content {
        max-height: 300px;
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .streamed-content h1 {
        font-size: 1.3rem;
    }
    
    .streamed-content h2 {
        font-size: 1.1rem;
    }
    
    .streamed-content h3 {
        font-size: 1rem;
    }
}

/* Animazione per il contenuto che appare */
.streamed-content {
    animation: streamContentAppear 0.3s ease-out;
}

@keyframes streamContentAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Indicatore di errore per streaming */
.streaming-error {
    color: var(--color-error);
    background: linear-gradient(135deg, rgba(245, 101, 101, 0.1) 0%, rgba(245, 101, 101, 0.05) 100%);
    border-left-color: var(--color-error);
    padding: 0.75rem;
    border-radius: 0 6px 6px 0;
    margin: 0.5rem 0;
}

body.dark-mode .streaming-error {
    background: linear-gradient(135deg, rgba(245, 101, 101, 0.15) 0%, rgba(245, 101, 101, 0.08) 100%);
}

/* ===== QUERY SUGGESTIONS SYSTEM ===== */
.query-suggestions-wrapper {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 12px;
    margin: 15px 0;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
}

.query-suggestions-wrapper.collapsed .suggestions-container {
    display: none;
}

.query-suggestions-wrapper.collapsed .suggestions-footer {
    display: none;
}

/* Layout compatto per singolo suggerimento su una riga - INVISIBILE */
.query-suggestions-wrapper.compact-single {
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: none; /* Nascosto di default - mostrato solo per punteggi bassi */
}

.suggestion-item-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    font-size: 12px;
    color: #888;
}

.suggestion-icon {
    font-size: 12px;
    flex-shrink: 0;
    color: #aaa;
}

.suggestion-text {
    flex: 1;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    font-style: italic;
    transition: color 0.2s ease;
}

.suggestion-text:hover {
    color: #555;
}

.btn-execute-compact,
.btn-dismiss-compact {
    background: none;
    color: #aaa;
    border: none;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.btn-execute-compact:hover {
    background: rgba(0, 156, 255, 0.1);
    color: #009cff;
}

.btn-dismiss-compact {
    color: #bbb;
    padding: 2px 4px;
}

.btn-dismiss-compact:hover {
    background: rgba(255, 0, 0, 0.1);
    color: #ff6666;
}

.no-suggestions-compact {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    font-size: 13px;
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(90deg, #007bff 0%, #0056b3 100%);
    color: white;
    margin: 0;
}

.suggestions-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.suggestions-controls {
    display: flex;
    gap: 8px;
}

.btn-suggestions-refresh,
.btn-suggestions-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
}

.btn-suggestions-refresh:hover,
.btn-suggestions-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.suggestions-container {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.suggestions-loading,
.suggestions-error,
.no-suggestions,
.suggestions-disabled {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-style: italic;
}

.suggestions-loading .loading-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

.suggestions-error {
    color: #dc3545;
}

.btn-retry {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 8px;
    font-size: 12px;
}

.btn-retry:hover {
    background: #0056b3;
}

.suggestion-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
}

.suggestion-item.suggestion-appear {
    opacity: 1;
    transform: translateY(0);
}

.suggestion-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
    transform: translateY(-1px);
}

.suggestion-item.executing {
    background: #fff3cd;
    border-color: #ffc107;
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.suggestion-category {
    font-size: 11px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestion-complexity {
    font-size: 14px;
}

.suggestion-query {
    font-size: 14px;
    font-weight: 500;
    color: #212529;
    margin-bottom: 8px;
    line-height: 1.4;
    cursor: pointer;
}

.suggestion-query:hover {
    color: #007bff;
}

.suggestion-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 11px;
    color: #6c757d;
}

.suggestion-confidence {
    font-weight: 500;
}

.suggestion-docs {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
}

.suggestion-contextual {
    background: #d4edda;
    color: #155724;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.suggestion-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-execute-suggestion,
.btn-copy-suggestion,
.btn-feedback-suggestion {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-execute-suggestion {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.btn-execute-suggestion:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.btn-copy-suggestion:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.btn-feedback-suggestion:hover {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.btn-execute-suggestion:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Confidence indicators */
.suggestion-item.high-confidence {
    border-left: 4px solid #28a745;
}

.suggestion-item.medium-confidence {
    border-left: 4px solid #ffc107;
}

.suggestion-item.low-confidence {
    border-left: 4px solid #dc3545;
}

.suggestions-footer {
    padding: 8px 16px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.suggestions-footer small {
    font-size: 11px;
    color: #6c757d;
}

/* Feedback Modal */
.suggestion-feedback-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.feedback-modal-content {
    background: white;
    border-radius: 8px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #007bff;
    color: white;
    border-radius: 8px 8px 0 0;
}

.feedback-header h4 {
    margin: 0;
    font-size: 16px;
}

.feedback-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.feedback-body {
    padding: 16px;
}

.feedback-body p {
    margin-bottom: 16px;
    font-size: 14px;
}

.feedback-options {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.feedback-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.feedback-btn.helpful:hover {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.feedback-btn.not-helpful:hover {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.feedback-btn.irrelevant:hover {
    background: #e2e3e5;
    border-color: #d6d8db;
    color: #383d41;
}

.feedback-comments {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 12px;
    resize: vertical;
    font-family: inherit;
}

.feedback-comments:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Dark mode support */
body.dark-mode .query-suggestions-wrapper {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-color: #495057;
}

body.dark-mode .suggestions-header {
    background: linear-gradient(90deg, #0056b3 0%, #003d82 100%);
}

body.dark-mode .suggestion-item {
    background: #343a40;
    border-color: #495057;
    color: #f8f9fa;
}

body.dark-mode .suggestion-item:hover {
    border-color: #007bff;
    background: #3d4449;
}

body.dark-mode .suggestion-query {
    color: #f8f9fa;
}

body.dark-mode .suggestion-query:hover {
    color: #66b3ff;
}

body.dark-mode .suggestion-meta {
    color: #adb5bd;
}

body.dark-mode .suggestions-footer {
    background: #2c3e50;
    border-color: #495057;
}

body.dark-mode .feedback-modal-content {
    background: #343a40;
    color: #f8f9fa;
}

body.dark-mode .feedback-header {
    background: #0056b3;
}

body.dark-mode .feedback-comments {
    background: #495057;
    border-color: #6c757d;
    color: #f8f9fa;
}

body.dark-mode .feedback-comments:focus {
    border-color: #66b3ff;
}

body.dark-mode .btn-execute-suggestion,
body.dark-mode .btn-copy-suggestion,
body.dark-mode .btn-feedback-suggestion,
body.dark-mode .feedback-btn {
    background: #495057;
    border-color: #6c757d;
    color: #f8f9fa;
}

body.dark-mode .btn-execute-suggestion {
    background: #007bff;
    border-color: #007bff;
}

body.dark-mode .btn-execute-suggestion:hover {
    background: #0056b3;
}

/* Dark mode per layout compatto - INVISIBILE */
body.dark-mode .query-suggestions-wrapper.compact-single {
    background: none;
    border: none;
    box-shadow: none;
}

body.dark-mode .suggestion-item-compact {
    color: #555;
}

body.dark-mode .suggestion-icon {
    color: #444;
}

body.dark-mode .suggestion-text {
    color: #555;
}

body.dark-mode .suggestion-text:hover {
    color: #888;
}

body.dark-mode .btn-execute-compact {
    color: #444;
}

body.dark-mode .btn-execute-compact:hover {
    background: rgba(0, 156, 255, 0.2);
    color: #66b3ff;
}

body.dark-mode .btn-dismiss-compact {
    color: #333;
}

body.dark-mode .btn-dismiss-compact:hover {
    background: rgba(255, 0, 0, 0.2);
    color: #ff8888;
}

body.dark-mode .no-suggestions-compact {
    color: #444;
}

/* Responsive design */
@media (max-width: 768px) {
    .query-suggestions-wrapper {
        margin: 10px 0;
    }
    
    .suggestions-header {
        padding: 10px 12px;
    }
    
    .suggestions-header h4 {
        font-size: 13px;
    }
    
    .suggestions-container {
        padding: 12px;
    }
    
    .suggestion-item {
        padding: 10px;
    }
    
    .suggestion-actions {
        gap: 6px;
    }
    
    .btn-execute-suggestion,
    .btn-copy-suggestion,
    .btn-feedback-suggestion {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    .feedback-modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .feedback-options {
        flex-direction: column;
    }
    
    .feedback-btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .suggestions-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .suggestion-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .suggestion-meta {
        flex-direction: column;
        gap: 4px;
    }
    
    .suggestion-actions {
        flex-direction: column;
    }
    
    .btn-execute-suggestion,
    .btn-copy-suggestion,
    .btn-feedback-suggestion {
        width: 100%;
        text-align: center;
    }
}

/* Animation keyframes */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== CONTROLLO TEMPERATURA COMPATTO ===== */
.temperature-control-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    margin: 12px 0;
    background: rgba(113, 203, 244, 0.1);
    border: 1px solid rgba(113, 203, 244, 0.3);
    border-radius: 8px;
    transition: all 0.3s ease;
    width: 100%;
}

.temperature-control-compact:hover {
    background: rgba(113, 203, 244, 0.15);
    border-color: rgba(113, 203, 244, 0.5);
    box-shadow: 0 2px 8px rgba(113, 203, 244, 0.2);
}

.temp-icon {
    font-size: 14px;
    opacity: 0.8;
}

.temp-mode-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    min-width: 32px;
}

.temp-value-compact {
    background: var(--color-azzurro);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
    transition: all 0.2s ease;
}

.temp-slider-compact {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    outline: none;
    opacity: 0.8;
    transition: all 0.3s ease;
    cursor: pointer;
    background: linear-gradient(to right, #e2e8f0 0%, var(--color-azzurro) 100%);
}

.temp-slider-compact:hover {
    opacity: 1;
    height: 6px;
}

.temp-slider-compact::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-azzurro);
    cursor: pointer;
    border: 1px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.temp-slider-compact::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.temp-slider-compact::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-azzurro);
    cursor: pointer;
    border: 1px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.btn-reset-temp {
    background: none;
    border: none;
    color: var(--color-text-light);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.btn-reset-temp:hover {
    opacity: 1;
    background: rgba(113, 203, 244, 0.2);
    color: var(--color-azzurro);
    transform: scale(1.1);
}

/* Modalità RAG - Verde */
.temperature-control-compact.rag-mode {
    background: rgba(131, 240, 26, 0.10);
    border-color: rgba(131, 240, 26, 0.30);
}

.temperature-control-compact.rag-mode:hover {
    background: rgba(131, 240, 26, 0.15);
    border-color: rgba(131, 240, 26, 0.50);
    box-shadow: 0 2px 8px rgba(131, 240, 26, 0.20);
}

.temperature-control-compact.rag-mode .temp-value-compact {
    background: #5CC31A; /* verde meno acido per badge valore */
}

.temperature-control-compact.rag-mode .temp-slider-compact {
    background: linear-gradient(to right, #e2e8f0 0%, #5CC31A 100%);
}

.temperature-control-compact.rag-mode .temp-slider-compact::-webkit-slider-thumb {
    background: #5CC31A; /* thumb meno acido */
}

.temperature-control-compact.rag-mode .temp-slider-compact::-moz-range-thumb {
    background: #5CC31A;
}

.temperature-control-compact.rag-mode .btn-reset-temp:hover {
    background: rgba(131, 240, 26, 0.20);
    color: var(--e17-green);
}

/* Modalità LLM - Magenta */
.temperature-control-compact.llm-mode {
    background: rgba(231, 25, 132, 0.10);
    border-color: rgba(231, 25, 132, 0.30);
}

.temperature-control-compact.llm-mode:hover {
    background: rgba(231, 25, 132, 0.15);
    border-color: rgba(231, 25, 132, 0.50);
    box-shadow: 0 2px 8px rgba(231, 25, 132, 0.20);
}

.temperature-control-compact.llm-mode .temp-value-compact {
    background: var(--e17-magenta);
}

.temperature-control-compact.llm-mode .temp-slider-compact {
    background: linear-gradient(to right, #e2e8f0 0%, var(--e17-magenta) 100%);
}

.temperature-control-compact.llm-mode .temp-slider-compact::-webkit-slider-thumb {
    background: var(--e17-magenta);
}

.temperature-control-compact.llm-mode .temp-slider-compact::-moz-range-thumb {
    background: var(--e17-magenta);
}

.temperature-control-compact.llm-mode .btn-reset-temp:hover {
    background: rgba(231, 25, 132, 0.20);
    color: var(--e17-magenta);
}

/* Modalità WEB - Ciano */
.temperature-control-compact.web-mode {
    background: rgba(0, 172, 233, 0.10);
    border-color: rgba(0, 172, 233, 0.30);
}

.temperature-control-compact.web-mode:hover {
    background: rgba(0, 172, 233, 0.15);
    border-color: rgba(0, 172, 233, 0.50);
    box-shadow: 0 2px 8px rgba(0, 172, 233, 0.20);
}

.temperature-control-compact.web-mode .temp-value-compact {
    background: var(--e17-cyan);
}

.temperature-control-compact.web-mode .temp-slider-compact {
    background: linear-gradient(to right, #e2e8f0 0%, var(--e17-cyan) 100%);
}

.temperature-control-compact.web-mode .temp-slider-compact::-webkit-slider-thumb {
    background: var(--e17-cyan);
}

.temperature-control-compact.web-mode .temp-slider-compact::-moz-range-thumb {
    background: var(--e17-cyan);
}

.temperature-control-compact.web-mode .btn-reset-temp:hover {
    background: rgba(0, 172, 233, 0.20);
    color: var(--e17-cyan);
}

/* Dark Mode Support */
body.dark-mode .temperature-control-compact {
    background: rgba(113, 203, 244, 0.15);
    border-color: rgba(113, 203, 244, 0.4);
}

body.dark-mode .temperature-control-compact:hover {
    background: rgba(113, 203, 244, 0.25);
    border-color: rgba(113, 203, 244, 0.6);
}

body.dark-mode .temp-mode-label {
    color: var(--color-text);
}

body.dark-mode .btn-reset-temp {
    color: var(--color-text-light);
}

body.dark-mode .temperature-control-compact.rag-mode {
    background: rgba(72, 187, 120, 0.15);
    border-color: rgba(72, 187, 120, 0.4);
}

body.dark-mode .temperature-control-compact.llm-mode {
    background: rgba(255, 107, 107, 0.15);
    border-color: rgba(255, 107, 107, 0.4);
}

body.dark-mode .temperature-control-compact.web-mode {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.40);
}

/* Responsive Design */
@media (max-width: 768px) {
    .temperature-control-compact {
        min-width: 160px;
        gap: 4px;
        padding: 6px 8px;
    }
    
    .temp-mode-label {
        font-size: 11px;
        min-width: 28px;
    }
    
    .temp-value-compact {
        font-size: 10px;
        min-width: 28px;
    }
    
    .temp-icon {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .temperature-control-compact {
        min-width: 140px;
        gap: 3px;
        padding: 4px 6px;
    }
    
    .temp-mode-label {
        font-size: 10px;
        min-width: 24px;
    }
    
    .temp-value-compact {
        font-size: 9px;
        min-width: 24px;
        padding: 1px 4px;
    }
    
    .temp-icon {
        font-size: 11px;
    }
    
    .btn-reset-temp {
        font-size: 10px;
    }
}

/* Forza coordinamento colore area domanda in base allo stato del pulsante modalità */
.input-section .input-group #modeToggleBtn.llm-mode ~ #userInput { background: var(--grad-chat) !important; }
.input-section .input-group #modeToggleBtn.web-mode ~ #userInput { background: var(--grad-web) !important; }
.input-section .input-group #modeToggleBtn:not(.llm-mode):not(.web-mode) ~ #userInput { background: var(--grad-docs) !important; }

/* Bottoni modalità e opzioni avanzate con stesso sfondo per modalità */
#modeToggleBtn { background: var(--grad-docs) !important; }
body.mode-docs #modeToggleBtn { background: var(--grad-docs) !important; }
body.mode-chat #modeToggleBtn { background: var(--grad-chat) !important; }
body.mode-web  #modeToggleBtn { background: var(--grad-web)  !important; }

/* Seconda riga modello nel bottone modalità */
.mode-model { display: block; font-size: inherit; font-weight: inherit; color: inherit; opacity: 1; }

#filtersToggleBtn { background: var(--grad-docs) !important; }
body.mode-docs #filtersToggleBtn { background: var(--grad-docs) !important; }
body.mode-chat #filtersToggleBtn { background: var(--grad-chat) !important; }
body.mode-web  #filtersToggleBtn { background: var(--grad-web)  !important; }

/* Bordi coerenti */
body.mode-docs #modeToggleBtn, body.mode-docs #filtersToggleBtn { border-color: rgba(16,185,129,0.35) !important; }
body.mode-chat #modeToggleBtn, body.mode-chat #filtersToggleBtn { border-color: rgba(190,24,93,0.35) !important; }
body.mode-web  #modeToggleBtn, body.mode-web  #filtersToggleBtn { border-color: rgba(6,182,212,0.35) !important; }

/* Bottone Carica documento inline */
.upload-inline-btn {
    border-radius: 0;
    border: 1px solid var(--color-border);
    border-left: none;
    background: var(--grad-docs) !important;
    color: var(--color-text);
    white-space: nowrap;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    min-width: 60px;
    line-height: 1;
}
body.mode-chat .upload-inline-btn { background: var(--grad-chat) !important; border-color: rgba(190,24,93,0.35) !important; }
body.mode-web  .upload-inline-btn { background: var(--grad-web)  !important; border-color: rgba(6,182,212,0.35) !important; }
body.mode-docs .upload-inline-btn { background: var(--grad-docs) !important; border-color: rgba(16,185,129,0.35) !important; }

@media (max-width: 768px) {
  .upload-inline-btn .upload-text-inline { display: inline; }
}
@media (max-width: 480px) {
  .upload-inline-btn .upload-text-inline { display: inline; }
}

.upload-inline-btn .upload-icon { font-size: 16px; line-height: 1; margin-bottom: 2px; }
.upload-inline-btn .upload-text { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; line-height: 1; margin-top: 1px; }

.upload-inline-btn:hover { background: var(--color-azzurro-light); border-color: var(--color-azzurro); color: var(--color-azzurro-dark); z-index: 2; }
.upload-inline-btn:focus { z-index: 3; border-color: var(--color-azzurro); box-shadow: 0 0 0 2px rgba(113,203,244,0.2); }

.mode-toggle-btn-inline .mode-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mode-toggle-btn-inline .mode-fav { width: 32px; height: auto; border-radius: 0; display: inline-block; }
.mode-toggle-btn-inline .mode-text {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    line-height: 1.05;
    margin-top: 0;
    }

/* Favicon per modalità */
body.mode-docs #modeToggleBtn .mode-fav { content: url('/chat-static/images/avatar-green.svg'); }
body.mode-chat #modeToggleBtn .mode-fav { content: url('/chat-static/images/avatar-magenta.svg'); }
body.mode-web  #modeToggleBtn .mode-fav { content: url('/chat-static/images/avatar-cyan.svg'); }

@media (max-width: 768px) {
    .mode-toggle-btn-inline {
        padding: 6px 8px;
        min-width: 45px;
    }
    .mode-toggle-btn-inline .mode-text { display: inline; }
    /* Navbar mobile: mostra solo avatar (nascondi nome) e compatta bottoni */
    #navUserNameLabel { display: none !important; }
    .navbar .btn.me-2 { margin-right: .14rem !important; }
    .navbar .btn.btn-sm { padding: .14rem .30rem !important; line-height: 1.1 !important; }
    .navbar .nav-text { display: none !important; }
    #navUserName { margin-right: .25rem !important; }
    /* Evita a capo: tieni i bottoni su una riga e restringi version/brand */
    .navbar .container-fluid > .ms-auto { display:flex; flex-wrap: nowrap !important; gap: .14rem !important; }
    .navbar .container-fluid > .ms-auto > * { flex: 0 0 auto; }
    .navbar .brand-text { font-size: .95rem !important; }
    #chatVersionLabel { display: none !important; }
}

/* Compattazione ulteriore su schermi piccoli */
@media (max-width: 576px) {
    .navbar .btn.me-2 { margin-right: .2rem !important; }
    .navbar .btn.btn-sm { padding: .18rem .35rem !important; line-height: 1.1 !important; }
    .navbar .nav-text { display: none !important; }
    .navbar .btn .nav-icon { margin-right: 0 !important; }
}

/* Compattazione estrema per telefoni molto stretti */
@media (max-width: 420px) {
    .navbar .btn.me-2 { margin-right: .16rem !important; }
    .navbar .btn.btn-sm { padding: .14rem .28rem !important; }
}

/* Leggero ingrandimento bottoni navbar su telefoni ~1080px (viewport medio-alto) */
@media (min-width: 900px) and (max-width: 1200px) {
  .navbar .btn.btn-sm { padding: .32rem .60rem !important; }
  .navbar .btn.me-2 { margin-right: .30rem !important; }
}

/* Icone favicon nei messaggi e nel welcome */
.msg-fav { width: 28px; height: auto; vertical-align: middle; margin-right: 6px; border-radius: 0; }
/* Dark theme: no extra background for assistant favicon */
body.dark-mode .assistant-message .msg-fav { background: transparent; padding: 0; }
.welcome-fav { width: 28px; height: auto; vertical-align: middle; margin-right: 6px; border-radius: 0; }
/* Allinea gli avatar del welcome al testo come le icone dei messaggi */
.assistant-message .welcome-fav { position: relative; top: 2px; }
.assistant-message .welcome-line { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.assistant-message .welcome-text { display: inline-block; vertical-align: middle; line-height: 1.3; }
.assistant-message .welcome-quick-start-btn { font-weight: 600; text-align: left; }
/* Bottoni suggerimenti - Magenta per AI */
.assistant-message .welcome-quick-start-btn.mode-magenta { color: var(--e17-magenta); border-color: var(--e17-magenta); }
.assistant-message .welcome-quick-start-btn.mode-magenta:hover { background: var(--e17-magenta); color: #fff; }

/* Bottoni suggerimenti - Verde per RAG (tema LIGHT: verde scuro per contrasto) */
.assistant-message .welcome-quick-start-btn.mode-green { color: var(--e17-green-ui); border-color: var(--e17-green-ui); }
.assistant-message .welcome-quick-start-btn.mode-green:hover { background: var(--e17-green-ui); color: #fff; }

/* Bottoni suggerimenti - Cyan per WEB (entrambi i temi) */
.assistant-message .welcome-quick-start-btn.mode-cyan { color: var(--e17-cyan); border-color: var(--e17-cyan); }
.assistant-message .welcome-quick-start-btn.mode-cyan:hover { background: var(--e17-cyan); color: #fff; }

/* Dark mode: torna al verde originale più chiaro e luminoso per RAG */
body.dark-mode .assistant-message .welcome-quick-start-btn.mode-green { color: var(--e17-green-soft); border-color: var(--e17-green-soft); }
body.dark-mode .assistant-message .welcome-quick-start-btn.mode-green:hover { background: var(--e17-green-soft); color: #fff; }

/* Dark mode: cyan rimane invariato (già ben visibile) */
body.dark-mode .assistant-message .welcome-quick-start-btn.mode-cyan { color: var(--e17-cyan); border-color: var(--e17-cyan); }
body.dark-mode .assistant-message .welcome-quick-start-btn.mode-cyan:hover { background: var(--e17-cyan); color: #fff; }

.mode-toggle-btn-inline .mode-fav { display: none; }

/* Stili per liste nella sezione comandi */
#cmdListDocsOutput ul, #cmdListDocsOutput ol {
    margin: 2px 0;
    padding-left: 20px;
}

#cmdListDocsOutput li {
    margin: 0;
    line-height: 1.1;
    padding: 0;
}

#cmdListDocsOutput hr {
    margin: 12px 0;
    border: none;
    border-top: 1px solid #ddd;
}

body.dark-mode #cmdListDocsOutput hr {
    border-top-color: #555;
}

/* Stili per bottone Cancella filtri - usa gli stessi colori del bottone Chiudi */
#cmdClearFiltersBtn {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #ffffff !important;
}

#cmdClearFiltersBtn:hover {
    background-color: #5a6268 !important;
    border-color: #545b62 !important;
    color: #ffffff !important;
}

body.dark-mode #cmdClearFiltersBtn {
    background-color: #495057 !important;
    border-color: #495057 !important;
    color: #ffffff !important;
}

body.dark-mode #cmdClearFiltersBtn:hover {
    background-color: #3d4043 !important;
    border-color: #373a3d !important;
    color: #ffffff !important;
}

.assistant-message .welcome-quickstart-group { display: block; margin-top: 8px; }

/* Uniforma spaziatura welcome: bottoni modalità, suggeriti e personalizzati */
.assistant-message .welcome-quickstart-group { margin-top: 6px !important; margin-bottom: 0 !important; }
.assistant-message .welcome-quick-start-btn { margin-right: 3px !important; margin-bottom: 3px !important; }
.welcome-mode-item { margin-bottom: 6px !important; }

/* Followup post-risposta: compattazione spazi bottoni e sezioni */
.assistant-message .followups-wrap { margin-top: 6px !important; padding-top: 4px !important; }
.assistant-message .followups-wrap .text-muted { margin-bottom: 2px !important; }
.assistant-message .followups-wrap .welcome-quick-start-btn { margin-right: 3px !important; margin-bottom: 3px !important; }

/* Avatar badge per modalità */
.message-avatar { position: relative; display: inline-flex; flex-direction: column; align-items: center; }
.message-avatar .mode-badge { position: static; margin-top: 2px; background: transparent; border: 0; box-shadow: none; font-size: 12px; width: auto; height: auto; }
body.dark-mode .message-avatar .mode-badge { background: transparent; border: 0; box-shadow: none; }

.assistant-message .welcome-line:last-of-type { margin-bottom: 4px; }

.assistant-message .welcome-quickstart-group { display: block; margin-top: 6px; }

.assistant-message .welcome-line { display: flex; align-items: center; gap: 8px; margin: 8px 0 6px; }
.assistant-message .welcome-line:last-of-type { margin-bottom: 4px; }
.assistant-message .welcome-text { display: inline-block; vertical-align: middle; line-height: 1.3; }
.assistant-message .welcome-quickstart-group { display: block; margin-top: 6px; }

.assistant-message .welcome-line { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; padding-bottom: 8px; }
.assistant-message .welcome-line:last-of-type { margin-bottom: 0; padding-bottom: 0; }
.assistant-message .welcome-text { display: inline-block; vertical-align: middle; line-height: 1.3; }
.assistant-message .welcome-quickstart-group { display: block; margin-top: 6px; }

.assistant-message .welcome-line { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding-bottom: 8px; }
.assistant-message .welcome-line:last-of-type { margin-bottom: 0; padding-bottom: 0; }
.assistant-message .welcome-text { display: inline-block; vertical-align: middle; line-height: 1.3; }
.assistant-message .welcome-quickstart-group { display: block; margin-top: 8px; }

/* Bottoni modalità nel welcome message - usano classi esistenti dei bottoni domande */

/* Prompt personalizzati - grigio outline con buon contrasto */
.welcome-quick-start-btn.btn-outline-secondary {
    border-width: 1.5px;
    border-color: #6c757d;
    color: #495057;
    background: transparent;
}

.welcome-quick-start-btn.btn-outline-secondary:hover {
    background: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

/* Dark mode: bordo e testo più chiari per visibilità */
body.dark-mode .welcome-quick-start-btn.btn-outline-secondary {
    border-color: #adb5bd;
    color: #ced4da;
}

body.dark-mode .welcome-quick-start-btn.btn-outline-secondary:hover {
    background: #6c757d;
    border-color: #adb5bd;
    color: #fff;
}

.doc-banner{display:flex;gap:10px;align-items:center;padding:10px 12px;border-left:6px solid #F59F00;background:#FFF7CC;color:#1a1f2e;box-shadow:0 6px 18px rgba(0,0,0,.15);border-radius:8px}
.doc-banner--sticky{position:sticky;top:60px;z-index:20;margin:8px 0}
.doc-banner__file{font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:65vw}
.doc-banner__hint{opacity:.95;font-weight:600}
.doc-banner__close{margin-left:auto;background:#E03131;color:#fff;border:0;border-radius:6px;width:28px;height:28px;font-weight:700;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
.doc-banner__close:hover{filter:brightness(1.05)}
/* In dark mode manteniamo il banner chiaro per massima evidenza */
/* Mantieni sticky giallo anche in dark mode */
body.dark-mode .doc-banner{background:#FFF7CC;color:#1a1f2e;border-left-color:#F59F00;box-shadow:0 6px 18px rgba(0,0,0,.35)}
body.dark-mode .doc-banner__close{background:#C92A2A}

/* Mobile tweaks */
@media (max-width: 576px){
  .doc-banner--sticky{top:56px; margin:6px 0;}
  .doc-banner__file{max-width:55vw}
  .doc-banner__close{width:26px;height:26px;font-size:14px}
}

/* ===== Toolbar Filtra documenti: bottoni operativi ===== */
.filter-actions-toolbar .btn-secondary:enabled{
  background-color:#6c757d; border-color:#6c757d; color:#fff;
}
.filter-actions-toolbar .btn-secondary:enabled:hover,
.filter-actions-toolbar .btn-secondary:enabled:focus{
  background-color:#5c636a; border-color:#5c636a; color:#fff;
}
.filter-actions-toolbar .btn-secondary:disabled,
.filter-actions-toolbar .btn-secondary[disabled]{
  background-color:#e9ecef; border-color:#e9ecef; color:#6c757d; opacity:1;
}
body.dark-mode .filter-actions-toolbar .btn-secondary:enabled{
  background-color:#495057; border-color:#495057; color:#fff;
}
body.dark-mode .filter-actions-toolbar .btn-secondary:enabled:hover,
body.dark-mode .filter-actions-toolbar .btn-secondary:enabled:focus{
  background-color:#3f464c; border-color:#3f464c; color:#fff;
}
body.dark-mode .filter-actions-toolbar .btn-secondary:disabled,
body.dark-mode .filter-actions-toolbar .btn-secondary[disabled]{
  background-color:#343a40; border-color:#343a40; color:#adb5bd; opacity:1;
}

/* Outline stile come quick actions per bottoni attivi Apri (ciano) e Analizza (verde) */
.filter-actions-toolbar .welcome-quick-start-btn { border-width:1.5px; }
.filter-actions-toolbar .welcome-quick-start-btn.mode-cyan {
  background: transparent; color: var(--e17-cyan); border-color: var(--e17-cyan);
}
.filter-actions-toolbar .welcome-quick-start-btn.mode-cyan:hover,
.filter-actions-toolbar .welcome-quick-start-btn.mode-cyan:focus {
  background: var(--e17-cyan); color:#fff; border-color: var(--e17-cyan);
}
.filter-actions-toolbar .welcome-quick-start-btn.mode-magenta {
  background: transparent; color: var(--e17-magenta); border-color: var(--e17-magenta);
}
.filter-actions-toolbar .welcome-quick-start-btn.mode-magenta:hover,
.filter-actions-toolbar .welcome-quick-start-btn.mode-magenta:focus {
  background: var(--e17-magenta); color:#fff; border-color: var(--e17-magenta);
}
.filter-actions-toolbar .welcome-quick-start-btn.mode-green {
  background: transparent; color: var(--e17-green-ui); border-color: var(--e17-green-ui);
}
.filter-actions-toolbar .welcome-quick-start-btn.mode-green:hover,
.filter-actions-toolbar .welcome-quick-start-btn.mode-green:focus {
  background: var(--e17-green-ui); color:#fff; border-color: var(--e17-green-ui);
}
body.dark-mode .filter-actions-toolbar .welcome-quick-start-btn.mode-green {
  background: transparent; color: var(--e17-green-soft); border-color: var(--e17-green-soft);
}
body.dark-mode .filter-actions-toolbar .welcome-quick-start-btn.mode-green:hover,
body.dark-mode .filter-actions-toolbar .welcome-quick-start-btn.mode-green:focus {
  background: var(--e17-green-soft); color:#fff; border-color: var(--e17-green-soft);
}
body.dark-mode .filter-actions-toolbar .welcome-quick-start-btn.mode-cyan {
  background: transparent; color: var(--e17-cyan); border-color: var(--e17-cyan);
}
body.dark-mode .filter-actions-toolbar .welcome-quick-start-btn.mode-cyan:hover,
body.dark-mode .filter-actions-toolbar .welcome-quick-start-btn.mode-cyan:focus {
  background: var(--e17-cyan); color:#fff; border-color: var(--e17-cyan);
}
/* Variante outline per bottoni azione (Apri/Analizza) quando abilitati */
.filter-actions-toolbar .btn-action-outline.btn-secondary:enabled{
  background-color: #ffffff;
  color: #6c757d;
  border-color: #6c757d;
}
.filter-actions-toolbar .btn-action-outline.btn-secondary:enabled:hover,
.filter-actions-toolbar .btn-action-outline.btn-secondary:enabled:focus{
  background-color: #f8f9fa;
  color: #5c636a;
  border-color: #5c636a;
}
body.dark-mode .filter-actions-toolbar .btn-action-outline.btn-secondary:enabled{
  background-color: #212529;
  color: #e9ecef;
  border-color: #495057;
}
body.dark-mode .filter-actions-toolbar .btn-action-outline.btn-secondary:enabled:hover,
body.dark-mode .filter-actions-toolbar .btn-action-outline.btn-secondary:enabled:focus{
  background-color: #2a3036;
  color: #ffffff;
  border-color: #3f464c;
}

/* Stile outline secondario coerente con bottoni rapidi (Totale/Buste/Citazioni) */
.filter-actions-toolbar .btn-outline-secondary{
  border-width: 1.5px;
  border-color: #6c757d;
  color: #6c757d;
  background: transparent;
}
.filter-actions-toolbar .btn-outline-secondary:hover,
.filter-actions-toolbar .btn-outline-secondary:focus{
  background: #6c757d;
  border-color: #6c757d;
  color: #fff;
}
body.dark-mode .filter-actions-toolbar .btn-outline-secondary{
  border-color: #adb5bd;
  color: #ced4da;
  background: transparent;
}
body.dark-mode .filter-actions-toolbar .btn-outline-secondary:hover,
body.dark-mode .filter-actions-toolbar .btn-outline-secondary:focus{
  background: #6c757d;
  border-color: #adb5bd;
  color: #fff;
}
/* Bottoni "Seleziona tutti" / "Deseleziona tutti" con bordo visibile (light+dark) */
.filter-actions-toolbar .btn-action-outline{
  background-color: transparent;
  border: 1px solid #6c757d;
  color: #6c757d;
}
.filter-actions-toolbar .btn-action-outline:hover,
.filter-actions-toolbar .btn-action-outline:focus{
  background-color: #f8f9fa !important;
  color: #5c636a !important;
  border-color: #5c636a !important;
}
.filter-actions-toolbar .btn-action-outline:disabled,
.filter-actions-toolbar .btn-action-outline[disabled]{
  background: transparent;
  border-color: #ced4da;
  color: #adb5bd;
  opacity: 1;
}
body.dark-mode .filter-actions-toolbar .btn-action-outline{
  background-color: transparent;
  border: 1px solid #8a93a0;
  color: #cbd5e1;
}
body.dark-mode .filter-actions-toolbar .btn-action-outline:hover,
body.dark-mode .filter-actions-toolbar .btn-action-outline:focus{
  background-color: #1b2230;
  color: #e5eaf1;
  border-color: #a4adba;
}
body.dark-mode .filter-actions-toolbar .btn-action-outline:disabled,
body.dark-mode .filter-actions-toolbar .btn-action-outline[disabled]{
  background: transparent;
  border-color: #3b4654;
  color: #7a8596;
}

/* Outline specifici per Apri/Analizza (coerenti con File elaborati) */
.filter-actions-toolbar .btn-open-outline{
  background: transparent;
  border: 1px solid var(--e17-cyan);
  color: var(--e17-cyan);
}
.filter-actions-toolbar .btn-open-outline:hover,
.filter-actions-toolbar .btn-open-outline:focus{ background: rgba(0,172,233,.08); }
.filter-actions-toolbar .btn-open-outline:disabled,
.filter-actions-toolbar .btn-open-outline[disabled]{
  border-color:#ced4da; color:#adb5bd; background:transparent; opacity:1;
}
.filter-actions-toolbar .btn-analyze-outline{
  background: transparent;
  border: 1px solid var(--e17-green-soft);
  color: var(--e17-green-soft);
}
.filter-actions-toolbar .btn-analyze-outline:hover,
.filter-actions-toolbar .btn-analyze-outline:focus{ background: rgba(92,195,26,.10); }
.filter-actions-toolbar .btn-analyze-outline:disabled,
.filter-actions-toolbar .btn-analyze-outline[disabled]{
  border-color:#ced4da; color:#adb5bd; background:transparent; opacity:1;
}
body.dark-mode .filter-actions-toolbar .btn-open-outline{ border-color:#7dd3fc; color:#a5e9ff; }
body.dark-mode .filter-actions-toolbar .btn-open-outline:hover,
body.dark-mode .filter-actions-toolbar .btn-open-outline:focus{ background: rgba(125,211,252,.12); }
body.dark-mode .filter-actions-toolbar .btn-open-outline:disabled,
body.dark-mode .filter-actions-toolbar .btn-open-outline[disabled]{ border-color:#3b4654; color:#7a8596; }
body.dark-mode .filter-actions-toolbar .btn-analyze-outline{ border-color:#9ee37d; color:#b8f29c; }
body.dark-mode .filter-actions-toolbar .btn-analyze-outline:hover,
body.dark-mode .filter-actions-toolbar .btn-analyze-outline:focus{ background: rgba(158,227,125,.12); }
body.dark-mode .filter-actions-toolbar .btn-analyze-outline:disabled,
body.dark-mode .filter-actions-toolbar .btn-analyze-outline[disabled]{ border-color:#3b4a39; color:#7f8d7c; }
/* Dark theme: history offcanvas styling */
body.dark-mode #historyPanel .offcanvas-header{background:#0f1720;border-bottom:1px solid #334155}
body.dark-mode #historyPanel .offcanvas-title{color:#e2e8f0}
body.dark-mode #historyPanel .list-group-item{background:#1f2730;color:#e2e8f0;border-color:#334155}
body.dark-mode #historyPanel #historyDetail{background:#1f2730;color:#e2e8f0;border-color:#334155}
body.dark-mode #historyPanel .badge{background:#2b3440;color:#cbd5e1;border:1px solid #3b4654}
body.dark-mode #historyPanel .input-group-text{background:#2b3440;color:#cbd5e1;border-color:#3b4654}
body.dark-mode #historyPanel .form-control{background:#1f2730;color:#e2e8f0;border-color:#334155}
body.dark-mode #historyPanel .form-check-label{color:#cbd5e1}

/* History offcanvas compact spacing */
#historyPanel .list-group-item { padding: 10px 12px; border-radius: 8px; }
#historyPanel .list-group-item .badge { font-size: .75rem; font-weight: 600; }
#historyPanel .btn-sm { padding: .25rem .55rem; line-height: 1.2; }

/* Dark-mode improvements for history offcanvas */
body.dark-mode #historyPanel .list-group-item:hover { background:#26303b; }
body.dark-mode #historyPanel .btn-outline-secondary { color:#e2e8f0; border-color:#475569; background:transparent; }
body.dark-mode #historyPanel .btn-outline-secondary:hover { background:#334155; color:#e2e8f0; border-color:#64748b; }
body.dark-mode #historyPanel .btn-warning { background:#f59f00; border-color:#f59f00; color:#1f2937; }
body.dark-mode #historyPanel .btn-warning.active { filter:brightness(1.05); }

/* Strong dark-mode overrides for History offcanvas */
body.dark-mode #historyPanel{background:#0b1220;}
body.dark-mode #historyPanel.offcanvas{background:#0b1220;}
body.dark-mode #historyPanel .offcanvas-body{background:#0b1220;}
body.dark-mode #historyPanel .list-group{background:transparent;}
body.dark-mode #historyPanel #historyDetail{background:#0f1720;border-color:#223043;color:#e2e8f0}
body.dark-mode #historyPanel .form-control::placeholder{color:#94a3b8}

/* Dark-mode: make offcanvas close button visible in history panel */
body.dark-mode #historyPanel .btn-close{filter: invert(1) grayscale(1) brightness(180%); opacity: .9;}
body.dark-mode #historyPanel .btn-close:hover{opacity:1;}

/* Dark theme: processed offcanvas styling */
body.dark-mode #processedPanel .offcanvas-header{background:#0f1720;border-bottom:1px solid #334155}
body.dark-mode #processedPanel .offcanvas-title{color:#e2e8f0}
body.dark-mode #processedPanel .list-group-item{background:#1f2730;color:#e2e8f0;border-color:#334155}
body.dark-mode #processedPanel .badge{background:#2b3440;color:#cbd5e1;border:1px solid #3b4654}
body.dark-mode #processedPanel .input-group-text{background:#2b3440;color:#cbd5e1;border-color:#3b4654}
body.dark-mode #processedPanel .form-select, body.dark-mode #processedPanel .form-control{background:#1f2730;color:#e2e8f0;border-color:#334155}
body.dark-mode #processedPanel{background:#0b1220;}
body.dark-mode #processedPanel .offcanvas-body{background:#0b1220;}
body.dark-mode #processedPanel .btn-close{filter: invert(1) grayscale(1) brightness(180%); opacity:.9}
body.dark-mode #processedPanel .btn-close:hover{opacity:1}

/* Spaziatura compatta per processed */
#processedPanel .list-group-item { padding: 10px 12px; border-radius: 8px; }
#processedPanel .btn-sm { padding: .25rem .55rem; line-height: 1.2; }

/* Bottoni azione in File elaborati: bordi evidenti come in Cronologia (Stampa) */
#processedPanel .btn-action-outline {
  background-color: transparent;
  border: 1px solid #6c757d;
  color: #6c757d;
}
#processedPanel .btn-action-outline:hover,
#processedPanel .btn-action-outline:focus {
  background-color: #f8f9fa;
  color: #5c636a;
  border-color: #5c636a;
}
/* Varianti cromatiche per Apri/Analizza coerenti con ciano/verde */
#processedPanel .btn-open-outline {
  background-color: transparent;
  border: 1px solid var(--e17-cyan);
  color: var(--e17-cyan);
}
#processedPanel .btn-open-outline:hover,
#processedPanel .btn-open-outline:focus { background-color: rgba(0,172,233,.08); }

#processedPanel .btn-analyze-outline {
  background-color: transparent;
  border: 1px solid var(--e17-green-soft);
  color: var(--e17-green-soft);
}
#processedPanel .btn-analyze-outline:hover,
#processedPanel .btn-analyze-outline:focus { background-color: rgba(92,195,26,.10); }

/* Dark mode variants */
body.dark-mode #processedPanel .btn-action-outline { border-color:#8a93a0; color:#cbd5e1; }
body.dark-mode #processedPanel .btn-action-outline:hover,
body.dark-mode #processedPanel .btn-action-outline:focus { background:#1b2230; color:#e5eaf1; border-color:#a4adba; }
body.dark-mode #processedPanel .btn-open-outline { border-color:#7dd3fc; color:#a5e9ff; }
body.dark-mode #processedPanel .btn-open-outline:hover,
body.dark-mode #processedPanel .btn-open-outline:focus { background:rgba(125,211,252,.12); }
body.dark-mode #processedPanel .btn-analyze-outline { border-color:#9ee37d; color:#b8f29c; }
body.dark-mode #processedPanel .btn-analyze-outline:hover,
body.dark-mode #processedPanel .btn-analyze-outline:focus { background:rgba(158,227,125,.12); }