body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0f172a;
    color: #f8fafc;
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

/* Layout principale */
.app-container {
    display: flex;
    height: 100vh;
}

/* Barra laterale sessioni */
.sessions-sidebar {
    width: 280px;
    background: #1e293b;
    border-right: 1px solid rgba(59, 130, 246, 0.2);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.sessions-sidebar.hidden {
    width: 0;
    overflow: hidden;
    border-right: none;
}

.sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.sessions-header h3 {
    margin: 0;
    color: #3b82f6;
    font-size: 1rem;
    font-weight: 600;
}

.sessions-toggle-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

.sessions-toggle-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.sessions-actions {
    padding: 1rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    margin: 0.25rem 0;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.session-item:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.session-item.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

.session-info {
    flex: 1;
    min-width: 0;
}

.session-name {
    font-weight: 500;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-meta {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    gap: 0.5rem;
}

.session-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.session-item:hover .session-actions {
    opacity: 1;
}

.session-action-btn {
    background: none;
    border: none;
    color: #64748b;
    padding: 4px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.session-action-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.session-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Pulsante per mostrare sessioni */
.show-sessions-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(59, 130, 246, 0.9);
    border: none;
    color: white;
    padding: 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    z-index: 150;
    backdrop-filter: blur(10px);
}

.show-sessions-btn:hover {
    background: #3b82f6;
    transform: scale(1.05);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Layout diviso */
.split-container {
    display: flex;
    height: 100vh;
    position: relative;
    /* necessario per posizionare il toggle rispetto al centro */
}

.left-panel {
    width: 50%;
    height: 100%;
    background: #0f172a;
    border-right: 1px solid rgba(59, 130, 246, 0.2);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.left-panel.minimized {
    width: 60px;
}

.left-panel.minimized .chat-container {
    opacity: 0;
    pointer-events: none;
}

.right-panel {
    width: 50%;
    height: 100%;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.right-panel.expanded {
    width: calc(100% - 60px);
}

/* Pulsante toggle chat */
#chat-toggle {
    display: none;
}

.chat-toggle-btn {
    position: absolute;
    top: 50%;
    left: 100%;
    /* il bordo sinistro è allineato con il bordo destro del pannello */
    transform: translateY(-50%);
    width: 10px !important;
    /* 5px più stretto */
    min-width: 10px;
    max-width: 10px;
    height: 40px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    border: none;
    border-radius: 0 3px 3px 0;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow:
        1px 0 6px rgba(59, 130, 246, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    padding: 0;
    overflow: hidden;
}

.chat-toggle-btn:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #8b5cf6 100%);
    transform: translateY(-50%) scale(1.05);
    box-shadow:
        1px 0 8px rgba(59, 130, 246, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

.chat-toggle-btn .toggle-icon {
    transition: transform 0.3s ease;
    user-select: none;
}

.left-panel.minimized .chat-toggle-btn .toggle-icon {
    transform: rotate(180deg);
}

.excalidraw-container {
    flex: 1;
    height: 100%;
    background: #0f172a;
    transition: all 0.3s ease;
}

.chat-container {
    width: 100%;
    height: 100%;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    background: #0f172a;
}

/* Scrollbar personalizzata */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3b82f6, #6366f1);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #60a5fa, #8b5cf6);
}

.message {
    padding: 1rem 1.5rem;
    border-radius: 3px;
    max-width: 85%;
    line-height: 1.6;
    position: relative;
    backdrop-filter: blur(10px);
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    box-shadow:
        0 8px 32px rgba(59, 130, 246, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

.message.user::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: #6366f1;
}

.message.assistant {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(51, 65, 85, 0.9) 0%, rgba(71, 85, 105, 0.8) 100%);
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.message.assistant::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: rgba(71, 85, 105, 0.8);
}

.chat-input-area {
    padding: 2rem;
    display: flex;
    gap: 1rem;
    background: #0f172a;
    border-top: 1px solid rgba(59, 130, 246, 0.2);
    position: relative;
}

.chat-input-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.6), transparent);
}

input[type="text"] {
    flex: 1;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #f8fafc;
    padding: 1rem 1.5rem;
    border-radius: 3px;
    outline: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

input[type="text"]:focus {
    border-color: #3b82f6;
    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.1),
        0 8px 32px rgba(59, 130, 246, 0.2);
    background: rgba(30, 41, 59, 0.8);
}

input[type="text"]::placeholder {
    color: #94a3b8;
}

button {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow:
        0 8px 32px rgba(59, 130, 246, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

button:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #8b5cf6 100%);
    transform: translateY(-2px);
    box-shadow:
        0 12px 40px rgba(59, 130, 246, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: translateY(0);
}

/* Chart Styles */
.chart-container {
    margin: 1.5rem 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
    padding: 1.5rem;
    border-radius: 3px;
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(59, 130, 246, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
    display: flex;
    justify-content: center;
    backdrop-filter: blur(20px);
    position: relative;
    transition: all 0.3s ease;
}

.chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
    opacity: 0.6;
}

.chart-container:hover {
    transform: translateY(-2px);
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(59, 130, 246, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.chart-img {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
    transition: all 0.3s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.chart-img:hover {
    transform: scale(1.02);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
}

.chart-img[draggable="true"] {
    user-select: none;
    -webkit-user-drag: element;
    cursor: grab;
}

.chart-img[draggable="true"]:active {
    cursor: grabbing;
}

/* Stile per l'area di drop */
.excalidraw-container {
    transition: all 0.3s ease;
}

.excalidraw-container.drag-over {
    opacity: 0.8;
    background: rgba(59, 130, 246, 0.05);
    backdrop-filter: blur(5px);
}

.message-content {
    word-wrap: break-word;
}

/* === STILI MARKDOWN NEI MESSAGGI === */

/* Headers nei messaggi */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 {
    font-size: 1.5rem;
    color: #3b82f6;
    border-bottom: 2px solid rgba(59, 130, 246, 0.3);
    padding-bottom: 0.5rem;
}

.message-content h2 {
    font-size: 1.3rem;
    color: #60a5fa;
}

.message-content h3 {
    font-size: 1.1rem;
    color: #93c5fd;
}

/* Bold e Italic */
.message-content strong {
    font-weight: 700;
    color: #f8fafc;
}

.message-content em {
    font-style: italic;
    color: #cbd5e1;
}

/* Liste */
.message-content ul,
.message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin: 0.25rem 0;
    line-height: 1.6;
}

.message-content ul {
    list-style-type: disc;
}

.message-content ul li::marker {
    color: #3b82f6;
}

/* Code inline */
.message-content code {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Blocchi code */
.message-content pre {
    background: #1e293b;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 3px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.message-content pre code {
    background: none;
    color: #e2e8f0;
    padding: 0;
    border: none;
    font-size: 0.85rem;
    line-height: 1.5;
    display: block;
}

/* Blockquotes */
.message-content blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #cbd5e1;
    font-style: italic;
    background: rgba(59, 130, 246, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 0 3px 3px 0;
}

/* Links */
.message-content a {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.message-content a:hover {
    color: #93c5fd;
    border-bottom-color: #93c5fd;
}

/* Paragraphs spacing */
.message-content p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

/* Miglioramenti generali hi-tech */
* {
    box-sizing: border-box;
}

/* Excalidraw Menu Overrides - Fix per leggibilità */
.excalidraw-container .Modal,
.excalidraw-container .dropdown-menu,
.excalidraw-container [role="dialog"],
.excalidraw-container .popover {
    background: rgba(15, 23, 42, 0.98) !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    backdrop-filter: blur(20px) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6) !important;
}

.excalidraw-container .dropdown-menu-item,
.excalidraw-container .Modal button,
.excalidraw-container .Modal input,
.excalidraw-container .Modal select,
.excalidraw-container .Modal textarea,
.excalidraw-container .dropdown-menu button,
.excalidraw-container [role="menuitem"] {
    background: rgba(15, 23, 42, 0.8) !important;
    color: #f8fafc !important;
    border: 1px solid rgba(59, 130, 246, 0.2) !important;
}

.excalidraw-container .dropdown-menu-item:hover,
.excalidraw-container .Modal button:hover,
.excalidraw-container .dropdown-menu button:hover,
.excalidraw-container [role="menuitem"]:hover {
    background: rgba(59, 130, 246, 0.8) !important;
    color: white !important;
}

.excalidraw-container .Modal h1,
.excalidraw-container .Modal h2,
.excalidraw-container .Modal h3,
.excalidraw-container .Modal label,
.excalidraw-container .Modal span,
.excalidraw-container .Modal div {
    color: #f8fafc !important;
}

.excalidraw-container .Modal input:focus,
.excalidraw-container .Modal select:focus,
.excalidraw-container .Modal textarea:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3) !important;
}

/* Menu hamburger e toolbar */
.excalidraw-container .Island,
.excalidraw-container .App-toolbar {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(59, 130, 246, 0.2) !important;
    backdrop-filter: blur(10px) !important;
}

.excalidraw-container .ToolIcon,
.excalidraw-container .Stack button {
    background: rgba(248, 250, 252, 0.8) !important;
    color: #1e293b !important;
    border: 1px solid rgba(59, 130, 246, 0.1) !important;
}

.excalidraw-container .ToolIcon:hover,
.excalidraw-container .Stack button:hover,
.excalidraw-container .ToolIcon--selected {
    background: rgba(59, 130, 246, 0.8) !important;
    color: white !important;
}

/* Canvas background override per uniformità */
.excalidraw-container .excalidraw {
    --color-surface-lowest: #0f172a !important;
    --color-surface-low: #1e293b !important;
    --color-primary: #3b82f6 !important;
}

/* Effetti di glow per elementi interattivi */
.chart-container,
.message.user,
button {
    position: relative;
}

.chart-container:hover,
.message.user:hover,
button:hover {
    filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.3));
}

/* Rimozione outline per accessibilità ma mantenimento focus visivo */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.chart-container {
    margin: 1rem 0;
    background-color: white;
    padding: 1rem;
    border-radius: 3px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.chart-img {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chart-img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* === LIGHTBOX === */

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* === MAP & VIEW TOGGLE === */

.right-panel {
    position: relative;
    /* Ensure absolute positioning works inside */
}

/* Toggle Button Container */
.view-toggle-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    /* Above Excalidraw and Leaflet */
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #f8fafc;
    padding: 8px 16px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.view-toggle-btn:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.2);
}

.view-toggle-btn .mode-icon {
    font-size: 1.2rem;
}

/* Containers */
.excalidraw-container,
.map-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.maplibregl-ctrl-bottom-right {
    display: none !important;
}

/* Helper classes for toggling */
.active-view {
    opacity: 1;
    visibility: visible;
    z-index: 1;
}

.hidden-view {
    opacity: 0;
    visibility: hidden;
    z-index: 0;
    pointer-events: none;
}

/* Leaflet Overrides for Dark Theme (Optional, maybe for later) */
.leaflet-container {
    background: #0f172a;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(59, 130, 246, 0.9);
    border: none;
    color: white;
    font-size: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.lightbox-close:hover {
    background: #3b82f6;
    transform: rotate(90deg);
}

#lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 3px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.message-content {
    word-wrap: break-word;
}

/* === STILI SISTEMA SESSIONI === */

/* Chat header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    background: rgba(59, 130, 246, 0.05);
    position: relative;
    /* permette di centrare il titolo assolutamente */
    min-height: 56px;
    /* mantiene l'altezza minima dell'header */
}

.chat-header h3 {
    margin: 0;
    color: #3b82f6;
    font-size: 1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    max-width: calc(100% - 160px);
    /* spazio per i pulsanti a destra */
    z-index: 2;
    pointer-events: none;
    /* evita che il titolo blocchi i click sui pulsanti */
}

.chat-header-actions {
    display: flex;
    gap: 8px;
    position: absolute;
    /* posiziona i pulsanti a destra dell'header */
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    /* sopra il titolo */
}

/* Bottone per mostrare le sessioni quando sidebar è nascosta - inline nell'header */
.chat-header .show-sessions-btn {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    font-size: 0.9rem;
    padding: 8px;
    /* lascia che .icon-btn gestisca colori e hover */
    border-radius: 3px;
}

/* Il comportamento hover e colori vengono ereditati da .icon-btn */

@media (max-width: 520px) {
    .chat-header {
        min-height: auto;
    }

    .chat-header h3 {
        position: static;
        left: auto;
        transform: none;
        text-align: left;
        max-width: 100%;
        pointer-events: auto;
        /* permette di selezionare il testo su mobile */
    }

    .chat-header-actions {
        position: static;
        transform: none;
        right: auto;
        top: auto;
        margin-left: auto;
    }

    .chat-header .show-sessions-btn {
        position: static;
        transform: none;
        margin-right: 0.5rem;
    }
}

/* Adattamento per schermi stretti: rendi il titolo e i pulsanti in flow normale */
@media (max-width: 520px) {
    .chat-header {
        min-height: auto;
    }

    .chat-header h3 {
        position: static;
        left: auto;
        transform: none;
        text-align: left;
        max-width: 100%;
        pointer-events: auto;
        /* permette di selezionare il testo su mobile */
    }

    .chat-header-actions {
        position: static;
        transform: none;
        right: auto;
        top: auto;
        margin-left: auto;
    }
}

.icon-btn {
    background: none;
    border: none;
    color: #64748b;
    padding: 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

/* Bottoni generali */
.btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    width: 100%;
    justify-content: center;
}

.btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn.btn-secondary {
    background: #64748b;
}

.btn.btn-secondary:hover {
    background: #475569;
}

.btn.btn-primary {
    background: #3b82f6;
}

.btn.btn-primary:hover {
    background: #2563eb;
}

.icon {
    font-size: 0.8rem;
}

/* Modali */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #1e293b;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 3px;
    padding: 2rem;
    min-width: 400px;
    max-width: 500px;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h3 {
    margin: 0 0 1rem 0;
    color: #3b82f6;
    font-size: 1.25rem;
}

.modal-content input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 3px;
    background: #0f172a;
    color: #f8fafc;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    box-sizing: border-box;
}

.modal-content input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-actions .btn {
    width: auto;
    min-width: 80px;
}

/* Scrollbar personalizzata */
.sessions-list::-webkit-scrollbar {
    width: 6px;
}

.sessions-list::-webkit-scrollbar-track {
    background: transparent;
}

.sessions-list::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 3px;
}

.sessions-list::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.5);
}

/* Status steps (processing pipeline feedback) */
.status-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 12px;
    margin: 2px 0;
    align-self: flex-start;
    max-width: 100%;
    transition: opacity 0.4s ease, max-height 0.4s ease;
}

.status-steps.collapsed {
    opacity: 0.45;
    max-height: 28px;
    overflow: hidden;
}

.status-step {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: #94a3b8;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 12px;
    padding: 2px 10px 2px 6px;
    line-height: 1.4;
    transition: all 0.3s ease;
}

.status-step.active {
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.35);
}

.status-step.done {
    color: #64748b;
}

.step-spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid rgba(59, 130, 246, 0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: stepSpin 0.8s linear infinite;
}

@keyframes stepSpin {
    to { transform: rotate(360deg); }
}

.step-check {
    font-size: 0.65rem;
    color: #22c55e;
    line-height: 1;
}

.step-label {
    white-space: nowrap;
}

.status-step.timeout {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.35);
}

/* Timeout dialog overlay */
.timeout-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.timeout-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.timeout-dialog {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    padding: 2rem 2.5rem;
    text-align: center;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
    max-width: 360px;
}

.timeout-icon {
    margin-bottom: 1rem;
}

.timeout-spinner {
    width: 28px;
    height: 28px;
    border-width: 3px;
    border-color: rgba(245, 158, 11, 0.3);
    border-top-color: #f59e0b;
}

.timeout-text {
    font-size: 0.95rem;
    color: #f8fafc;
    margin-bottom: 0.4rem;
}

.timeout-sub {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 1.25rem;
}

.timeout-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.timeout-actions .btn {
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.timeout-yes {
    background: #3b82f6;
    color: white;
}

.timeout-yes:hover {
    background: #2563eb;
}

.timeout-no {
    background: transparent;
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.3) !important;
}

.timeout-no:hover {
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.5) !important;
}

/* Typing indicator (loading dots) */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.4);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sessions-sidebar {
        position: absolute;
        height: 100%;
        z-index: 200;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    .modal-content {
        min-width: 300px;
        margin: 1rem;
    }
}