/* =====================================================
   STILI GLOBALI APPLICAZIONE
   ===================================================== */

:root {
    --primary: #2196F3;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
}

/* =====================================================
   DARK MODE - VARIABILI GLOBALI
   ===================================================== */
html.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #444;
}

html.dark-mode html,
html.dark-mode body {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

html.dark-mode main {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

html.dark-mode .container-main {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

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

html, body {
    height: 100%;
    background-color: #f8f9fa;
}

body {
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
}

main {
    flex: 1;
    padding: 30px 0;
}

/* =====================================================
   TABELLE - STILI GLOBALI
   ===================================================== */

.table {
    font-size: 0.85rem;
    margin-bottom: 0;
}

.table thead th {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.5rem;
    border-bottom: 2px solid #dee2e6;
}

.table tbody td {
    padding: 0.5rem;
    font-size: 0.8rem;
}

.table tbody tr:hover {
    background-color: #f5f5f5;
}

/* =====================================================
   CARD - STILI GLOBALI
   ===================================================== */

.card {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1.25rem;
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.card-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
}

.card-header h5 {
    margin: 0;
    font-size: 1rem;
}

.card-body {
    padding: 1.25rem;
}

/* Header gradiente per card view */
.card-header.bg-primary {
    background: linear-gradient(135deg, #2196F3, #1565C0) !important;
    color: white;
}

.card-header.bg-warning {
    background: linear-gradient(135deg, #FF9800, #F57C00) !important;
    color: white;
}

.card-header.bg-success {
    background: linear-gradient(135deg, #4CAF50, #388E3C) !important;
    color: white;
}

.card-header.bg-danger {
    background: linear-gradient(135deg, #f44336, #d32f2f) !important;
    color: white;
}

.card-header.bg-info {
    background: linear-gradient(135deg, #00BCD4, #0097A7) !important;
    color: white;
}

/* =====================================================
   ETICHETTE E TESTO - STILI GLOBALI
   ===================================================== */

.form-label,
.view-label {
    color: #999;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.view-value {
    font-size: 1rem;
    color: #333;
    margin: 0;
}

.view-value strong {
    font-weight: 600;
}

/* =====================================================
   BADGE - STILI GLOBALI
   ===================================================== */

.badge {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-block;
}

/* =====================================================
   PULSANTI PRINCIPALE (Navbar)
   ===================================================== */

/* Stili generici per btn-group in tabelle responsive */
.btn-group {
    display: inline-flex !important;
    gap: 2px;
    flex-wrap: nowrap;
    width: auto;
    visibility: visible !important;
    overflow: visible !important;
}

.btn-group .btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    white-space: nowrap;
    border-radius: 0 !important;
    flex-shrink: 0;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
}

.btn-group .btn:first-child {
    border-radius: 0.25rem 0 0 0.25rem !important;
}

.btn-group .btn:last-child {
    border-radius: 0 0.25rem 0.25rem 0 !important;
}

.btn-group .btn i {
    display: inline;
    margin-right: 3px;
}

.btn-group .btn i:only-child {
    margin-right: 0;
}

/* Pulsanti piccoli */
.btn-sm {
    padding: 0.375rem 0.5rem !important;
    font-size: 0.8125rem !important;
}

.btn-sm i {
    font-size: 0.875rem;
}

/* Table responsive adjustments */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .btn-group {
    width: 100%;
    display: flex !important;
    flex-direction: row;
}

.table-responsive .btn-group .btn {
    flex: 1 1 auto;
    min-width: 32px;
    padding: 0.375rem 0.25rem !important;
}

.table-responsive td {
    vertical-align: middle;
    visibility: visible !important;
    overflow: visible !important;
}

.table-responsive td:last-child {
    min-width: 120px;
    overflow: visible !important;
}

/* =====================================================
   UTILITY
   ===================================================== */

.text-end {
    text-align: right;
}

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

.mt-4 {
    margin-top: 1.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
    margin-top: 10px;
    margin-left: 10px;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075) !important;
}

/* Clearfix */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* =====================================================
   MEDIA QUERIES - TABLET (768px - 1024px)
   ===================================================== */

@media (max-width: 1024px) {
    .table {
        font-size: 0.8rem;
    }

    .table thead th {
        font-size: 0.75rem;
        padding: 0.375rem;
    }

    .table tbody td {
        padding: 0.375rem;
        font-size: 0.75rem;
    }

    .btn-sm {
        padding: 0.25rem 0.375rem !important;
        font-size: 0.75rem !important;
    }

    .table-responsive .btn-group .btn {
        min-width: 28px;
        padding: 0.25rem 0.125rem !important;
    }

    .table-responsive td:last-child {
        min-width: 100px;
    }

    main {
        padding: 20px 0;
    }
}

/* =====================================================
   MEDIA QUERIES - MOBILE (< 768px)
   ===================================================== */

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    main {
        padding: 15px 0;
    }

    /* Riduci font delle tabelle */
    .table {
        font-size: 0.75rem;
        margin-bottom: 0;
    }

    .table thead th {
        font-size: 0.7rem;
        padding: 0.25rem;
        font-weight: 600;
    }

    .table tbody td {
        padding: 0.25rem;
        font-size: 0.7rem;
    }

    /* Pulsanti più piccoli su mobile */
    .btn-sm {
        padding: 0.2rem 0.3rem !important;
        font-size: 0.7rem !important;
    }

    .btn-sm i {
        font-size: 0.75rem;
    }

    /* Btn group su mobile */
    .table-responsive .btn-group {
        display: flex !important;
        gap: 1px;
    }

    .table-responsive .btn-group .btn {
        flex: 1 1 auto;
        min-width: 24px;
        padding: 0.2rem 0.1rem !important;
        font-size: 0.65rem !important;
    }

    .table-responsive .btn-group .btn i {
        margin-right: 1px;
    }

    /* Colonne più strette */
    .table-responsive td {
        padding: 0.25rem;
    }

    .table-responsive td:last-child {
        min-width: 80px;
    }
}

/* =====================================================
   STAT BOXES - RIEPILOGO CARD
   ===================================================== */

.stat-box {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 16px 12px;
    border-left: 4px solid #2196F3;
    min-height: 90px;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.stat-box:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

/* =====================================================
   MEDIA QUERY - RESPONSIVE DESIGN
   ===================================================== */

@media (max-width: 1024px) {
    /* Layout responsivo per due colonne (col-lg-9 diventa full width) */
    .col-lg-9,
    .col-lg-3 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .col-lg-9 {
        margin-bottom: 20px;
    }

    /* Summarysection diventa un overlay su mobile */
    .summary-section {
        position: relative !important;
        top: 0 !important;
        max-height: none !important;
        overflow-y: visible !important;
        margin-top: 30px;
    }
}

/* =====================================================
   DARK MODE - ELEMENTI GENERALI
   ===================================================== */

html.dark-mode .card {
    background-color: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .card-header {
    background-color: #3a3a3a !important;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .card-body {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

html.dark-mode .card-title,
html.dark-mode .card-text {
    color: #e0e0e0;
}

html.dark-mode .table {
    color: #e0e0e0;
    background-color: #2d2d2d;
    border-color: #444;
}

html.dark-mode .table thead th {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border-color: #444;
}

html.dark-mode .table tbody td {
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .table tbody tr:hover {
    background-color: #3a3a3a;
}

html.dark-mode .form-control,
html.dark-mode .form-select,
html.dark-mode .form-check-input {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border-color: #444;
}

html.dark-mode .form-control:focus,
html.dark-mode .form-select:focus {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border-color: #2196F3;
    box-shadow: 0 0 0 0.25rem rgba(33, 150, 243, 0.25);
}

html.dark-mode .form-check-input:checked {
    background-color: #2196F3;
    border-color: #2196F3;
}

html.dark-mode .form-label {
    color: #e0e0e0;
}

html.dark-mode .input-group-text {
    background-color: #3a3a3a;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .btn-primary {
    background-color: #2196F3;
    border-color: #2196F3;
    color: white;
}

html.dark-mode .btn-primary:hover {
    background-color: #1565C0;
    border-color: #1565C0;
}

html.dark-mode .btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
}

html.dark-mode .btn-outline-danger {
    color: #dc3545;
    border-color: #dc3545;
}

html.dark-mode .btn-outline-danger:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

html.dark-mode .dropdown-menu {
    background-color: #2d2d2d;
    border-color: #444;
}

html.dark-mode .dropdown-item {
    color: #e0e0e0;
}

html.dark-mode .dropdown-item:hover,
html.dark-mode .dropdown-item:focus {
    background-color: #3a3a3a;
    color: #e0e0e0;
}

html.dark-mode .dropdown-divider {
    border-color: #444;
}

html.dark-mode .list-group-item {
    background-color: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .list-group-item:hover {
    background-color: #3a3a3a;
}

html.dark-mode .list-group-item.active {
    background-color: #2196F3;
    border-color: #2196F3;
}

html.dark-mode .badge {
    background-color: #2196F3;
    color: white;
}

html.dark-mode .badge.bg-danger {
    background-color: #dc3545 !important;
}

html.dark-mode .badge.bg-success {
    background-color: #28a745 !important;
}

html.dark-mode .badge.bg-secondary {
    background-color: #6c757d !important;
}

html.dark-mode .badge.bg-warning {
    background-color: #ffc107 !important;
    color: #333;
}

html.dark-mode .badge.bg-info {
    background-color: #17a2b8 !important;
}

html.dark-mode .alert {
    background-color: #3a3a3a;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    border-color: #dc3545;
    color: #ff6b6b;
}

html.dark-mode .alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    border-color: #28a745;
    color: #51cf66;
}

html.dark-mode .text-muted {
    color: #b0b0b0 !important;
}

html.dark-mode .text-secondary {
    color: #b0b0b0 !important;
}

html.dark-mode .border {
    border-color: #444 !important;
}

html.dark-mode hr {
    border-color: #444;
}

html.dark-mode .pagination .page-link {
    background-color: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .pagination .page-link:hover {
    background-color: #3a3a3a;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .pagination .page-item.active .page-link {
    background-color: #2196F3;
    border-color: #2196F3;
}

html.dark-mode .modal-content {
    background-color: #2d2d2d;
    color: #e0e0e0;
    border-color: #444;
}

html.dark-mode .modal-header {
    background-color: #3a3a3a;
    border-color: #444;
}

html.dark-mode .modal-body {
    color: #e0e0e0;
}

html.dark-mode .close,
html.dark-mode .btn-close {
    color: #e0e0e0;
}

html.dark-mode .tooltip-inner {
    background-color: #3a3a3a;
    color: #e0e0e0;
}

html.dark-mode .popover {
    background-color: #2d2d2d;
    border-color: #444;
}

html.dark-mode .popover-header {
    background-color: #3a3a3a;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .popover-body {
    color: #e0e0e0;
}

/* Dark mode scrollbar */
html.dark-mode ::-webkit-scrollbar-track {
    background: #1a1a1a;
}

html.dark-mode ::-webkit-scrollbar-thumb {
    background: #555;
}

html.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #777;
}
