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

body {
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
    background: #111b21;
    color: #e9edef;
    overflow: hidden;
}

.container {
    max-width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #111b21;
}

/* Header */
header {
    background: linear-gradient(135deg, #202c33 0%, #2a3942 100%);
    color: #e9edef;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    min-height: 70px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
}

.logo {
    height: 45px;
    width: auto;
    background: white;
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #00a884;
    margin: 0;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #8696a0;
}

.status-indicator {
    font-size: 1.2rem;
}

.btn-primary {
    background: #00a884;
    color: #111b21;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #06cf9c;
}

.btn-primary:disabled {
    background: #374248;
    color: #667781;
    cursor: not-allowed;
}

.btn-connect {
    background: #ff9800;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
    animation: pulse 2s infinite;
}

.btn-connect:hover {
    background: #f57c00;
}

.btn-admin {
    background: #667781;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-admin:hover {
    background: #8696a0;
}

.btn-logout {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 250px 420px 1fr;
    gap: 0;
    height: calc(100vh - 70px);
    overflow: hidden;
    background: #111b21;
}

/* Sidebar */
.sidebar {
    background: #111b21;
    border-right: 1px solid #2a3942;
    overflow-y: auto;
    min-height: 0;
}

.filters, .categoria-filters, .tecnici-list {
    padding: 12px;
    border-bottom: 1px solid #2a3942;
}

.filters h3, .categoria-filters h3, .tecnici-list h3 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: #8696a0;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.filter-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 6px;
    border: none;
    background: #202c33;
    color: #e9edef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.filter-btn .count {
    background: #2a3942;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.filter-btn.active .count {
    background: #00a884;
    color: #ffffff;
    font-weight: 700;
}

.filter-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: #00a884;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.filter-btn:hover {
    background: #2a3942;
    transform: translateX(4px);
}

.filter-btn:hover::before {
    transform: scaleY(1);
}

.filter-btn.active {
    background: #202c33;
    color: #00a884;
    font-weight: 700;
    transform: translateX(0);
    border-left: 4px solid #00a884;
    padding-left: 10px;
}

.filter-btn.active::before {
    transform: scaleY(1);
    /* Rimosso width: 100% per evitare che copra il testo */
}

.categoria-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 6px;
    border: none;
    background: #202c33;
    color: #e9edef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.categoria-btn:hover {
    background: #2a3942;
    transform: translateX(4px);
}

.categoria-btn.active {
    background: #667781;
    color: white;
    font-weight: 600;
}

.tecnico-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    color: #e9edef;
}

.tecnico-item:hover {
    background: #202c33;
}

.tecnico-item.active {
    background: #202c33;
    border-left: 3px solid #00a884;
    padding-left: 9px;
}

.tecnico-badge {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Chat List */
.chat-list {
    background: #111b21;
    border-right: 1px solid #2a3942;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-list h2 {
    padding: 16px;
    font-size: 1.5rem;
    font-weight: 600;
    border-bottom: 1px solid #2a3942;
    background: #202c33;
    color: #e9edef;
}

.search-bar {
    padding: 12px 16px;
    border-bottom: 1px solid #2a3942;
    background: #202c33;
}

.search-bar input {
    width: 100%;
    padding: 10px 14px;
    background: #2a3942;
    border: 1px solid #374248;
    border-radius: 8px;
    color: #e9edef;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-bar input::placeholder {
    color: #8696a0;
}

.search-bar input:focus {
    outline: none;
    border-color: #00a884;
    background: #374248;
}

.chat-items {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.chat-item {
    padding: 14px 16px;
    border-bottom: 1px solid #2a3942;
    cursor: pointer;
    transition: all 0.25s ease;
    background: #111b21;
    position: relative;
}

.chat-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: #00a884;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.chat-item:hover {
    background: #202c33;
    padding-left: 20px;
}

.chat-item:hover::before {
    transform: scaleX(1);
}

.chat-item.active {
    background: #2a3942;
    border-left: 4px solid #00a884;
    padding-left: 16px;
}

.chat-item.active::before {
    transform: scaleX(1);
}

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

.chat-item-nome {
    font-weight: 600;
    font-size: 1rem;
    color: #e9edef;
}

.chat-item-time {
    font-size: 0.75rem;
    color: #8696a0;
}

.chat-item-preview {
    font-size: 0.9rem;
    color: #8696a0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 6px;
}

.chat-item-footer {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-nuovo {
    background: #ffd93d;
    color: #111b21;
}

.badge-assegnato {
    background: #4a9eff;
    color: white;
}

.badge-in_lavorazione {
    background: #00a884;
    color: white;
}

.badge-chiuso {
    background: #54656f;
    color: #e9edef;
}

.tecnico-badge-inline {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    color: white;
    font-weight: 600;
}

/* Chat Detail */
.chat-detail {
    background: #0b141a;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8696a0;
    font-size: 1.1rem;
    z-index: 1;
}

.empty-state.hidden {
    display: none;
}

#chatContent {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
}

#chatContent.active {
    display: flex !important;
    flex-direction: column;
}

.chat-header {
    flex: 0 0 50px;
    background: #202c33;
    padding: 8px 16px;
    border-bottom: 1px solid #2a3942;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.chat-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.chat-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.chat-header h2 {
    font-size: 1.1rem;
    margin-bottom: 2px;
    color: #e9edef;
    font-weight: 600;
}

.btn-rename {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    transition: all 0.2s;
    border-radius: 4px;
}

.btn-rename:hover {
    background: #2a3942;
    color: #00a884;
    transform: scale(1.1);
}

.chat-id {
    font-size: 0.75rem;
    color: #8696a0;
}

.chat-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.select-tecnico, .select-stato, .select-categoria {
    padding: 6px 12px;
    border: 1px solid #2a3942;
    border-radius: 8px;
    font-size: 0.85rem;
    background: #111b21;
    color: #e9edef;
    cursor: pointer;
    transition: all 0.2s;
}

.select-tecnico:hover, .select-stato:hover, .select-categoria:hover {
    background: #2a3942;
    border-color: #00a884;
}

.select-categoria {
    border-color: #667781;
}

.btn-generate-report {
    background: #8b5cf6;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-weight: 600;
}

.btn-generate-report:hover {
    background: #7c3aed;
    transform: translateY(-2px);
}

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

.btn-delete-chat {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    min-width: 40px;
}

.btn-delete-chat:hover {
    background: #dc2626;
    transform: scale(1.1);
}

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

/* Messages */
.messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" opacity="0.03"><path fill="%23ffffff" d="M0 0h400v400H0z"/><path fill="%23000000" d="M200 50l50 50-50 50-50-50zm-100 100l50 50-50 50-50-50zm200 0l50 50-50 50-50-50zm-100 100l50 50-50 50-50-50z"/></svg>');
    background-color: #0b141a;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.message {
    max-width: 65%;
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    position: relative;
}

.message-received {
    background: #202c33;
    margin-right: auto;
    color: #e9edef;
}

.message-sent {
    background: #005c4b;
    margin-left: auto;
    color: #e9edef;
}

.message-text {
    margin-bottom: 4px;
    line-height: 1.4;
    font-size: 0.95rem;
}

.message-time {
    font-size: 0.7rem;
    color: #8696a0;
    text-align: right;
    margin-top: 4px;
}

/* Message Input */
.message-input {
    flex: 0 0 60px;
    background: #202c33;
    padding: 10px 16px;
    display: flex;
    gap: 10px;
    border-top: 1px solid #2a3942;
    align-items: center;
    z-index: 10;
}

.message-input textarea {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    background: #2a3942;
    color: #e9edef;
    max-height: 120px;
    min-height: 44px;
    height: 44px;
}

.message-input textarea::placeholder {
    color: #8696a0;
}

.message-input textarea:focus {
    outline: none;
    background: #374248;
}

.btn-send {
    background: #00a884;
    color: #111b21;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    font-size: 0.95rem;
    min-height: 44px;
    white-space: nowrap;
}

.btn-send:hover {
    background: #06cf9c;
}

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

/* Emoji Picker */
.btn-emoji {
    background: #2a3942;
    color: #e9edef;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.btn-emoji:hover {
    background: #374248;
    transform: scale(1.1);
}

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

.emoji-picker {
    position: absolute;
    bottom: 80px;
    right: 16px;
    width: 320px;
    max-height: 400px;
    background: #202c33;
    border: 1px solid #374248;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.emoji-picker-header {
    padding: 12px 16px;
    font-weight: 600;
    color: #e9edef;
    border-bottom: 1px solid #374248;
    background: #111b21;
    border-radius: 12px 12px 0 0;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 12px;
    overflow-y: auto;
    max-height: 350px;
}

.emoji-item {
    font-size: 1.5rem;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    text-align: center;
    background: transparent;
    border: none;
}

.emoji-item:hover {
    background: #2a3942;
    transform: scale(1.2);
}

.emoji-item:active {
    transform: scale(0.9);
}

/* Note Section */
.note-section {
    flex: 0 0 auto;
    max-height: 150px;
    background: #202c33;
    border-top: 1px solid #2a3942;
    overflow: hidden;
    z-index: 10;
    transition: max-height 0.3s ease;
}

.note-section.collapsed {
    max-height: 40px;
}

.note-header {
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    min-height: 40px;
}

.note-header:hover {
    background: #2a3942;
}

.note-header h3 {
    font-size: 0.9rem;
    color: #8696a0;
    font-weight: 600;
    margin: 0;
}

.note-toggle {
    background: none;
    border: none;
    color: #8696a0;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.3s ease;
}

.note-section.collapsed .note-toggle {
    transform: rotate(-90deg);
}

.note-content {
    padding: 0 16px 8px 16px;
    overflow: hidden;
}

.note-section textarea {
    width: 100%;
    height: 50px;
    max-height: 50px;
    padding: 8px 12px;
    border: 1px solid #2a3942;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 6px;
    background: #2a3942;
    color: #e9edef;
    overflow-y: auto;
}

.note-section textarea::placeholder {
    color: #8696a0;
}

.note-section textarea:focus {
    outline: none;
    border-color: #00a884;
}

.btn-secondary {
    background: #00a884;
    color: #111b21;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #06cf9c;
}

/* Utilities */
.loading {
    text-align: center;
    color: #8696a0;
    padding: 2rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #111b21;
}

::-webkit-scrollbar-thumb {
    background: #374248;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #54656f;
}

/* QR Code Modal */
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.qr-modal-content {
    background: #202c33;
    padding: 2rem;
    border-radius: 16px;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out;
    position: relative;
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #2a3942;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    color: #e9edef;
}

.close-modal:hover {
    background: #374248;
}

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

.qr-modal-content h2 {
    color: #00a884;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.qr-modal-content p {
    color: #8696a0;
    margin-bottom: 1.5rem;
}

.qr-code-container {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    border: 3px solid #00a884;
    margin-bottom: 1.5rem;
    display: inline-block;
}

.qr-code-container img {
    width: 256px;
    height: 256px;
    display: block;
}

.qr-instructions {
    text-align: left;
    margin: 0 auto;
    max-width: 320px;
    color: #8696a0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.qr-instructions li {
    margin-bottom: 0.5rem;
}

.qr-instructions strong {
    color: #00a884;
}

/* Admin Modal */
.admin-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.admin-modal-content {
    background: #202c33;
    padding: 2rem;
    border-radius: 16px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out;
    position: relative;
}

.admin-modal-content h2 {
    color: #00a884;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #2a3942;
}

.admin-tab {
    background: transparent;
    border: none;
    padding: 12px 24px;
    color: #8696a0;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
}

.admin-tab:hover {
    color: #e9edef;
}

.admin-tab.active {
    color: #00a884;
    border-bottom-color: #00a884;
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

.admin-section {
    margin-bottom: 2rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.admin-header h3 {
    color: #e9edef;
    font-size: 1.2rem;
}

.btn-add {
    background: #00a884;
    color: #111b21;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.btn-add:hover {
    background: #06cf9c;
}

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-tecnico-item {
    background: #2a3942;
    padding: 16px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.admin-tecnico-item:hover {
    background: #374248;
}

.admin-tecnico-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.admin-tecnico-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

.admin-tecnico-name {
    font-size: 1rem;
    color: #e9edef;
    font-weight: 600;
}

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

.btn-edit, .btn-delete {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-edit {
    background: #667781;
    color: white;
}

.btn-edit:hover {
    background: #8696a0;
}

.btn-delete {
    background: #ef4444;
    color: white;
}

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

/* Tecnico Form */
.tecnico-form {
    background: #111b21;
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1.5rem;
}

.tecnico-form h3 {
    color: #00a884;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    color: #8696a0;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    background: #2a3942;
    border: 1px solid #374248;
    border-radius: 8px;
    color: #e9edef;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #00a884;
}

.color-picker-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-group input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.color-preview {
    padding: 8px 16px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 1.5rem;
}

.form-actions button {
    flex: 1;
}

/* User Management */
.admin-user-item {
    background: #2a3942;
    padding: 16px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.admin-user-item:hover {
    background: #374248;
}

.admin-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.admin-user-name {
    font-size: 1rem;
    color: #e9edef;
    font-weight: 600;
}

.admin-user-details {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.85rem;
    color: #8696a0;
}

.admin-user-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.admin-user-badge.admin {
    background: #8b5cf6;
    color: white;
}

.admin-user-badge.tecnico {
    background: #3b82f6;
    color: white;
}

.admin-user-badge.2fa-enabled {
    background: #10b981;
    color: white;
}

.admin-user-badge.2fa-disabled {
    background: #f59e0b;
    color: white;
}

.admin-user-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-reset-password,
.btn-reset-2fa {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-reset-password {
    background: #f59e0b;
    color: white;
}

.btn-reset-password:hover {
    background: #d97706;
}

.btn-reset-2fa {
    background: #8b5cf6;
    color: white;
}

.btn-reset-2fa:hover {
    background: #7c3aed;
}

/* User Form */
.user-form {
    background: #111b21;
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1.5rem;
}

.user-form h3 {
    color: #00a884;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.user-form select {
    width: 100%;
    padding: 10px 12px;
    background: #2a3942;
    border: 1px solid #374248;
    border-radius: 8px;
    color: #e9edef;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    cursor: pointer;
}

.user-form select:focus {
    outline: none;
    border-color: #00a884;
}

/* Badge Categoria */
.badge-categoria {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #667781;
    color: white;
}

/* Badge Note */
.badge-note {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #ff9800;
    color: white;
    cursor: help;
    transition: all 0.2s;
}

.badge-note:hover {
    background: #f57c00;
    transform: scale(1.05);
}

/* Report Modal */
.report-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.report-modal-content {
    background: #202c33;
    padding: 2rem;
    border-radius: 16px;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out;
    position: relative;
}

.report-modal-content h2 {
    color: #8b5cf6;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.report-info {
    background: #111b21;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 2rem;
}

.report-info-item {
    color: #8696a0;
    font-size: 0.9rem;
}

.report-info-item strong {
    color: #e9edef;
    margin-right: 0.5rem;
}

.report-content {
    background: #111b21;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    color: #e9edef;
    line-height: 1.6;
    white-space: pre-wrap;
    font-family: 'Segoe UI', sans-serif;
}

.loading-report {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #8696a0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #2a3942;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.report-actions {
    display: flex;
    gap: 1rem;
}

.report-actions button {
    flex: 1;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #202c33;
    color: #e9edef;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.3s ease-out;
    pointer-events: all;
    border-left: 4px solid;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.info {
    border-left-color: #3b82f6;
}

.toast.warning {
    border-left-color: #f59e0b;
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.toast-message {
    font-size: 0.85rem;
    color: #8696a0;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #e9edef;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.hiding {
    animation: slideOutRight 0.3s ease-out forwards;
}

/* ===== NUOVE FUNZIONALITÀ: MEDIA E QUOTE ===== */

/* Pulsante Allega File */
.btn-attach {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    transition: transform 0.2s;
}

.btn-attach:hover {
    transform: scale(1.1);
}

/* Preview File Selezionato */
.file-preview {
    background: #f0f2f5;
    border: 1px solid #d1d7db;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 12px 0;
}

.file-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-type {
    flex-shrink: 0;
}

.file-name {
    flex: 1;
    font-size: 14px;
    color: #3b4a54;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-cancel {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
}

.file-cancel:hover {
    background: #dc2626;
}

/* Preview Risposta (Quote) */
.reply-preview {
    background: #e7f3e7;
    border-left: 4px solid #00a884;
    padding: 8px 12px;
    margin: 8px 12px 0;
    border-radius: 4px;
}

.reply-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #00a884;
    font-weight: 500;
}

.reply-text {
    font-size: 14px;
    color: #667781;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-cancel {
    background: transparent;
    border: none;
    color: #667781;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 20px;
    height: 20px;
    line-height: 1;
}

.reply-cancel:hover {
    color: #ef4444;
}

/* Messaggio con Quote */
.quoted-message {
    background: rgba(0, 168, 132, 0.1);
    border-left: 4px solid #00a884;
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 4px;
    display: flex;
    gap: 8px;
}

.quoted-bar {
    width: 4px;
    background: #00a884;
    border-radius: 2px;
}

.quoted-content {
    flex: 1;
    min-width: 0;
}

.quoted-sender {
    font-size: 13px;
    font-weight: 600;
    color: #00a884;
    margin-bottom: 2px;
}

.quoted-text {
    font-size: 13px;
    color: #667781;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Media nei Messaggi */
.message-media {
    margin-bottom: 8px;
}

.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    display: block;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-video {
    max-width: 300px;
    border-radius: 8px;
    display: block;
}

.message-file {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 8px;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #3b4a54;
}

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

.file-name {
    font-size: 14px;
    font-weight: 500;
}

/* Pulsante Risposta sui Messaggi */
.message {
    position: relative;
}

.reply-btn {
    position: absolute;
    top: 8px;
    right: -35px;
    background: white;
    border: 1px solid #d1d7db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #667781;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message:hover .reply-btn {
    display: flex;
}

.reply-btn:hover {
    background: #00a884;
    color: white;
    border-color: #00a884;
    transform: scale(1.1);
}

/* Modale Immagine */
.image-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    padding-top: 60px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.95);
}

.image-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    animation: zoom 0.3s;
}

@keyframes zoom {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.image-modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.image-modal-close:hover,
.image-modal-close:focus {
    color: #bbb;
}

.image-modal-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    font-size: 16px;
}

/* Responsive per mobile */
@media (max-width: 768px) {
    .message-image,
    .message-video {
        max-width: 200px;
    }

    .reply-btn {
        right: 8px;
        top: auto;
        bottom: 8px;
    }

    .image-modal-content {
        width: 100%;
        max-width: 100%;
    }
}
