/* RESET E BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1a73e8;
    --secondary-color: #34a853;
    --danger-color: #ea4335;
    --warning-color: #fbbc04;
    --bg-dark: #1a1a1a;
    --bg-medium: #2a2a2a;
    --bg-light: #3a3a3a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --success-color: #34a853;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* SCREENS */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for iOS */
    background: var(--bg-dark);
    overflow-y: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* LOGIN */
#loginScreen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.logo {
    font-size: 80px;
    margin-bottom: 20px;
}

.login-container h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.login-container p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.login-container input {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-medium);
    color: var(--text-primary);
    margin-bottom: 15px;
}

.login-container input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* HEADER */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.header-date {
    font-size: 14px;
    color: var(--text-secondary);
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

/* NUOVA DASHBOARD */
.dashboard-new {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 40px;
}

/* CHAT BUTTON PRINCIPALE */
.chat-main-btn {
    width: 100%;
    padding: 25px;
    background: linear-gradient(135deg, var(--primary-color), #1557b0);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
    transition: transform 0.2s;
}

.chat-main-btn:active {
    transform: scale(0.98);
}

.chat-main-btn.nota-rapida-btn {
    background: linear-gradient(135deg, #f97316, #ea580c);
    margin-bottom: 30px;
}

.chat-icon {
    font-size: 48px;
}

.chat-text {
    text-align: left;
    flex: 1;
}

.chat-title {
    font-size: 22px;
    font-weight: 700;
    color: white;
    margin-bottom: 5px;
}

.chat-subtitle {
    font-size: 14px;
    color: rgba(255,255,255,0.8);
}

/* SECTION TITLE */
.section-title {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ACTIONS GRID */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.actions-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.action-card {
    background: var(--bg-medium);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 30px 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.action-card:active {
    transform: scale(0.95);
    background: var(--bg-light);
    border-color: var(--primary-color);
}

.action-icon {
    font-size: 42px;
}

.action-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

/* BUTTONS */
.btn-primary {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:active {
    background: #1557b0;
}

/* LIST CONTENT */
.list-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.list-item {
    background: var(--bg-medium);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.list-item:active {
    transform: scale(0.98);
    border-color: var(--primary-color);
}

.list-item-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.list-item-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.list-item-meta {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.meta-tag {
    background: var(--bg-light);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* DETAIL CONTENT */
.detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.info-box {
    background: var(--bg-medium);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.info-box h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.cantiere-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.info-value {
    font-weight: 600;
    font-size: 14px;
}

.actions-section {
    margin-top: 20px;
}

.actions-section h3 {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 600;
}

.action-btn {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    font-weight: 600;
    background: var(--bg-medium);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 12px;
    text-align: left;
    transition: all 0.2s;
}

.action-btn:active {
    transform: scale(0.98);
    background: var(--bg-light);
    border-color: var(--primary-color);
}

/* CHAT */
.chat-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}

.chat-context {
    width: 100%;
}

#chatSubtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.4;
}

.message.user {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.omar {
    align-self: flex-start;
    background: var(--bg-medium);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    background: var(--bg-light);
    color: var(--text-secondary);
    font-size: 14px;
    font-style: italic;
}

.message-time {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    margin-top: 5px;
}

.saved-badge {
    color: #4CAF50;
    font-size: 14px;
    font-weight: bold;
    margin-left: 5px;
}

.chat-input-container {
    padding: 15px 20px;
    background: var(--bg-medium);
    border-top: 1px solid var(--border-color);
}

.btn-voice {
    width: 100%;
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.btn-voice:active {
    transform: scale(0.98);
    background: #c5221f;
}

.btn-voice.recording {
    background: var(--success-color);
    animation: pulse 1s infinite;
}

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

.voice-icon {
    font-size: 24px;
}

.text-input-row {
    display: flex;
    gap: 10px;
}

#textInput {
    flex: 1;
    padding: 12px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-light);
    color: var(--text-primary);
}

#textInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-send {
    width: 48px;
    height: 48px;
    min-width: 48px;
    font-size: 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-send:active {
    background: #1557b0;
    transform: scale(0.95);
}

.chat-actions {
    padding: 15px 20px;
    background: var(--bg-medium);
    border-top: 1px solid var(--border-color);
}

/* LOADING */
.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* TOAST */
.toast-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 90%;
}

.toast {
    background: var(--bg-medium);
    color: var(--text-primary);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease;
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

@keyframes slideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.error-msg {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 10px;
    display: none;
}

.error-msg.active {
    display: block;
}

.badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

.badge.alert {
    background: var(--danger-color);
}

.hidden {
    display: none !important;
}

/* CANTIERI ACCORDION */
.cantiere-accordion {
    background: var(--bg-medium);
    border-radius: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--border-color);
    overflow: hidden;
    transition: all 0.3s;
}

.cantiere-accordion.active {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

.cantiere-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.cantiere-header:active {
    background: var(--bg-light);
}

.cantiere-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.cantiere-icon {
    font-size: 24px;
}

.cantiere-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.cantiere-ref {
    font-size: 14px;
    color: var(--text-secondary);
}

.cantiere-arrow {
    font-size: 24px;
    color: var(--text-secondary);
    transition: transform 0.3s;
}

.cantiere-accordion.active .cantiere-arrow {
    transform: rotate(90deg);
    color: var(--primary-color);
}

.cantiere-actions {
    padding: 0 15px 15px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.cantiere-action-btn {
    width: 100%;
    padding: 16px 15px;
    font-size: 17px;
    font-weight: 600;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    margin-bottom: 15px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.cantiere-action-btn:active {
    transform: scale(0.98);
    background: #1557b0;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-medium);
    border-radius: 16px;
    padding: 25px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-content h2 {
    font-size: 22px;
    margin-bottom: 20px;
    text-align: center;
}

.modal-option {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    font-weight: 600;
    background: var(--bg-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 12px;
    text-align: left;
    transition: all 0.2s;
}

.modal-option:active {
    transform: scale(0.98);
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.modal-close {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.2s;
}

.modal-close:active {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

.info-box {
    background: var(--bg-medium);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.info-box h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

/* NUOVA PAGINA DETTAGLIO CANTIERE */
.cantiere-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cantiere-detail-header {
    background: var(--bg-medium);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.cantiere-detail-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.cantiere-detail-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.detail-badge {
    background: var(--bg-light);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.detail-badge:empty {
    display: none;
}

/* RIEPILOGO OMAR BOX */
.omar-riepilogo-box {
    background: var(--bg-medium);
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    overflow: hidden;
    flex: 1;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.omar-riepilogo-header {
    background: linear-gradient(135deg, var(--primary-color), #1557b0);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.omar-icon {
    font-size: 28px;
}

.omar-label {
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.omar-riepilogo-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
}

.riepilogo-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-style: italic;
}

.loading-dots {
    animation: pulse 1.5s infinite;
}

/* AZIONI CANTIERE - 3 BOTTONI GRANDI */
.cantiere-detail-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 20px;
}

.cantiere-big-btn {
    width: 100%;
    padding: 22px 20px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.cantiere-big-btn:active {
    transform: scale(0.98);
}

.big-btn-icon {
    font-size: 32px;
}

.big-btn-text {
    font-size: 20px;
    font-weight: 700;
    color: white;
}

/* Colori specifici per ogni bottone */
.nota-btn {
    background: linear-gradient(135deg, #f57c00, #e65100);
}

.nota-btn:active {
    background: linear-gradient(135deg, #e65100, #bf360c);
}

.programma-btn {
    background: linear-gradient(135deg, #7cb342, #558b2f);
}

.programma-btn:active {
    background: linear-gradient(135deg, #558b2f, #33691e);
}

.chat-btn {
    background: linear-gradient(135deg, var(--primary-color), #1557b0);
}

.chat-btn:active {
    background: linear-gradient(135deg, #1557b0, #0d47a1);
}

/* LISTA CANTIERI - NUOVO STILE */
.cantiere-list-item {
    background: var(--bg-medium);
    border-radius: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--border-color);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.cantiere-list-item:active {
    transform: scale(0.98);
    background: var(--bg-light);
    border-color: var(--primary-color);
}

/* ========================================
   PAGINA DETTAGLIO CANTIERE - NUOVO LAYOUT
   ======================================== */

/* Container principale - permette scroll con pulsanti fixed */
#cantiereDetailScreen .cantiere-detail-content {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
    padding-bottom: 280px; /* Spazio per i pulsanti fixed */
}

/* Box riepilogo Omar - senza header, solo contenuto */
#cantiereDetailScreen .omar-riepilogo-box {
    background: var(--bg-medium);
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

#cantiereDetailScreen .omar-riepilogo-content {
    padding: 20px;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
}

/* Pulsanti FIXED in basso */
.cantiere-detail-actions-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-dark);
    padding: 15px;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.cantiere-detail-actions-fixed .cantiere-big-btn {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.cantiere-detail-actions-fixed .big-btn-icon {
    font-size: 24px;
}

.cantiere-detail-actions-fixed .big-btn-text {
    font-size: 18px;
    font-weight: 700;
    color: white;
}

/* ========================================
   FIX SCROLLING GLOBALE iOS
   ======================================== */

/* Fix per list-content scrollabile */
.list-content {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    padding-bottom: 40px;
}

/* Fix per dashboard scrollabile */
.dashboard-new {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    padding-bottom: 40px;
}

/* Fix per detail-content scrollabile */
.detail-content {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    padding-bottom: 40px;
}

/* Fix per chat messages scrollabile */
.chat-messages {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ========================================
   PULSANTI ORIZZONTALI - FIXED IN BASSO
   ======================================== */
.cantiere-actions-row {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-dark);
    padding: 12px 10px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: row;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.cantiere-action-btn-small {
    flex: 1;
    padding: 12px 8px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
}

.cantiere-action-btn-small:active {
    transform: scale(0.95);
}

.action-icon-small {
    font-size: 24px;
}

.action-text-small {
    font-size: 11px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}

/* Aggiorna padding del contenuto per pulsanti più piccoli */
#cantiereDetailScreen .cantiere-detail-content {
    padding-bottom: 100px; /* Ridotto da 280px */
}

/* Box riepilogo - altezza automatica, nessun limite */
#cantiereDetailScreen .omar-riepilogo-box {
    max-height: none;
    overflow: visible;
}

/* Contenuto riepilogo - testo completo senza troncamento */
#cantiereDetailScreen .omar-riepilogo-content {
    overflow: visible;
    max-height: none;
}

/* ========================================
   SCHERMATA IMPEGNI
   ======================================== */

/* Header impegni con badge */
.impegni-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.impegni-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.impegni-badge {
    background: var(--danger-color);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}

/* Lista impegni scrollabile */
.impegni-list {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
    padding-bottom: 90px; /* Spazio per filtri fixed */
}

/* Card impegno */
.impegno-card {
    background: var(--bg-medium);
    border-radius: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--border-color);
    overflow: hidden;
    animation: slideInUp 0.3s ease;
    transition: all 0.2s;
    min-height: 180px;
}

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

.impegno-card:active {
    transform: scale(0.97);
}

.impegno-card.removing {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Bordo sinistro colorato per priorità */
.impegno-card.priorita-alta {
    border-left: 4px solid var(--danger-color);
}

.impegno-card.priorita-media {
    border-left: 4px solid var(--warning-color);
}

.impegno-card.priorita-bassa {
    border-left: 4px solid var(--success-color);
}

/* Bordo per fonte (email/whatsapp) */
.impegno-card[data-fonte="email"] {
    border-color: #0d6efd;
}

.impegno-card[data-fonte="whatsapp"] {
    border-color: #25D366;
}

/* Contenuto card */
.impegno-card-content {
    padding: 20px;
    cursor: pointer;
}

.impegno-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.impegno-icona {
    font-size: 24px;
    flex-shrink: 0;
}

.impegno-info {
    flex: 1;
    min-width: 0;
}

.impegno-tipo {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.impegno-titolo {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.impegno-tempo {
    font-size: 13px;
    color: var(--text-secondary);
}

.impegno-tempo.urgente {
    color: var(--danger-color);
    font-weight: 600;
}

.impegno-contenuto {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 8px;
}

/* Pulsanti card */
.impegno-card-actions {
    display: flex;
    border-top: 1px solid var(--border-color);
}

.impegno-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}

.impegno-btn:active {
    background: var(--bg-light);
}

.impegno-btn.risolto {
    color: var(--success-color);
    border-right: 1px solid var(--border-color);
}

.impegno-btn.apri {
    color: var(--primary-color);
}

/* Barra filtri fixed bottom */
.impegni-filtri {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-dark);
    padding: 12px 15px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.filtro-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    border-radius: 8px;
    background: var(--bg-medium);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.filtro-btn:active {
    transform: scale(0.95);
}

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

.filtro-badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    min-width: 20px;
}

.filtro-btn.active .filtro-badge {
    background: rgba(255,255,255,0.3);
}

/* ========================================
   SCHERMATA DETTAGLIO IMPEGNO
   ======================================== */

.impegno-detail-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
    padding-bottom: 100px;
}

/* Box Briefing Omar */
.briefing-box {
    background: var(--bg-medium);
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    overflow: visible;
    margin-bottom: 20px;
    /* RIMOSSO min-height per far espandere il box con il contenuto */
}

.briefing-header {
    background: linear-gradient(135deg, var(--primary-color), #1557b0);
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px 10px 0 0; /* Angoli arrotondati sopra */
}

.briefing-header-icon {
    font-size: 24px;
}

.briefing-header-text {
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.briefing-content {
    padding: 15px;
    /* NO max-height - il testo si espande liberamente */
    /* La pagina .impegno-detail-content ha overflow-y: auto quindi scrolla */
    -webkit-overflow-scrolling: touch;
}

.briefing-section {
    margin-bottom: 18px;
}

.briefing-section:last-child {
    margin-bottom: 0;
}

.briefing-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.briefing-section-icon {
    font-size: 16px;
}

.briefing-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.briefing-section-text {
    font-size: 17px;
    color: var(--text-primary);
    line-height: 1.6;
    padding-left: 24px;
    font-weight: 500;
}

.briefing-section-text.warning {
    color: var(--warning-color);
}

.briefing-section-text.muted {
    color: var(--text-secondary);
    font-style: italic;
}

/* Chat nel dettaglio */
.impegno-chat-box {
    background: var(--bg-medium);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    min-height: 620px;
}

.impegno-chat-header {
    padding: 12px 15px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.impegno-chat-messages {
    height: 600px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.impegno-chat-input {
    display: flex;
    gap: 10px;
    padding: 12px 15px;
    background: var(--bg-dark);
    border-top: 1px solid var(--border-color);
}

.impegno-chat-input input {
    flex: 1;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-medium);
    color: var(--text-primary);
}

.impegno-chat-input input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.impegno-chat-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.impegno-chat-btn:active {
    transform: scale(0.95);
}

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

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

/* Header dettaglio impegno */
.impegno-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.impegno-detail-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.impegno-detail-title {
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-risolto-header {
    padding: 10px 16px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.btn-risolto-header:active {
    transform: scale(0.95);
    background: #2e7d32;
}

/* ========================================
   NUOVI STILI - 15 DIC 2025
   ======================================== */

/* Freccia indietro grande */
.btn-back-large {
    font-size: 24px !important;
    min-width: 44px;
    min-height: 44px;
    padding: 12px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pulsante cronologia */
.btn-cronologia {
    background: #94a3b8;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 8px;
    transition: background 0.2s;
}

.btn-cronologia:active {
    background: #64748b;
}

.cronologia-icon {
    font-size: 18px;
    color: #1e293b;
    font-weight: bold;
}

.cronologia-text {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
}

/* Header impegni modificato */
.impegni-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Separatori data */
.impegni-date-separator {
    text-align: center;
    padding: 15px 0 10px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.impegni-date-separator::before,
.impegni-date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* Card impegno compatta - header su una linea */
.impegno-card-header-compact {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.impegno-dot {
    font-size: 10px;
}

.impegno-tipo-compact {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.impegno-titolo-compact {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.impegno-tempo-compact {
    font-size: 12px;
    color: var(--text-secondary);
}

.impegno-tempo-compact.urgente {
    color: var(--danger-color);
}

/* Pulsanti bottom cantieri */
.cantieri-list-content {
    padding-bottom: 90px !important; /* Spazio per pulsanti */
}

.cantieri-bottom-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-dark);
    padding: 12px 15px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.cantieri-bottom-btn {
    flex: 1;
    padding: 14px 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: white;
    transition: all 0.2s;
}

.cantieri-bottom-btn:active {
    transform: scale(0.95);
}

.cantieri-bottom-btn.elabora-btn {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.cantieri-bottom-btn.report-btn {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* Chat header compatto */
.chat-header-compact {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.chat-context-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-context-compact #chatTitle {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-separator {
    color: var(--text-secondary);
}

.chat-subtitle-compact {
    font-size: 14px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pulsante vocale compatto - NON PIU' USATO */
.btn-voice-compact {
    padding: 14px !important;
    font-size: 16px !important;
}

/* Pulsante vocale piccolo rotondo */
.btn-voice-small {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    background: var(--danger-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-voice-small:active {
    transform: scale(0.95);
    background: #c5221f;
}

.btn-voice-small.recording {
    background: var(--success-color);
    animation: pulse 1s infinite;
}

/* Pulsante invio giallo */
.btn-send-yellow {
    background: #EAB308 !important;
    color: white;
}

.btn-send-yellow:active {
    background: #CA8A04 !important;
}

/* Pulsante invio giallo chat impegno */
.impegno-chat-btn.send-yellow {
    background: #EAB308;
    color: white;
}

.impegno-chat-btn.send-yellow:active {
    background: #CA8A04;
}

/* Modal conferma */
.confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-modal.active {
    display: flex;
}

.confirm-modal-content {
    background: var(--bg-medium);
    border-radius: 16px;
    padding: 25px;
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.confirm-modal-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 25px;
}

.confirm-modal-buttons {
    display: flex;
    gap: 12px;
}

.confirm-modal-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.confirm-modal-btn:active {
    transform: scale(0.95);
}

.confirm-modal-btn.cancel {
    background: var(--bg-light);
    color: var(--text-secondary);
}

.confirm-modal-btn.confirm {
    background: var(--success-color);
    color: white;
}

/* Modal cronologia */
.cronologia-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cronologia-modal.active {
    display: flex;
}

.cronologia-modal-content {
    background: var(--bg-medium);
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.cronologia-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.cronologia-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.cronologia-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
}

.cronologia-list {
    flex: 1;
    overflow-y: auto;
}

.cronologia-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 8px;
}

.cronologia-item-info {
    flex: 1;
}

.cronologia-item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.cronologia-item-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.cronologia-item-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.cronologia-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-style: italic;
}

/* ========================================
   CARD CANTIERI CON PULSANTE ELABORA - v6.3
   ======================================== */

.cantiere-list-item-new {
    background: var(--bg-medium);
    border-radius: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: stretch;
    overflow: hidden;
    transition: all 0.2s;
}

/* Stile per progetti PROVVISORI (da verificare) */
.cantiere-list-item-new.provvisorio {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #f87171;
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.3);
}

.cantiere-list-item-new.provvisorio .cantiere-name {
    color: #dc2626;
}

.cantiere-list-item-new.provvisorio .cantiere-elabora-btn {
    background: #ef4444;
}

.cantiere-list-item-new.provvisorio .cantiere-elabora-btn:active {
    background: #dc2626;
}

.provvisorio-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fef2f2;
    color: #dc2626;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #fca5a5;
    margin-left: 8px;
}

.cantiere-list-item-new:active {
    transform: scale(0.98);
}

.cantiere-elabora-btn {
    width: 60px;
    min-width: 60px;
    background: #3b82f6;
    border: none;
    border-radius: 10px 0 0 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.cantiere-elabora-btn:active {
    background: #2563eb;
}

.elabora-text {
    color: white;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

.cantiere-info-section {
    flex: 1;
    padding: 15px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cantiere-list-item-new .cantiere-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.cantiere-list-item-new .cantiere-ref {
    font-size: 13px;
    color: var(--text-secondary);
}

.cantiere-list-item-new .cantiere-arrow {
    font-size: 24px;
    color: var(--text-secondary);
    padding: 15px 15px 15px 5px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Stile per report-btn nel dettaglio cantiere */
.cantiere-action-btn-small.report-btn {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.cantiere-action-btn-small.report-btn:active {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
}

/* ========================================
   PULSANTI DINAMICI INBOX
   ======================================== */

/* Container pulsanti dinamici */
.impegno-card-actions-dynamic {
    display: flex;
    border-top: 1px solid var(--border-color);
    padding: 8px;
    gap: 8px;
    flex-wrap: wrap;
}

/* Pulsante dinamico singolo */
.impegno-btn-dynamic {
    flex: 1;
    min-width: 70px;
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.impegno-btn-dynamic:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* Spinner piccolo per loading */
.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

/* Stato errore inbox */
.inbox-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.inbox-error-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.inbox-error-text {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 20px;
}

.inbox-retry-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inbox-retry-btn:active {
    transform: scale(0.95);
    background: #1557b0;
}

/* Animazione rimozione card */
.impegno-card.removing {
    animation: slideOutLeft 0.3s ease forwards;
}

@keyframes slideOutLeft {
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* ========================================
   CHAT CLIENTE - 1 GEN 2026
   ======================================== */

/* Header Chat Cliente */
.chat-cliente-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-color);
    gap: 15px;
}

.chat-cliente-info {
    flex: 1;
}

.chat-cliente-nome {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.chat-cliente-progetto {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Riepilogo situazione */
.chat-cliente-riepilogo {
    padding: 12px 20px;
    background: #2d3748;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
    max-height: 80px;
    overflow-y: auto;
}

.chat-cliente-riepilogo:empty {
    display: none;
}

/* Lista messaggi */
.chat-cliente-messaggi {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Singolo messaggio chat cliente */
.chat-cliente-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
}

.chat-cliente-msg.ingresso {
    align-self: flex-start;
    background: #3a3a3a;
    border-bottom-left-radius: 4px;
}

.chat-cliente-msg.uscita {
    align-self: flex-end;
    background: #1a73e8;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-cliente-msg-testo {
    font-size: 15px;
    line-height: 1.5;
}

.chat-cliente-msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.7;
}

.chat-cliente-msg-commento {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* Nuovo stile messaggi con colori mittente */
.chat-message {
    padding: 12px;
    margin: 8px 12px;
    border-radius: 12px;
}

.message-ours {
    margin-left: 40px;
}

.message-theirs {
    margin-right: 40px;
}

.message-sender {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 4px;
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
    color: var(--text-primary);
}

.message-time {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #888;
    margin-top: 6px;
    justify-content: flex-end;
}

/* Messaggi chat - Cliente a sinistra (blu), Kibitec a destra (verde) */
.msg-cliente {
    margin-right: 20%;
    margin-left: 0;
    border-left: 4px solid #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.msg-kibitec {
    margin-left: 20%;
    margin-right: 0;
    border-left: 4px solid #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

/* Colori bordo schede lista Impegni basato su stato */
.scheda-urgente {
    border-left: 4px solid #ef4444 !important;
}

.scheda-attesa {
    border-left: 4px solid #eab308 !important;
}

.scheda-ok {
    border-left: 4px solid #22c55e !important;
}

/* Area input chat cliente */
.chat-cliente-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
    background: var(--bg-medium);
    border-top: 1px solid var(--border-color);
}

.chat-cliente-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 15px;
}

.chat-cliente-input-area input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ========================================
   MODAL RISPOSTA CLIENTE
   ======================================== */

.risposta-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.risposta-modal.active {
    display: flex;
}

.risposta-modal-content {
    background: var(--bg-medium);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.risposta-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.risposta-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.risposta-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
}

.risposta-modal-note {
    padding: 12px 20px;
    background: #2d3748;
    font-size: 13px;
    color: #a0aec0;
    border-bottom: 1px solid var(--border-color);
}

.risposta-modal-note:empty {
    display: none;
}

.risposta-modal-testo {
    width: 100%;
    min-height: 120px;
    padding: 16px 20px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
}

.risposta-modal-testo:focus {
    outline: none;
}

.risposta-modal-buttons {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.risposta-modal-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.risposta-modal-btn.modifica {
    background: #4a5568;
    color: white;
}

.risposta-modal-btn.accetta {
    background: #38a169;
    color: white;
}

.risposta-modal-btn:active {
    transform: scale(0.95);
}

/* Pulsante Dopo per schede cliente */
.impegno-btn-dopo {
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.impegno-btn-dopo:active {
    transform: scale(0.95);
    background: #4b5563;
}

/* ========================================
   CARD WHATSAPP - NUOVO DESIGN
   ======================================== */

.whatsapp-card {
    cursor: pointer;
    position: relative;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--card-bg);
    margin-bottom: 10px;
}

.whatsapp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.whatsapp-card-cliente {
    display: flex;
    align-items: center;
    gap: 8px;
}

.whatsapp-dot {
    font-size: 12px;
}

.whatsapp-icon-svg {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 4px;
    flex-shrink: 0;
}

.whatsapp-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.whatsapp-label strong {
    color: var(--text-primary);
    font-weight: 600;
}

.whatsapp-badge {
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.btn-posponi {
    background: #6c757d;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    color: white;
    transition: all 0.2s;
}

.btn-posponi:active {
    background: #5a6268;
    transform: scale(0.95);
}

.whatsapp-card-messaggio {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.whatsapp-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.whatsapp-contesto {
    font-size: 12px;
    color: #888;
    flex: 1;
}

.whatsapp-tempo {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

/* Bordo sinistro priorità per card WhatsApp */
.whatsapp-card.priorita-urgente {
    border-left: 4px solid var(--danger-color);
}

.whatsapp-card.priorita-normale {
    border-left: 4px solid var(--success-color);
}

/* Retrocompatibilità */
.whatsapp-card.priorita-alta {
    border-left: 4px solid var(--danger-color);
}

.whatsapp-card.priorita-media {
    border-left: 4px solid var(--warning-color);
}

.whatsapp-card.priorita-bassa {
    border-left: 4px solid var(--success-color);
}

/* === PULSANTE E MODAL CONTESTO === */

.btn-contesto {
    background: linear-gradient(135deg, #4a90d9, #357abd);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
}

.btn-contesto:hover {
    background: linear-gradient(135deg, #357abd, #2a5f8f);
    transform: scale(1.02);
}

.contesto-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.contesto-modal.active {
    display: flex;
}

.contesto-modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
}

.contesto-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.contesto-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.contesto-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.contesto-discussioni h3,
.contesto-riepilogo h3 {
    font-size: 14px;
    color: #888;
    margin: 16px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contesto-discussione {
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 3px solid var(--success-color);
}

.contesto-discussione.urgente {
    border-left-color: var(--danger-color);
}

.contesto-discussione.alta {
    border-left-color: var(--warning-color);
}

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

.discussione-header span:first-child {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.discussione-stato {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: #888;
}

.discussione-riepilogo {
    font-size: 13px;
    color: #aaa;
    line-height: 1.4;
}

/* Nuovo stile card discussioni con pulsanti */
.discussione-card {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.discussione-card .discussione-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.discussione-icon {
    font-size: 14px;
}

.discussione-titolo {
    font-weight: bold;
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
}

.discussione-stato {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #444;
    color: #aaa;
}

.discussione-stato.aperta {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.discussione-stato.conclusa {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

/* Stile per discussioni concluse (card grigia) */
.discussione-conclusa {
    background: #1a1a1a !important;
    border-left: 4px solid #555 !important;
    opacity: 0.7;
}

.discussione-conclusa .discussione-titolo {
    color: #888;
}

.discussione-conclusa .discussione-descrizione {
    color: #666;
}

/* Header sezione concluse */
.concluse-header {
    color: #888;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #333;
}

.discussione-descrizione {
    font-size: 14px;
    color: #ccc;
    margin-bottom: 12px;
    line-height: 1.4;
}

.discussione-actions {
    display: flex;
    gap: 8px;
}

.btn-disc {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.btn-disc:active {
    opacity: 0.8;
}

.btn-rispondi {
    background: #3b82f6;
    color: white;
}

.btn-chiudi {
    background: #28a745;
    color: white;
}

.btn-dopo {
    background: #6b7280;
    color: white;
}

.contesto-riepilogo .riepilogo-testo {
    background: rgba(74, 144, 217, 0.1);
    border-radius: 10px;
    padding: 12px;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
}

.contesto-riepilogo .riepilogo-data {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    text-align: right;
}

.no-data {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* === NUOVO LAYOUT CHAT CLIENTE === */

.chat-cliente-footer {
    padding: 16px;
    display: flex;
    justify-content: center;
    background: var(--bg-primary);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-rispondi-omar {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    max-width: 300px;
    transition: all 0.2s;
}

.btn-rispondi-omar:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* === POPUP OMAR === */

.omar-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
    display: none;
    z-index: 3000;
    align-items: flex-end;
    justify-content: center;
}

.omar-popup.active {
    display: flex;
}

.omar-popup-content {
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.omar-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.omar-popup-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.omar-popup-close {
    background: none;
    border: none;
    color: #888;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.omar-popup-chat {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 200px;
    max-height: 300px;
}

.omar-msg {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 10px;
    max-width: 85%;
    line-height: 1.4;
}

.omar-msg.sistema {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border-left: 3px solid #3b82f6;
}

.omar-msg.utente {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    margin-left: auto;
}

.omar-msg.omar {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border-left: 3px solid #22c55e;
}

.omar-msg.risposta-proposta {
    background: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
    border: 2px solid #f59e0b;
    font-size: 15px;
}

.omar-popup-input-area {
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.omar-popup-input-area textarea {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 16px;
    min-height: 100px;
    max-height: 200px;
    resize: none;
    overflow-y: auto;
    line-height: 1.4;
    font-family: inherit;
}

.omar-popup-input-area textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.omar-popup-actions {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    gap: 12px;
}

.btn-modifica-risposta {
    flex: 1;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modifica-risposta:hover {
    background: #5b6270;
    transform: scale(1.02);
}

.btn-manda-risposta {
    flex: 1;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-manda-risposta:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

/* ========================================
   NUOVI STILI IMPEGNI v6.4 - 3 GEN 2026
   ======================================== */

/* Card impegno con classi priorità */
.impegno-card.urgente {
    border-left: 6px solid #ef4444;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

.impegno-card.normale {
    border-left: 6px solid #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.impegno-card.posposto {
    border-left: 6px solid #6b7280;
    opacity: 0.8;
    background: rgba(107, 114, 128, 0.1);
}

.impegno-card.attende {
    border-left: 6px solid #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
}

/* Header impegno card */
.impegno-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px;
    cursor: pointer;
}

.impegno-progetto {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.impegno-ora {
    font-size: 12px;
    color: var(--text-secondary);
}

.impegno-ora.urgente {
    color: #ef4444;
    font-weight: 600;
}

/* Icona fonte (WhatsApp/Email) */
.impegno-fonte-icon {
    font-size: 18px;
    margin-right: 8px;
    flex-shrink: 0;
}

/* Mittente nell'header */
.impegno-mittente {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progetto come sottotitolo */
.impegno-progetto-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 0 14px 6px;
    margin-top: -6px;
}

/* Badge numero messaggi */
.impegno-msg-badge {
    background: var(--accent-blue);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Riepilogo impegno */
.impegno-riepilogo {
    padding: 0 20px 20px;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.6;
    /* Full text display - no truncation */
}

/* Stato impegno */
.impegno-stato {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: var(--text-secondary);
}

.impegno-stato.urgente {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.impegno-stato.attende {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.impegno-stato.posposto {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

/* Azioni impegno card */
.impegno-actions {
    display: flex;
    border-top: 1px solid var(--border-color);
}

.impegno-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.impegno-actions button:active {
    background: var(--bg-light);
}

.impegno-actions button:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

/* Pulsante Posponi - GRIGIO */
.impegno-actions .btn-posponi {
    background: #6c757d !important;
    color: white !important;
}

/* Pulsante Risolto (btn-chiudi) - VERDE */
.impegno-actions .btn-chiudi {
    background: #28a745 !important;
    color: white !important;
}

/* Pulsante posponi */
.btn-posponi-new {
    color: #6b7280 !important;
}

/* ===== STILI DETTAGLIO EMAIL ===== */
.email-header-detail {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.email-header-detail > div {
    margin-bottom: 10px;
}

.email-header-detail > div:last-child {
    margin-bottom: 0;
}

.email-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    margin-right: 8px;
}

.email-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.email-address {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 4px;
}

.email-from {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
}

.email-subject .email-value {
    font-size: 15px;
}

.email-body-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.email-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.email-attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-light);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s;
}

.email-attachment-item:active {
    background: var(--bg-hover);
}

/* Briefing evidenziato */
.briefing-highlight {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
}

.briefing-highlight .briefing-section-header {
    color: var(--accent-blue);
}

.briefing-highlight .briefing-section-text {
    color: var(--text-primary);
    font-weight: 500;
}

.btn-posponi-new:active {
    background: rgba(107, 114, 128, 0.2) !important;
}

/* Pulsante chiudi */
.btn-chiudi-new {
    color: #10b981 !important;
}

.btn-chiudi-new:active {
    background: rgba(16, 185, 129, 0.2) !important;
}

/* Messaggi conversazione cliente */
.messaggio {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    max-width: 85%;
    line-height: 1.5;
    font-size: 15px;
}

.msg-cliente {
    background: #3a3a3a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.msg-kibitec {
    background: #1a73e8;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.msg-time {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

/* Container messaggi */
.conversazione-messaggi {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

/* Input risposta */
.risposta-input-container {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: var(--bg-medium);
    border-top: 1px solid var(--border-color);
}

.risposta-input-container input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 15px;
}

.risposta-input-container input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ========================================
   POPUP POSPONI E CONFERMA RISPOSTA
   ======================================== */

.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.popup-content {
    background: var(--bg-medium);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 340px;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.popup-titolo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 20px;
}

.popup-opzioni {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.popup-opzioni button {
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 10px;
    background: var(--bg-light);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.popup-opzioni button:active {
    background: var(--primary-color);
    transform: scale(0.98);
}

.popup-cancel {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.popup-cancel:active {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

/* Popup conferma risposta */
.popup-messaggio {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.popup-buttons {
    display: flex;
    gap: 12px;
}

.popup-buttons .btn-modifica {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: #6b7280;
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.popup-buttons .btn-modifica:active {
    background: #4b5563;
    transform: scale(0.95);
}

.popup-buttons .btn-conferma {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: #10b981;
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.popup-buttons .btn-conferma:active {
    background: #059669;
    transform: scale(0.95);
}

/* Popup conferma chiusura (ultimo msg cliente) */
.popup-box-conferma {
    background: var(--bg-medium);
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    max-width: 300px;
    animation: popIn 0.2s ease-out;
}

.popup-warning-text {
    font-size: 18px;
    font-weight: 600;
    color: #f59e0b;
    margin-bottom: 8px;
}

.popup-question-text {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.popup-buttons-conferma {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-chiudi-popup {
    background: #dc3545;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-chiudi-popup:active {
    background: #b02a37;
    transform: scale(0.95);
}

.btn-rispondi-popup {
    background: #28a745;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-rispondi-popup:active {
    background: #1e7e34;
    transform: scale(0.95);
}

/* Badge contatore non letto */
.impegno-badge-unread {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Stato attende risposta con animazione */
.impegno-stato.attende::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #f59e0b;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

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

/* Alert ultimo messaggio cliente */
.alert-ultimo-cliente {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-ultimo-cliente-icon {
    font-size: 20px;
}

.alert-ultimo-cliente-text {
    font-size: 14px;
    color: #fca5a5;
    line-height: 1.4;
}

/* ========================================
   IMPEGNO DETTAGLIO - Nuova struttura v6.5
   ======================================== */

/* Header con pulsanti Chat + Risolto */
.impegno-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.impegno-detail-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.impegno-detail-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.impegno-detail-header-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Pulsante Chat blu */
.btn-chat-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #3b82f6;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-chat-header:active {
    background: #2563eb;
    transform: scale(0.95);
}

/* Pulsante Risolto verde */
.btn-risolto-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #10b981;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-risolto-header:active {
    background: #059669;
    transform: scale(0.95);
}

/* Contenuto scrollabile con padding per header e input fissi */
#impegnoDetailScreen .impegno-detail-content {
    padding: 70px 16px 90px;
    overflow-y: auto;
    height: 100vh;
    box-sizing: border-box;
}

/* ========================================
   FIX BRIEFING RIEPILOGO - FULL PAGE
   ======================================== */

/* Briefing box - nessun limite, si espande con contenuto */
#impegnoDetailScreen .briefing-box {
    overflow: visible !important;
    max-height: none !important;
    min-height: auto !important;
    height: auto !important;
}

/* Briefing content - tutto visibile, nessun troncamento */
#impegnoDetailScreen .briefing-content {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
}

/* Sezioni briefing - nessun line-clamp */
#impegnoDetailScreen .briefing-section {
    overflow: visible !important;
}

/* Testo riepilogo - MAI troncato */
#impegnoDetailScreen .briefing-section-text {
    display: block !important;
    overflow: visible !important;
    text-overflow: unset !important;
    -webkit-line-clamp: unset !important;
    -webkit-box-orient: unset !important;
    max-height: none !important;
    white-space: normal !important;
}

/* Input risposta FIXED in basso */
.impegno-input-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-medium);
    border-top: 1px solid var(--border-color);
    z-index: 100;
}

.impegno-input-fixed textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    min-height: 100px;  /* 4 righe circa */
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.4;
}

.impegno-input-fixed textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-mic-input,
.btn-send-input {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-mic-input {
    background: var(--bg-light);
    color: var(--text-primary);
}

.btn-mic-input:active {
    background: #ef4444;
    color: white;
}

.btn-send-input {
    background: #fbbf24;
    color: #1a1a1a;
}

.btn-send-input:active {
    background: #f59e0b;
    transform: scale(0.95);
}

/* ========================================
   MESSAGGI CONVERSAZIONE - Fix display
   ======================================== */

.conversazione-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
}

.messaggio {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 90%;
    word-wrap: break-word;
}

.messaggio.msg-cliente {
    background: #2a2a2a;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.messaggio.msg-kibitec {
    background: #1a73e8;
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

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

.msg-mittente {
    font-weight: 600;
    color: var(--text-primary);
}

.msg-kibitec .msg-mittente {
    color: rgba(255,255,255,0.9);
}

.msg-ora {
    color: var(--text-secondary);
    font-size: 11px;
}

.msg-kibitec .msg-ora {
    color: rgba(255,255,255,0.6);
}

.msg-testo {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.msg-kibitec .msg-testo {
    color: white;
}

/* ========================================
   CHAT OMAR - Overlay a tutto schermo
   ======================================== */

.chat-omar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    z-index: 2000;
    display: none;
    flex-direction: column;
}

.chat-omar-overlay.active {
    display: flex;
}

.chat-omar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #2a2a2a;
    border-bottom: 1px solid #444;
}

.chat-omar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.chat-omar-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--bg-light);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-omar-close:active {
    background: #ef4444;
    color: white;
}

.chat-omar-messaggi {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.omar-msg {
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 85%;
    font-size: 15px;
    line-height: 1.5;
}

.omar-msg.omar {
    background: #2a2a2a;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.omar-msg.user {
    background: #3b82f6;
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.omar-msg.loading {
    opacity: 0.7;
    font-style: italic;
}

.omar-msg.error {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.chat-omar-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #2a2a2a;
    border-top: 1px solid #444;
}

.chat-omar-input textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #444;
    border-radius: 20px;
    background: #1a1a1a;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.4;
}

.chat-omar-input textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.btn-mic-omar,
.btn-send-omar {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-mic-omar {
    background: var(--bg-light);
    color: var(--text-primary);
}

.btn-mic-omar:active {
    background: #ef4444;
    color: white;
}

.btn-send-omar {
    background: #3b82f6;
    color: white;
}

.btn-send-omar:active {
    background: #2563eb;
    transform: scale(0.95);
}

/* ========================================
   POPUP NORMALIZZAZIONE RISPOSTA
   ======================================== */

.popup-normalizzazione {
    max-width: 400px;
}

.popup-sezione {
    margin-bottom: 16px;
}

.popup-sezione label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.popup-testo {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.btn-approva {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: #10b981;
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-approva:active {
    background: #059669;
    transform: scale(0.95);
}

/* ========================================
   MESSAGGI CHAT CON BORDO COLORATO
   ======================================== */

.messaggio-chat {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    border-left: 4px solid #3b82f6; /* default blu */
}

.messaggio-chat.msg-kibitec {
    margin-left: 15%;
    background: #1a3d2e;
}

.messaggio-chat.msg-cliente {
    margin-right: 15%;
    background: #1e3a5f;
}

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

.messaggio-chat .msg-mittente {
    font-size: 12px;
    font-weight: 700;
    color: #aaa;
}

.messaggio-chat .msg-ora {
    font-size: 11px;
    color: #666;
}

.messaggio-chat .msg-testo {
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Loading nella chat */
.chat-loading {
    text-align: center;
    color: #888;
    padding: 40px 20px;
    font-style: italic;
}

/* Override per chat omar overlay - stessi stili */
.chat-omar-messaggi .messaggio-chat {
    max-width: 85%;
}

.chat-omar-messaggi .messaggio-chat.msg-kibitec {
    margin-left: auto;
    margin-right: 0;
}

.chat-omar-messaggi .messaggio-chat.msg-cliente {
    margin-left: 0;
    margin-right: auto;
}

/* ========================================
   MODAL MASCHERA PROGETTO PROVVISORIO
   ======================================== */

.progetto-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.progetto-modal.show {
    display: flex;
}

.progetto-modal-content {
    background: var(--bg-dark);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progetto-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-radius: 16px 16px 0 0;
}

.progetto-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.progetto-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.progetto-modal-close:hover {
    opacity: 1;
}

.progetto-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.progetto-field {
    margin-bottom: 16px;
}

.progetto-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.progetto-field label .required {
    color: #ef4444;
    margin-left: 2px;
}

.progetto-field input,
.progetto-field select,
.progetto-field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    background: var(--bg-medium);
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s;
}

.progetto-field input:focus,
.progetto-field select:focus,
.progetto-field textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background: var(--bg-dark);
}

.progetto-field input.readonly,
.progetto-field select.readonly,
.progetto-field textarea.readonly {
    background: rgba(255, 255, 255, 0.03);
    color: #888;
    border-color: transparent;
    cursor: not-allowed;
}

.progetto-field textarea {
    resize: vertical;
    min-height: 80px;
}

.progetto-field-row {
    display: flex;
    gap: 12px;
}

.progetto-field-row .progetto-field {
    flex: 1;
}

.progetto-modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.progetto-modal-btn {
    flex: 1;
    padding: 14px 20px;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.progetto-modal-btn.cancel {
    background: var(--bg-medium);
    color: var(--text-secondary);
}

.progetto-modal-btn.cancel:hover {
    background: var(--bg-light);
}

.progetto-modal-btn.save {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.progetto-modal-btn.save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.progetto-modal-btn.save:disabled {
    background: #4b5563;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Badge verificare sulla lista cantieri */
.btn-verifica-progetto {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    margin-right: 10px;
    transition: all 0.2s;
}

.btn-verifica-progetto:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* ========================================
   PULSANTE NUOVO PROGETTO
   ======================================== */

.btn-nuovo-progetto {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
    transition: all 0.2s;
}

.btn-nuovo-progetto:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.btn-nuovo-progetto:active {
    transform: scale(0.98);
}

/* ========================================
   MODAL PROGRAMMA LAVORI CHAT
   ======================================== */

.programma-lavori-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.programma-lavori-modal.active {
    display: flex;
    flex-direction: column;
}

.programma-lavori-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    border-radius: 16px;
    overflow: hidden;
    max-height: 100%;
}

.programma-lavori-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border-bottom: 1px solid var(--border-color);
}

.programma-lavori-title {
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.programma-lavori-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.programma-lavori-close:active {
    background: rgba(255,255,255,0.3);
}

.programma-lavori-chat {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
}

.programma-lavori-chat .msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 15px;
}

.programma-lavori-chat .msg.user {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.programma-lavori-chat .msg.omar {
    align-self: flex-start;
    background: var(--bg-medium);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    white-space: pre-wrap;
}

.programma-lavori-chat .msg.system {
    align-self: center;
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    font-size: 13px;
    font-style: italic;
}

.programma-lavori-input-area {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: var(--bg-medium);
    border-top: 1px solid var(--border-color);
}

.programma-lavori-input-area input {
    flex: 1;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-dark);
    color: var(--text-primary);
}

.programma-lavori-input-area input:focus {
    outline: none;
    border-color: #8b5cf6;
}

.programma-lavori-result {
    padding: 15px;
    background: var(--bg-light);
    border-top: 2px solid #22c55e;
}

.programma-lavori-result .result-header {
    font-size: 14px;
    font-weight: 600;
    color: #22c55e;
    margin-bottom: 10px;
}

.programma-lavori-result textarea {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-dark);
    color: var(--text-primary);
    resize: none;
    margin-bottom: 10px;
}

.programma-lavori-result .btn-copy {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.programma-lavori-result .btn-copy:active {
    transform: scale(0.98);
}

/* Loading spinner in chat */
.programma-lavori-chat .loading-msg {
    align-self: flex-start;
    background: var(--bg-medium);
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.programma-lavori-chat .loading-msg .dots {
    display: flex;
    gap: 4px;
}

.programma-lavori-chat .loading-msg .dots span {
    width: 8px;
    height: 8px;
    background: #8b5cf6;
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out both;
}

.programma-lavori-chat .loading-msg .dots span:nth-child(1) { animation-delay: -0.32s; }
.programma-lavori-chat .loading-msg .dots span:nth-child(2) { animation-delay: -0.16s; }
.programma-lavori-chat .loading-msg .dots span:nth-child(3) { animation-delay: 0s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* =====================================================
   SCHEDE DISCUSSIONI - SEZIONE BRIEFING
   ===================================================== */

.discussioni-section {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.discussioni-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.discussioni-icon {
    font-size: 18px;
}

.discussioni-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.discussioni-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.discussione-card {
    background: var(--bg-medium);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid #22c55e;
}

.discussione-card:hover {
    background: var(--bg-dark);
    transform: translateX(4px);
}

.discussione-card.disc-corrente {
    background: rgba(59, 130, 246, 0.15);
    border-left-color: #3b82f6;
}

.discussione-card.disc-urgente {
    border-left-color: #ef4444;
}

.discussione-card.disc-attesa {
    border-left-color: #eab308;
}

.discussione-card.disc-ok {
    border-left-color: #22c55e;
}

.disc-titolo {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.disc-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.disc-ora {
    font-size: 11px;
    color: var(--text-secondary);
}

.disc-badge-nostro {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    font-weight: 600;
}

.disc-badge-attesa {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
    font-weight: 600;
}

/* Header row per discussione card con pulsante chiudi */
.disc-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.disc-btn-chiudi {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.disc-btn-chiudi:hover {
    background: rgba(34, 197, 94, 0.3);
    transform: scale(1.1);
}

.disc-btn-chiudi:active {
    transform: scale(0.95);
}

/* Animazione per rimozione card */
.discussione-card {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
