/* Font Akko Pro - Brand Alperia */
@font-face {
    font-family: 'Akko Pro';
    src: local('Akko Pro Regular'), local('Akko-Pro-Regular'),
         url('/static/fonts/Akko Pro Regular/Akko Pro Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Variabili Colori Brand Alperia */
:root {
    --alperia-blue: #00547A;          /* Blu Alperia principale */
    --alperia-white: #FFFFFF;          /* Bianco Alperia */
    --alperia-gray-4: #4A4A4A;        /* Grigio Alperia 4 per testi documenti */
    --alperia-gray-light: #F5F5F5;    /* Grigio chiaro per sfondi */
    --alperia-gray-border: #DDDDDD;    /* Grigio per bordi */
}

/* Reset e Stili Globali */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Akko Pro', 'Arial', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
    background-color: var(--alperia-white);
    color: var(--alperia-gray-4);
    line-height: 1.5;
    font-weight: 400;
}

h2, h3 {
    text-transform: uppercase;
    font-weight: 700; /* Bold per simulare Medium */
    margin-bottom: 20px;
    color: var(--alperia-blue);
    font-family: 'Akko Pro', Arial, sans-serif;
}

label {
    display: block;
    font-weight: 700; /* Bold per simulare Medium */
    margin-bottom: 5px;
    color: var(--alperia-gray-4);
    font-family: 'Akko Pro', Arial, sans-serif;
}

/* Back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--alperia-blue);
    text-decoration: none;
    font-family: 'Akko Pro', Arial, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: fit-content;
}

.back-link:hover {
    background-color: rgba(0, 84, 122, 0.05);
    color: #004058;
}

.back-link i {
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.back-link:hover i {
    transform: translateX(-3px);
}

i {
    cursor: pointer;
    margin: 0 5px;
    color: var(--alperia-blue);
    transition: color 0.3s ease;
}

i:hover {
    color: #004058; /* Versione più scura del blu Alperia */
}

/* Contenitori e Layout */
.container {
    width: 90%;
    max-width: 1400px;
    margin: 20px auto;
}

.placeholder-box {
    background-color: var(--alperia-gray-light);
    border-radius: 4px;
    padding: 15px;
    min-height: 100px;
    margin-bottom: 15px;
    border: 1px solid var(--alperia-gray-border);
    color: var(--alperia-gray-4);
    transition: all 0.2s ease;
}

.placeholder-box:focus-within {
    border-color: var(--alperia-blue);
    box-shadow: 0 0 0 2px rgba(0, 84, 122, 0.1);
}

/* Input e textarea dentro placeholder-box */
.placeholder-box input[type="text"],
.placeholder-box textarea,
.placeholder-box select {
    background-color: var(--alperia-white);
    border: 1px solid var(--alperia-gray-border);
    border-radius: 4px;
    padding: 12px;
    width: 100%;
    font-family: 'Akko Pro', Arial, sans-serif;
    font-size: 1rem;
    color: var(--alperia-gray-4);
    transition: all 0.2s ease;
}

.placeholder-box input[type="text"]:focus,
.placeholder-box textarea:focus,
.placeholder-box select:focus {
    outline: none;
    border-color: var(--alperia-blue);
    box-shadow: 0 0 0 2px rgba(0, 84, 122, 0.1);
}

.placeholder-box select {
    appearance: none;
    background-color: var(--alperia-white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300547A' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
    cursor: pointer;
    min-height: 44px;
}

.placeholder-box select:hover {
    border-color: var(--alperia-blue);
    background-color: rgba(0, 84, 122, 0.02);
}

.placeholder-box select:focus {
    outline: none;
    border-color: var(--alperia-blue);
    box-shadow: 0 0 0 2px rgba(0, 84, 122, 0.1);
    background-color: var(--alperia-white);
}

/* Header Principale */
.main-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 15px 5%;
    background-color: var(--alperia-white);
    border-bottom: 2px solid var(--alperia-blue);
    font-weight: 700; /* Bold */
    position: relative;
    z-index: 100;
}

.main-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.main-header .logo-img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.main-header .logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    font-style: italic;
    color: var(--alperia-blue);
    font-family: 'Akko Pro', Arial, sans-serif;
}

.main-header nav {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 15px;
}

.main-header nav a {
    text-decoration: none;
    color: var(--alperia-gray-4);
    margin-left: 25px;
    font-family: 'Akko Pro', Arial, sans-serif;
    font-weight: 400;
    transition: color 0.3s ease;
    position: relative;
    z-index: 1;
    cursor: pointer;
    pointer-events: auto;
}

.main-header nav a:first-child {
    margin-left: 0;
}

.main-header nav a:hover {
    color: var(--alperia-blue);
}

.main-header nav a.active {
    color: var(--alperia-blue);
    text-decoration: underline;
    font-weight: 500;
}

/* Header Actions (logout, etc.) */
.main-header .header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.main-header .logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: transparent;
    border: 2px solid var(--alperia-blue);
    color: var(--alperia-blue);
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.main-header .logout-btn:hover {
    background-color: var(--alperia-blue);
    color: var(--alperia-white);
    transform: scale(1.05);
}

.main-header .logout-btn i {
    font-size: 1.2rem;
    color: inherit;
}

/* Bottoni */
.btn {
    padding: 10px 18px;
    background-color: var(--alperia-white);
    border: 1px solid var(--alperia-blue);
    color: var(--alperia-blue);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700; /* Bold */
    border-radius: 4px;
    font-family: 'Akko Pro', Arial, sans-serif;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn:hover {
    background-color: var(--alperia-blue);
    color: var(--alperia-white);
}

.btn-primary {
    background-color: var(--alperia-blue);
    color: var(--alperia-white);
    border: none;
    text-decoration: none;
}

a.btn,
a.btn-primary {
    text-decoration: none !important;
}

button.btn,
a.btn,
button.btn-primary,
a.btn-primary {
    height: auto;
    min-height: 38px;
    box-sizing: border-box;
    vertical-align: middle;
}

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

.btn-primary:hover {
    background-color: #004058; /* Versione più scura del blu Alperia */
}

.btn-detail {
    background-color: var(--alperia-blue);
    color: var(--alperia-white);
    border: none;
    padding: 5px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-detail i {
    color: var(--alperia-white);
}

.btn-detail:hover {
    background-color: #004058;
}

.btn-full-width {
    width: 100%;
    padding: 12px;
}

/* Form e Input */
input[type="text"],
input[type="password"],
input[type="search"],
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--alperia-gray-border);
    background-color: var(--alperia-white);
    border-radius: 4px;
    font-size: 1rem;
    color: var(--alperia-gray-4);
    font-family: 'Akko Pro', Arial, sans-serif;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--alperia-blue);
    box-shadow: 0 0 0 2px rgba(0, 84, 122, 0.1);
}

textarea {
    min-height: 150px;
    resize: vertical;
}

/* Textarea risposta più grande per allineamento con chat */
#responseText {
    min-height: 400px;
    height: 400px;
}

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    align-items: center;
    flex-wrap: wrap;
    padding: 15px;
    background-color: var(--alperia-gray-light);
    border-radius: 4px;
    border: 1px solid var(--alperia-gray-border);
}

.filters input[type="search"] {
    flex: 2;
    min-width: 200px;
    padding: 10px 15px;
    border: 1px solid var(--alperia-gray-border);
    border-radius: 4px;
    font-family: 'Akko Pro', Arial, sans-serif;
    font-size: 0.95rem;
    color: var(--alperia-gray-4);
    background-color: var(--alperia-white);
    transition: all 0.2s ease;
}

.filters input[type="search"]:focus {
    outline: none;
    border-color: var(--alperia-blue);
    box-shadow: 0 0 0 2px rgba(0, 84, 122, 0.1);
}

.filters select {
    flex: 1;
    min-width: 160px;
    padding: 10px 12px;
    border: 1px solid var(--alperia-gray-border);
    border-radius: 4px;
    font-family: 'Akko Pro', Arial, sans-serif;
    font-size: 0.95rem;
    color: var(--alperia-gray-4);
    background-color: var(--alperia-white);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300547A' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

.filters select:hover {
    border-color: var(--alperia-blue);
    background-color: rgba(0, 84, 122, 0.02);
}

.filters select:focus {
    outline: none;
    border-color: var(--alperia-blue);
    box-shadow: 0 0 0 2px rgba(0, 84, 122, 0.1);
}

.filters .btn-primary {
    white-space: nowrap;
    padding: 10px 20px;
    margin-left: auto;
}

/* Schermata Login */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--alperia-white);
}

.login-container {
    background-color: var(--alperia-white);
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 450px;
    border: 2px solid var(--alperia-blue);
    box-shadow: 0 4px 6px rgba(0, 84, 122, 0.1);
}

.login-container h2 {
    text-align: center;
    color: var(--alperia-blue);
}

.login-container .input-group {
    margin-bottom: 15px;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    background-color: var(--alperia-white);
}

.remember-me {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}
.remember-me input {
    margin-right: 8px;
    width: auto;
}

/* Lista Richieste / Template */
.list-box {
    background-color: var(--alperia-gray-light);
    padding: 10px;
    border-radius: 4px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--alperia-white);
    padding: 12px;
    border-bottom: 2px solid var(--alperia-gray-light);
    color: var(--alperia-gray-4);
}

.list-item:hover {
    background-color: rgba(0, 84, 122, 0.05);
}
/* Stili template-list ora definiti più in basso */

/* Tabella Ticket */
.table-container {
    background-color: var(--alperia-gray-light);
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
}

.tickets-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--alperia-white);
    border-radius: 4px;
    overflow: hidden;
}

.tickets-table thead {
    background-color: var(--alperia-blue);
    color: var(--alperia-white);
}

.tickets-table th {
    padding: 12px;
    text-align: left;
    font-weight: 700;
    font-family: 'Akko Pro', Arial, sans-serif;
    text-transform: uppercase;
    font-size: 0.9rem;
    border-bottom: 2px solid var(--alperia-blue);
}

.tickets-table tbody tr {
    border-bottom: 1px solid var(--alperia-gray-border);
    transition: background-color 0.2s ease;
}

.tickets-table tbody tr:hover {
    background-color: rgba(0, 84, 122, 0.05);
}

.tickets-table td {
    padding: 12px;
    color: var(--alperia-gray-4);
    font-family: 'Akko Pro', Arial, sans-serif;
    vertical-align: middle;
}

.tickets-table .ticket-id-cell {
    width: 100px;
    font-weight: 600;
}

.tickets-table .category-cell {
    width: 200px;
}

.tickets-table .message-cell {
    width: auto;
    max-width: 400px;
    word-wrap: break-word;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tickets-table .status-cell {
    width: 150px;
}

.tickets-table .detail-cell {
    width: 120px;
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    background-color: white;
    border: 1px solid;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Elabora Risposta */
.top-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
    width: 100%;
    background-color: var(--alperia-gray-light);
    padding: 0;
    border-radius: 4px;
    border: 1px solid var(--alperia-gray-border);
    box-sizing: border-box;
}

.ticket-message-box {
    background-color: transparent;
    padding: 15px;
    border: none;
    display: flex;
    flex-direction: column;
    height: 235px;
    box-sizing: border-box;
}

.ticket-message-box h3 {
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--alperia-blue);
    text-transform: uppercase;
    font-weight: 700;
    flex-shrink: 0;
}

.message-content {
    margin-top: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.message-content strong {
    display: block;
    margin-bottom: 8px;
    color: var(--alperia-gray-4);
    font-weight: 700;
    flex-shrink: 0;
}

.message-text {
    background-color: var(--alperia-white);
    padding: 0 10px;
    border-radius: 4px;
    border: 1px solid var(--alperia-gray-border);
    flex: 1;
    overflow-y: auto;
    white-space: pre-line;
    word-wrap: break-word;
    min-height: 0;
    line-height: 1.4;
}

.message-text p {
    margin: 0;
    padding: 10px 0;
    color: var(--alperia-gray-4);
}

.requester-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    box-sizing: border-box;
}

.requester-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0;
    flex-shrink: 0;
}

.requester-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--alperia-blue);
    text-transform: uppercase;
    font-weight: 700;
}

.requester-content-row {
    display: flex;
    flex-direction: row;
    gap: 15px;
    align-items: flex-start;
    flex: 1;
}

.requester-details-box {
    background-color: transparent;
    padding: 0;
    border: none;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 235px;
    max-height: none;
}

.requester-info {
    margin-top: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
    margin-bottom: 0;
}

.requester-info p {
    margin: 8px 0;
    color: var(--alperia-gray-4);
    flex-shrink: 0;
}

.requester-info p:last-child {
    margin-bottom: 0;
}

.requester-info strong {
    color: var(--alperia-gray-4);
    font-weight: 700;
}

/* Evidenziazione campo Contatto (persona non fisica: società, condominio, ecc.) */
.requester-contact-highlight {
    padding: 6px 10px;
    margin: 6px 0;
    background-color: rgba(0, 102, 179, 0.08);
    border-left: 3px solid var(--alperia-blue, #0066b3);
    border-radius: 0 4px 4px 0;
}

.requester-header .btn {
    white-space: nowrap;
    height: fit-content;
    margin: 0;
}

/* Stili per il riquadro degli allegati */
.ticket-attachments-box {
    width: 300px;
    min-width: 250px;
    max-width: 350px;
    box-sizing: border-box;
    padding: 8px 10px;
    background-color: var(--alperia-white);
    border: 1px solid var(--alperia-gray-border);
    border-radius: 4px;
    flex-shrink: 0;
    overflow: hidden;
    margin-top: 0;
    align-self: flex-start;
}

.ticket-attachments-box h4 {
    margin: 0 0 6px 0;
    font-size: 0.85rem;
    color: var(--alperia-blue);
    font-weight: 600;
    text-transform: uppercase;
}

.ticket-attachments-list {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ticket-attachments-list > div {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background-color: var(--alperia-gray-light);
    border: 1px solid var(--alperia-gray-border);
    border-radius: 3px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ticket-attachments-list > div > span {
    flex: 1;
    min-width: 0;
    color: var(--alperia-gray-4);
    font-size: 0.85rem;
    word-break: break-word;
    overflow-wrap: break-word;
    margin-right: 4px;
    line-height: 1.3;
}

.ticket-attachments-list > div > i {
    flex-shrink: 0;
    cursor: pointer;
    color: var(--alperia-blue);
    font-size: 0.9rem;
    padding: 2px;
    transition: color 0.2s ease;
}

.elabora-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    box-sizing: border-box;
    align-items: start;
}

@media (max-width: 768px) {
    .elabora-grid {
        grid-template-columns: 1fr;
    }
    .top-section {
        grid-template-columns: 1fr;
    }
}

.response-area {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Assicura che il bottone invia risposta sia in fondo e allineato */
.response-area #sendBtn {
    margin-top: auto;
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
    height: 100%;
}


.info-box {
    min-height: 120px;
}

/* Avviso per ticket out-of-scope */
.out-of-scope-alert {
    background-color: #FFF3CD;
    border: 1px solid #FFC107;
    border-left: 4px solid #FFC107;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #856404;
    font-size: 0.95rem;
    font-family: 'Akko Pro', Arial, sans-serif;
}

.out-of-scope-alert i {
    color: #FFC107;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.out-of-scope-alert span {
    flex: 1;
}

.response-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
}
.response-actions i {
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--alperia-blue);
    transition: color 0.2s;
}
.response-actions i:hover {
    color: #004058;
}

.attachment-input {
    position: relative;
    margin-bottom: 15px;
}
.attachment-input i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
}

.attachment-section {
    margin-bottom: 15px;
}

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

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: var(--alperia-gray-light);
    border: 1px solid var(--alperia-gray-border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.attachment-item-name {
    flex: 1;
    color: var(--alperia-gray-4);
    margin-right: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-item-source {
    font-size: 0.75rem;
    color: var(--alperia-blue);
    margin-right: 10px;
    font-style: italic;
}

.attachment-item-remove {
    cursor: pointer;
    color: var(--alperia-blue);
    font-size: 0.9rem;
    padding: 2px 6px;
}

.attachment-item-remove:hover {
    color: #004058;
}

.history-area {
    background-color: var(--alperia-gray-light);
    padding: 15px;
    border-radius: 4px;
    max-height: 450px;
    overflow-y: auto;
}

/* Stile personalizzato per la scrollbar della history area */
.history-area::-webkit-scrollbar {
    width: 8px;
}

.history-area::-webkit-scrollbar-track {
    background: var(--alperia-gray-light);
    border-radius: 4px;
}

.history-area::-webkit-scrollbar-thumb {
    background: var(--alperia-blue);
    border-radius: 4px;
}

.history-area::-webkit-scrollbar-thumb:hover {
    background: #004058;
}

/* Finestra per lo storico ticket */
.history-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background-color: var(--alperia-white);
    border-radius: 4px;
    border: 2px solid var(--alperia-blue);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    cursor: move;
}

.history-window.dragging {
    cursor: grabbing;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 2px solid var(--alperia-blue);
    background-color: var(--alperia-blue);
    color: var(--alperia-white);
    cursor: move;
    user-select: none;
}

.history-window .modal-header h3 {
    margin: 0;
    color: var(--alperia-white);
}

.history-window .modal-header i {
    color: var(--alperia-white);
    transition: color 0.3s ease;
}

.history-window .modal-header i:hover {
    color: #ffcccc;
}

.history-window .history-area {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    max-height: calc(80vh - 70px);
    cursor: default;
}

/* Overlay per il modal del documento */
.document-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    visibility: visible;
    opacity: 1;
}

.document-modal-overlay.visible {
    display: block;
    visibility: visible;
    opacity: 1;
}

/* Modal per visualizzare documenti */
.document-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    max-height: 85vh;
    background-color: var(--alperia-white);
    border-radius: 4px;
    border: 2px solid var(--alperia-blue);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    display: none;
    flex-direction: column;
    cursor: move;
    visibility: visible;
    opacity: 1;
}

.document-modal.visible {
    display: flex;
    visibility: visible;
    opacity: 1;
}

.document-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 2px solid var(--alperia-blue);
    background-color: var(--alperia-blue);
    color: var(--alperia-white);
    cursor: move;
    user-select: none;
}

.document-modal .modal-header h3 {
    margin: 0;
    color: var(--alperia-white);
}

.document-modal .modal-header i {
    color: var(--alperia-white);
    transition: color 0.3s ease;
}

.document-modal .modal-header i:hover {
    color: #ffcccc;
}

.document-viewer {
    flex: 1;
    overflow: hidden;
    padding: 0;
    height: calc(85vh - 70px);
    min-height: 400px;
    cursor: default;
    background-color: #f5f5f5;
    position: relative;
    display: block;
    visibility: visible;
}

.document-viewer iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    visibility: visible;
    opacity: 1;
}

/* Modal Storico Utility forniture */
.supply-history-modal {
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
}

.supply-history-modal .modal-subtitle {
    margin: 4px 0 0 0;
    font-size: 0.9rem;
    font-weight: 400;
    opacity: 0.95;
}

.supply-history-modal-body {
    flex: 1;
    overflow: auto;
    padding: 15px;
    max-height: calc(85vh - 140px);
}

.supply-history-modal-body .table-container {
    overflow-x: auto;
    overflow-y: visible;
}

.supply-history-empty-msg {
    color: var(--alperia-gray-4);
    padding: 20px;
}

/* Tabella storico: valori su una linea, padding, bordi, zebra */
.supply-history-table {
    table-layout: auto;
    min-width: 700px;
}

.supply-history-table th,
.supply-history-table td {
    white-space: nowrap !important;
    padding: 10px 12px;
    border: 1px solid var(--alperia-gray-border);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    vertical-align: middle;
}

.supply-history-table th {
    background-color: var(--alperia-blue);
    color: var(--alperia-white);
    font-weight: 700;
}

.supply-history-table tbody tr {
    border-bottom: 1px solid var(--alperia-gray-border);
}

.supply-history-table tbody tr:nth-child(even):not(.current-utility-row) {
    background-color: var(--alperia-gray-light);
}

.supply-history-table tbody tr:nth-child(odd):not(.current-utility-row) {
    background-color: var(--alperia-white);
}

.supply-history-table tbody tr:hover {
    background-color: rgba(0, 84, 122, 0.06);
}

.supply-history-table .current-utility-row {
    background-color: rgba(0, 84, 122, 0.12);
}

.supply-history-table .current-utility-row:hover {
    background-color: rgba(0, 84, 122, 0.15);
}

.supply-history-table .current-utility-row td {
    font-weight: 600;
}

.badge-attiva {
    display: inline-block;
    padding: 4px 10px;
    background-color: rgba(16, 185, 129, 0.15);
    color: #047857;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-ultima-config {
    display: inline-block;
    padding: 4px 10px;
    background-color: rgba(245, 158, 11, 0.2);
    color: #b45309;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 600;
}

.supply-history-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 15px;
    border-top: 1px solid var(--alperia-gray-border);
    background-color: var(--alperia-gray-light);
}

.supply-history-modal .modal-footer .btn {
    min-width: 100px;
}

.accordion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--alperia-white);
    padding: 10px;
    border: 1px solid var(--alperia-gray-border);
    margin-bottom: 5px;
    font-weight: 700; /* Bold */
    color: var(--alperia-gray-4);
    cursor: pointer;
    transition: all 0.3s ease;
}

.accordion-item:hover {
    background-color: rgba(0, 84, 122, 0.05);
    border-color: var(--alperia-blue);
}

.chat-area {
    background-color: var(--alperia-gray-light);
    padding: 15px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--alperia-blue);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.chat-header h3 {
    color: var(--alperia-blue);
}
.chat-header i { font-size: 1.2rem; }

.chat-window {
    background-color: var(--alperia-white);
    padding: 10px;
    border-radius: 4px;
    flex-grow: 1;
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    color: var(--alperia-gray-4);
    min-width: 0;
}

/* Evita che messaggi con URL/errori lunghi espandano la chat */
.chat-window .chat-message {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Stile personalizzato per la scrollbar della chat */
.chat-window::-webkit-scrollbar {
    width: 8px;
}

.chat-window::-webkit-scrollbar-track {
    background: var(--alperia-gray-light);
    border-radius: 4px;
}

.chat-window::-webkit-scrollbar-thumb {
    background: var(--alperia-blue);
    border-radius: 4px;
}

.chat-window::-webkit-scrollbar-thumb:hover {
    background: #004058;
}

.chat-attachment {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}
.chat-attachment span { font-size: 0.9rem; }
.chat-attachment i { font-size: 1.1rem; }

.chat-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}
.feedback-icons i { font-size: 1.2rem; }

.chat-suggestions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}
.chat-suggestions .btn {
    flex: 1;
}

.chat-input {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.chat-input input { flex: 1; }
.chat-input i { font-size: 1.2rem; }

/* Dettaglio Template */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--alperia-gray-border);
}

.detail-header h2 {
    margin-bottom: 0;
}

.content-box {
    line-height: 1.8;
    color: var(--alperia-gray-4);
    min-height: 120px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Form Template */
.template-form {
    background-color: var(--alperia-gray-light);
    padding: 25px;
    border-radius: 4px;
    border: 1px solid var(--alperia-gray-border);
}

.template-form label {
    margin-top: 20px;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.template-form label:first-child {
    margin-top: 0;
}

.template-form .btn-primary {
    margin-top: 25px;
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

/* Lista Template migliorata */
.template-list {
    background-color: var(--alperia-white);
    border: 1px solid var(--alperia-gray-border);
    border-radius: 4px;
    overflow: hidden;
}

.template-list .list-item {
    border-bottom: 1px solid var(--alperia-gray-border);
    padding: 15px 20px;
    transition: background-color 0.2s ease;
}

.template-list .list-item:last-child {
    border-bottom: none;
}

.template-list .list-item:hover {
    background-color: rgba(0, 84, 122, 0.05);
}

.template-list .list-item span {
    font-size: 1rem;
    color: var(--alperia-gray-4);
    font-weight: 400;
    flex: 1;
}

/* Paginazione migliorata */
#pagination {
    margin-top: 30px;
    padding: 20px;
    background-color: var(--alperia-gray-light);
    border-radius: 4px;
    border: 1px solid var(--alperia-gray-border);
}

#pagination .btn {
    min-width: 100px;
    padding: 10px 20px;
}

#pageInfo {
    font-weight: 600;
    color: var(--alperia-blue);
    font-size: 0.95rem;
}

/* Admin: Log */
.log-section {
    margin-bottom: 25px;
}
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.log-header h3 {
    color: var(--alperia-blue);
}

.log-body {
    min-height: 200px;
    color: var(--alperia-gray-4);
}

/* Admin: Performance */
.report-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}
.chart-box {
    flex: 1;
    min-width: 250px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.chart-box span {
    font-weight: 700; /* Bold */
    color: var(--alperia-blue);
    font-family: 'Akko Pro', Arial, sans-serif;
}

.chart-box i {
    font-size: 4rem;
    margin: 15px;
    color: var(--alperia-blue);
}

/* Paginazione */
.pagination-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.pagination {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination .btn {
    min-width: 40px;
    padding: 8px 12px;
}

.pagination .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    color: var(--alperia-gray-4);
    font-size: 0.9rem;
    font-family: 'Akko Pro', Arial, sans-serif;
}
