/* ===================================================================
   PRONTO STRADE - Portale Operativo
   Stylesheet Principale con ID e CLASSI
   ACI Global Servizi S.p.A.
   
   STRUTTURA:
   - ID (#) = Elementi UNICI per pagina
   - CLASSI (.) = Elementi RIPETIBILI/RIUTILIZZABILI
   =================================================================== */

/* ===================================================================
   VARIABILI CSS (Brand Colors)
   =================================================================== */
:root {
    /* Colori Brand Pronto Strade */
    --ps-blue-primary: #0051A5;
    --ps-blue-dark: #003D7A;
    --ps-grey: #6D6E71;
    --ps-grey-light: #F5F5F5;
    
    /* Colori Funzionali */
    --ps-red: #E74C3C;
    --ps-red-light: #FFCCCB;
    --ps-green: #27AE60;
    --ps-yellow: #F39C12;
    
    /* Sfumature Grigio */
    --grey-100: #F8F9FA;
    --grey-200: #E9ECEF;
    --grey-300: #DEE2E6;
    --grey-400: #CED4DA;
    --grey-500: #ADB5BD;
    --grey-600: #6C757D;
    --grey-700: #495057;
    --grey-800: #343A40;
    --grey-900: #212529;
    
    /* Tipografia */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 32px;
    
    /* Spaziature */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 30px;
    --spacing-2xl: 40px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    --radius-full: 50%;
    
    /* Ombre */
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.3);
    
    /* Transizioni */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--grey-800);
    background: var(--ps-grey-light);
}

/* ===================================================================
   TIPOGRAFIA
   =================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--grey-900);
    margin-bottom: var(--spacing-md);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--ps-blue-primary);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--ps-blue-dark);
}

/* ===================================================================
   LAYOUT - HEADER/NAVBAR (ID - Elemento UNICO)
   =================================================================== */
#navbar,
.header {
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
    color: white;
    padding: var(--spacing-md) var(--spacing-xl);
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.logo {
    width: 50px;
    height: 50px;
}

.header h1,
#navbar h1 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: white;
    margin: 0;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.user-role {
    font-size: var(--font-size-xs);
    opacity: 0.9;
}

/* ===================================================================
   MAIN CONTENT (ID - Elemento UNICO)
   =================================================================== */
#main-content {
    flex: 1;
    padding: var(--spacing-xl);
    background: var(--ps-grey-light);
}

/* ===================================================================
   LOGIN PAGE (ID - Elementi UNICI)
   =================================================================== */
#login-container {
    width: 100%;
    max-width: 450px;
    animation: slideIn 0.5s ease-out;
}

#login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

#login-form {
    /* Stili specifici per il form di login */
}

.login-header {
    background: white;
    padding: var(--spacing-2xl) var(--spacing-xl) var(--spacing-xl);
    text-align: center;
}

.login-logo {
    width: 120px;
    height: 120px;
    margin: 0 auto var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-body {
    padding: var(--spacing-xl);
}

.login-footer {
    background: var(--grey-100);
    padding: var(--spacing-lg);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--grey-600);
}

/* ===================================================================
   DASHBOARD (ID - Elementi UNICI)
   =================================================================== */
#welcome-section {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-2xl);
    margin-bottom: var(--spacing-xl);
    text-align: center;
    animation: slideIn 0.5s ease-out;
}

#quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
}

/* ===================================================================
   STATISTICS BAR (ID - Elemento UNICO)
   =================================================================== */
#stats-bar,
.stats-bar {
    background: white;
    padding: var(--spacing-lg) var(--spacing-xl);
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

/* STAT CARDS (CLASSE - Elementi RIPETIBILI) */
.stat-card {
    flex: 1;
    min-width: 200px;
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card.anga-no {
    background: linear-gradient(135deg, #ffeaea 0%, var(--ps-red-light) 100%);
}

.stat-card.anga-si {
    background: linear-gradient(135deg, #e8e8e8 0%, #d3d3d3 100%);
}

.stat-card.blue {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}

.stat-card.green {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

.stat-card.yellow {
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--grey-600);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: var(--spacing-sm);
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--grey-900);
}

.stat-change {
    font-size: var(--font-size-xs);
    margin-top: var(--spacing-xs);
}

.stat-change.positive {
    color: var(--ps-green);
}

.stat-change.negative {
    color: var(--ps-red);
}

/* ===================================================================
   MAP CONTAINER (ID - Elemento UNICO)
   =================================================================== */
#commerciale-map,
#map-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-top: var(--spacing-xl);
}

.map-header {
    padding: var(--spacing-lg) var(--spacing-xl);
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-header h2 {
    margin: 0;
    color: white;
}

#map {
    width: 100%;
    height: 600px;
}

.legend {
    display: flex;
    gap: var(--spacing-lg);
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: white;
}

.legend-icon {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
}

.legend-icon.anga-no {
    background: var(--ps-red);
}

.legend-icon.anga-si {
    background: var(--grey-500);
}

/* ===================================================================
   SEARCH SECTION (ID - Elemento UNICO)
   =================================================================== */
#search-section {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xl);
    margin-top: var(--spacing-xl);
}

.search-tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
    border-bottom: 2px solid var(--grey-200);
}

.tab-button {
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    background: transparent;
    color: var(--grey-600);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all var(--transition-base);
}

.tab-button.active {
    color: var(--ps-blue-primary);
    border-bottom-color: var(--ps-blue-primary);
}

.tab-content {
    display: none;
}

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

/* ===================================================================
   DATA TABLE (ID - Elemento UNICO)
   =================================================================== */
#data-table,
#convenzioni-table,
#rete-table {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: var(--spacing-xl);
}

/* ===================================================================
   FILTERS (ID - Elemento UNICO)
   =================================================================== */
#filters-container,
#stats-container {
    padding: 0 var(--spacing-xl) var(--spacing-lg) var(--spacing-xl);
}

.filters-bar {
    display: flex;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg) var(--spacing-xl);
    background: var(--grey-100);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--grey-700);
    margin-bottom: var(--spacing-sm);
}

.filters-buttons {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    margin-bottom: var(--spacing-md);
}

.filters-geo {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    align-items: center;
}

.filter-field {
    flex: 1;
    min-width: 200px;
}

.filter-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--grey-700);
    margin-bottom: var(--spacing-xs);
}

/* ===================================================================
   BUTTONS (CLASSE - Elementi RIPETIBILI)
   =================================================================== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 81, 165, 0.4);
}

.btn-secondary {
    background: var(--grey-500);
    color: white;
}

.btn-secondary:hover {
    background: var(--grey-600);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--ps-blue-primary);
    color: var(--ps-blue-primary);
}

.btn-outline:hover {
    background: var(--ps-blue-primary);
    color: white;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all var(--transition-base);
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-size-sm);
}

.btn-success {
    background: var(--ps-green);
    color: white;
}

.btn-danger {
    background: var(--ps-red);
    color: white;
}

.btn-warning {
    background: var(--ps-yellow);
    color: white;
}

.btn-filter {
    padding: 8px 20px;
    border-radius: var(--radius-md);
    border: 2px solid var(--grey-300);
    background: white;
    color: var(--grey-700);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-filter.active {
    background: var(--ps-blue-primary);
    color: white;
    border-color: var(--ps-blue-primary);
}

/* ===================================================================
   FORMS (CLASSE - Elementi RIPETIBILI)
   =================================================================== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    color: var(--grey-700);
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--grey-300);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
    font-family: var(--font-family);
}

.form-control:focus {
    outline: none;
    border-color: var(--ps-blue-primary);
    box-shadow: 0 0 0 3px rgba(0, 81, 165, 0.1);
}

.form-control::placeholder {
    color: var(--grey-400);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
}

/* Input con icona */
.input-icon {
    position: relative;
}

.input-icon input {
    padding-left: 45px;
}

.input-icon::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-size: contain;
    opacity: 0.5;
}

.input-icon.user::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230051A5'%3E%3Cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E");
}

.input-icon.password::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230051A5'%3E%3Cpath d='M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z'/%3E%3C/svg%3E");
}

/* ===================================================================
   CARDS & CONTAINERS (CLASSE - Elementi RIPETIBILI)
   =================================================================== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-header {
    padding: var(--spacing-lg) var(--spacing-xl);
    border-bottom: 1px solid var(--grey-200);
}

.card-body {
    padding: var(--spacing-xl);
}

.card-footer {
    padding: var(--spacing-lg) var(--spacing-xl);
    border-top: 1px solid var(--grey-200);
    background: var(--grey-100);
}

.quick-link-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xl);
    text-align: center;
    transition: all var(--transition-base);
    cursor: pointer;
    animation: fadeIn 0.5s ease-out;
}

.quick-link-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.quick-link-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

/* ===================================================================
   TABLES (CLASSE - Elementi RIPETIBILI)
   =================================================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    background: white;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 1400px;
    border-collapse: collapse;
    background: white;
}

thead {
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
    color: white;
}

thead th {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
    font-weight: 600;
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    border-bottom: 1px solid var(--grey-200);
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--grey-100);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody td {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: var(--font-size-sm);
}

tbody tr:nth-child(even) {
    background: var(--grey-100);
}

tbody tr:nth-child(even):hover {
    background: var(--grey-200);
}

.table-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all var(--transition-base);
}

.action-view {
    background: var(--ps-blue-primary);
    color: white;
}

.action-edit {
    background: var(--ps-yellow);
    color: white;
}

.action-delete {
    background: var(--ps-red);
    color: white;
}

/* ===================================================================
   BADGES & LABELS (CLASSE - Elementi RIPETIBILI)
   =================================================================== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-xl);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: var(--ps-blue-primary);
    color: white;
}

.badge-success {
    background: var(--ps-green);
    color: white;
}

.badge-danger {
    background: var(--ps-red);
    color: white;
}

.badge-warning {
    background: var(--ps-yellow);
    color: white;
}

.badge-secondary {
    background: var(--grey-500);
    color: white;
}

.distance-badge {
    background: var(--ps-blue-primary);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

/* ===================================================================
   MODALS (CLASSE - Elementi RIPETIBILI)
   =================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
}

.modal-header {
    padding: var(--spacing-xl);
    border-bottom: 2px solid var(--grey-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
    color: white;
}

.modal-header h2 {
    margin: 0;
    color: white;
}

.modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.modal-close:hover {
    background: rgba(255,255,255,0.3);
}

.modal-body {
    padding: var(--spacing-xl);
}

.modal-footer {
    padding: var(--spacing-lg) var(--spacing-xl);
    border-top: 1px solid var(--grey-200);
    background: var(--grey-100);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
}

/* ===================================================================
   ALERTS & MESSAGES (CLASSE - Elementi RIPETIBILI)
   =================================================================== */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    border-left: 4px solid;
}

.alert-success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--ps-green);
    border-color: var(--ps-green);
}

.alert-danger {
    background: rgba(231, 76, 60, 0.1);
    color: var(--ps-red);
    border-color: var(--ps-red);
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    color: var(--ps-yellow);
    border-color: var(--ps-yellow);
}

.alert-info {
    background: rgba(0, 81, 165, 0.1);
    color: var(--ps-blue-primary);
    border-color: var(--ps-blue-primary);
}

.error-message {
    background: var(--ps-red-light);
    color: var(--ps-red);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    font-size: var(--font-size-sm);
    border-left: 4px solid var(--ps-red);
    animation: shake 0.5s;
}

/* ===================================================================
   CONVENZIONI - SEZIONI E LAYOUT
   =================================================================== */
.convenzioni-header-subtitle {
    margin: 0;
    color: var(--grey-500);
}

.stats-container {
    padding: 0 var(--spacing-xl) var(--spacing-lg) var(--spacing-xl);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
}

.select-geo {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--grey-300);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    background-color: white;
    cursor: pointer;
}

.select-geo:focus {
    outline: none;
    border-color: var(--ps-blue-primary);
    box-shadow: 0 0 0 3px rgba(0, 81, 165, 0.1);
}

/* CARD STATISTICHE */
.stat-card-blue {
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
}

.stat-card-orange {
    background: linear-gradient(135deg, #F39C12 0%, #E67E22 100%);
}

.stat-card-red {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
}

.stat-card-title {
    font-size: var(--font-size-sm);
    opacity: 0.9;
    margin-bottom: var(--spacing-xs);
}

.stat-card-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.stat-card-subtitle {
    font-size: var(--font-size-xs);
    opacity: 0.8;
}

/* HEADER TABELLE */
.table-header-wrapper {
    padding: var(--spacing-xl) var(--spacing-xl) 0 var(--spacing-xl);
}

.table-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.table-header-active {
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
}

.table-header-expired {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
}

.table-header h3 {
    margin: 0;
    font-size: var(--font-size-xl);
    color: white !important;
}

.table-header-subtitle {
    font-size: var(--font-size-sm);
    opacity: 0.9;
}

/* CELLE TABELLA */
.cell-expired {
    background: rgba(231, 76, 60, 0.15);
    font-weight: bold;
    color: #C0392B;
}

.cell-expired-days {
    font-size: 11px;
    opacity: 0.8;
}

.cell-center {
    text-align: center;
    font-weight: bold;
}

.cell-mail-link {
    color: var(--ps-blue-primary);
    text-decoration: none;
}

.cell-empty {
    color: var(--grey-400);
}

.row-expired {
    background: rgba(231, 76, 60, 0.05);
}

/* TABELLE BORDER E THEAD */
.table-border-blue {
    border-top: 3px solid var(--ps-blue-primary);
}

.table-border-red {
    border-top: 3px solid #E74C3C;
}

.thead-blue {
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
}

.thead-red {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
}

.table-container-zero-margin {
    margin-top: 0;
}

.th-center {
    text-align: center;
}

.th-highlight {
    background: rgba(255, 255, 255, 0.2);
}

.table-header * {
    color: white;
}

/* ===================================================================
   NAVBAR COMPONENTS
   =================================================================== */
.navbar {
    background: linear-gradient(135deg, var(--ps-blue-primary) 0%, var(--ps-blue-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-xl);
    max-width: 1600px;
    margin: 0 auto;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-xl);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    text-decoration: none;
    color: white;
}

.navbar-logo {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.navbar-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin: 0;
    color: white;
}

.navbar-menu {
    display: flex;
    gap: var(--spacing-sm);
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-menu li a {
    display: block;
    padding: 10px 20px;
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.navbar-menu li a:hover {
    background: rgba(255, 255, 255, 0.15);
}

.navbar-menu li a.active {
    background: rgba(255, 255, 255, 0.25);
    font-weight: 600;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: var(--radius-md);
}

.user-avatar {
    width: 35px;
    height: 35px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-lg);
    text-transform: uppercase;
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.user-role {
    font-size: 0.75em;
    opacity: 0.9;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mobile-menu-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.5em;
    transition: all var(--transition-base);
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===================================================================
   UTILITY CLASSES
   =================================================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.p-0 { padding: 0; }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* ===================================================================
   ANIMATIONS
   =================================================================== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

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

.animate-slide-in {
    animation: slideIn 0.5s ease-out;
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

.animate-shake {
    animation: shake 0.5s;
}

/* ===================================================================
   RESPONSIVE DESIGN
   =================================================================== */
@media (max-width: 768px) {
    .header,
    #navbar {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .navbar-container {
        flex-wrap: wrap;
    }
    
    .navbar-menu {
        display: none;
        width: 100%;
        flex-direction: column;
        margin-top: var(--spacing-md);
    }
    
    .navbar-menu.active {
        display: flex;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .navbar-left {
        flex: 1;
    }
    
    .user-details {
        display: none;
    }
    
    #stats-bar,
    .stats-bar {
        flex-direction: column;
    }
    
    .stat-card {
        min-width: 100%;
    }
    
    .legend {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
    
    .map-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }
    
    .filters-bar {
        flex-direction: column;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    #quick-links {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: var(--font-size-xs);
    }
    
    thead th,
    tbody td {
        padding: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    :root {
        --font-size-base: 14px;
        --font-size-3xl: 24px;
        --spacing-xl: 20px;
    }
    
    .header h1,
    #navbar h1 {
        font-size: var(--font-size-xl);
    }
    
    .logo {
        width: 40px;
        height: 40px;
    }
}

/* ===================================================================
   DASHBOARD PRINCIPALE
   =================================================================== */

/* ── Layout generale ── */
.dashboard-body {
    background: #f0f2f7;
}

.dashboard-main {
    flex: 1;
    padding: var(--spacing-xl);
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ── Hero Banner ── */
.hero-banner {
    background: linear-gradient(135deg, #1a2f6e 0%, #2c5cc5 60%, #1e4db7 100%);
    color: white;
    padding: 40px 48px;
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-xl);
    box-shadow: 0 8px 32px rgba(28, 47, 110, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    position: relative;
    overflow: hidden;
}

.hero-banner::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.hero-banner::after {
    content: '';
    position: absolute;
    bottom: -80px;
    right: 100px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 50%;
}

.hero-text {
    z-index: 1;
}

/* Sovrascrive il colore scuro globale di h1-h6 dentro il banner */
.hero-banner h1,
.hero-banner h2,
.hero-banner h3,
.hero-banner p {
    color: white;
    margin-bottom: 0;
}

.hero-greeting {
    font-size: 0.95em;
    opacity: 0.75;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: white;
}

.hero-title {
    font-size: 2em;
    font-weight: 700;
    margin: 0 0 10px 0;
    letter-spacing: -0.01em;
    color: white;
}

.hero-subtitle {
    font-size: 1em;
    opacity: 0.85;
    max-width: 560px;
    line-height: 1.6;
    color: white;
    margin: 0;
}

.hero-badge-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1;
    flex-shrink: 0;
}

.hero-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px 18px;
    text-align: center;
    backdrop-filter: blur(4px);
}

.hero-badge .badge-value {
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1;
    color: white;
}

.hero-badge .badge-label {
    font-size: 0.75em;
    opacity: 0.75;
    margin-top: 3px;
    color: white;
}

#liveClock {
    font-size: 2em;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: white;
}

/* ── Etichetta sezione ── */
.section-label {
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--grey-600);
    margin-bottom: var(--spacing-md);
}

/* ── Griglia moduli ── */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.module-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 28px 24px;
    text-align: center;
    transition: all 0.25s ease;
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.module-card.blue::before   { background: linear-gradient(90deg, #2c5cc5, #667eea); }
.module-card.green::before  { background: linear-gradient(90deg, #16a34a, #22c55e); }
.module-card.orange::before { background: linear-gradient(90deg, #d97706, #f59e0b); }
.module-card.purple::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.module-card.teal::before   { background: linear-gradient(90deg, #0f766e, #2dd4bf); }

.module-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    border-color: #e2e8f0;
}

.module-icon {
    font-size: 42px;
    margin-bottom: 14px;
    display: block;
    line-height: 1;
}

.module-card h3 {
    color: #1e293b;
    font-size: 1.05em;
    font-weight: 700;
    margin: 0 0 6px 0;
}

.module-card p {
    color: var(--grey-600);
    font-size: 0.85em;
    margin: 0;
    line-height: 1.5;
}

/* ── Pannello inferiore ── */
.dashboard-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.info-panel {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: var(--spacing-xl);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid #f1f5f9;
}

.panel-header-icon {
    font-size: 1.4em;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
    color: #1e293b;
}

/* ── Link utili esterni ── */
.ext-link-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ext-link-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    transition: all 0.2s;
}

.ext-link-item:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    transform: translateX(4px);
}

.ext-link-logo {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    flex-shrink: 0;
    overflow: hidden;
}

.ext-link-info {
    flex: 1;
}

.ext-link-name {
    display: block;
    font-weight: 700;
    font-size: 0.9em;
    color: #1e293b;
}

.ext-link-desc {
    display: block;
    font-size: 0.78em;
    color: var(--grey-500);
    margin-top: 2px;
}

.ext-link-arrow {
    color: var(--grey-500);
    font-size: 0.8em;
    flex-shrink: 0;
}

/* ── Info aziendale ── */
.company-info-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.company-info-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.company-info-bullet {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    flex-shrink: 0;
    margin-top: 2px;
}

.company-info-bullet.blue   { background: #dbeafe; }
.company-info-bullet.green  { background: #dcfce7; }
.company-info-bullet.orange { background: #fef3c7; }
.company-info-bullet.red    { background: #fee2e2; }

.company-info-text strong {
    display: block;
    font-size: 0.9em;
    color: #1e293b;
    font-weight: 700;
}

.company-info-text span {
    font-size: 0.82em;
    color: var(--grey-600);
    line-height: 1.4;
}

/* ── Footer note ── */
.dashboard-footer-note {
    text-align: center;
    color: var(--grey-500);
    font-size: 0.8em;
    padding-bottom: var(--spacing-lg);
}

.dashboard-footer-note a {
    color: var(--ps-blue-primary);
    text-decoration: none;
}

/* ── Responsive dashboard ── */
@media (max-width: 1024px) {
    .dashboard-bottom-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .hero-banner {
        flex-direction: column;
        padding: 28px 24px;
    }

    .hero-badge-group {
        flex-direction: row;
        width: 100%;
        justify-content: center;
    }

    .modules-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .modules-grid {
        grid-template-columns: 1fr;
    }
}

/* ===================================================================
   PRINT STYLES
   =================================================================== */
@media print {
    .header,
    #navbar,
    .btn,
    .filters-bar {
        display: none;
    }
    
    #map-container,
    #commerciale-map {
        margin: 0;
        box-shadow: none;
    }
    
    body {
        background: white;
    }
}
