* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    overflow: hidden;
}

.login-header {
    background: var(--gray-50);
    padding: 30px;
    text-align: center;
    border-bottom: 1px solid var(--gray-200);
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--gray-800);
}

.login-header p {
    color: var(--gray-500);
    font-size: 14px;
}

.login-form {
    padding: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.alert {
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
}

.alert-error {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: var(--success);
    border: 1px solid #a7f3d0;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR - DESKTOP
   ============================================ */
.sidebar {
    width: 260px;
    background: var(--gray-800);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1001;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-700);
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 20px;
    color: white;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 24px;
    color: var(--gray-300);
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.4;
}

.sidebar-nav a .nav-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 16px;
    line-height: 1.4;
}

.sidebar-nav a .nav-text {
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--gray-700);
    color: white;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--gray-700);
    font-size: 14px;
    color: var(--gray-400);
    flex-shrink: 0;
}
/* ============================================
   MAIN CONTENT - DESKTOP
   ============================================ */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 20px;
    min-height: 100vh;
    width: calc(100% - 260px);
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.content-header h1 {
    font-size: 22px;
    color: var(--gray-800);
}

/* ============================================
   PULSANTE HAMBURGER - NASCOSTO SU DESKTOP
   ============================================ */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--gray-700);
    padding: 5px 10px;
    border-radius: 6px;
    transition: background 0.2s;
    line-height: 1;
}

.mobile-menu-toggle:hover {
    background: var(--gray-200);
}

/* ============================================
   OVERLAY PER CHIUDERE MENU
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.sidebar-overlay.active {
    display: block;
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }
.stat-card.info { border-left: 4px solid var(--info); }

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.stat-label {
    color: var(--gray-500);
    font-size: 14px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
}

.card-body {
    padding: 20px;
}

/* Movimenti List */
.movement-item {
    padding: 12px;
    border-bottom: 1px solid var(--gray-100);
}

.movement-item:last-child {
    border-bottom: none;
}

.movement-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.movement-details {
    font-size: 13px;
    color: var(--gray-500);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge.checkout { background: var(--warning); color: white; }
.badge.checkin { background: var(--success); color: white; }
.badge.warning { background: var(--warning); color: white; }
.badge.success { background: var(--success); color: white; }

/* QR Scanner */
.qr-scanner-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.qr-reader-wrapper {
    text-align: center;
}

#qr-video {
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
    margin: 20px 0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    background: none;
    border: none;
}

.close:hover {
    color: var(--gray-700);
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--gray-500);
}

.empty {
    text-align: center;
    padding: 20px;
    color: var(--gray-400);
    font-style: italic;
}

/* ============================================
   TABLET E MOBILE (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {
    /* Mostra il pulsante hamburger */
    .mobile-menu-toggle {
        display: block !important;
    }
    
    /* Sidebar nascosta di default */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.3);
    }
    
    /* Sidebar aperta */
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Contenuto principale a tutta larghezza */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 15px;
    }
    
    /* Overlay visibile quando menu è aperto */
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Header adattato */
    .content-header {
        flex-wrap: wrap;
        padding: 12px 15px;
    }
    
    .content-header h1 {
        font-size: 18px;
    }
    
    /* Statistiche su tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    /* Dashboard grid su tablet */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Filtri su tablet */
    .filters-bar {
        flex-wrap: wrap;
    }
    
    .filters-bar input,
    .filters-bar select {
        min-width: 150px;
        flex: 1;
    }
}

/* ============================================
   MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        width: 260px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .content-header h1 {
        font-size: 16px;
    }
    
    .content-header {
        padding: 10px;
    }
    
    .filters-bar input,
    .filters-bar select {
        min-width: 100%;
        flex: 1 1 100%;
    }
    
    .modal-content {
        padding: 20px;
        max-width: 95%;
    }
    
    .mobile-scan-btn {
        background: var(--primary);
        color: white !important;
        margin: 10px 20px;
        border-radius: 6px;
        text-align: center;
    }
}

/* ============================================
   MOBILE PICCOLO (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    .sidebar {
        width: 240px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .stat-card {
        padding: 10px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .content-header h1 {
        font-size: 14px;
    }
    
    .content-header {
        padding: 8px 10px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .btn-small {
        padding: 4px 8px;
        font-size: 11px;
    }
}
/* ============================================
   MOVIMENTI - TABELLA A LARGHEZZA PIENA
   ============================================ */

.movements-table-container {
    width: 100%;
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.movements-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    font-size: 13px;
}

.movements-table thead {
    background: #f8fafc;
}

.movements-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.movements-table td {
    padding: 10px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

/* Colonne con larghezze minime */
.movements-table th:nth-child(1),
.movements-table td:nth-child(1) { min-width: 150px; }

.movements-table th:nth-child(2),
.movements-table td:nth-child(2) { min-width: 180px; }

.movements-table th:nth-child(3),
.movements-table td:nth-child(3) { min-width: 150px; }

.movements-table th:nth-child(4),
.movements-table td:nth-child(4) { min-width: 80px; }

.movements-table th:nth-child(5),
.movements-table td:nth-child(5) { min-width: 120px; }

.movements-table th:nth-child(6),
.movements-table td:nth-child(6) { min-width: 100px; }

.movements-table th:nth-child(7),
.movements-table td:nth-child(7) { min-width: 150px; }

.movements-table th:nth-child(8),
.movements-table td:nth-child(8) { min-width: 200px; }

.movements-table th:nth-child(9),
.movements-table td:nth-child(9) { min-width: 120px; }

/* Scroll orizzontale su tablet */
@media (max-width: 1200px) {
    .movements-table-container {
        overflow-x: auto;
    }
    .movements-table {
        min-width: 1000px;
    }
}

/* Su desktop, la tabella occupa tutta la larghezza */
@media (min-width: 1201px) {
    .movements-table {
        min-width: 100%;
        width: 100%;
        table-layout: auto;
    }
}

/* Badge nella tabella */
.movements-table .badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.movements-table .badge.checkout {
    background: #f59e0b;
    color: white;
}

.movements-table .badge.checkin {
    background: #10b981;
    color: white;
}

.movements-table .badge.warning {
    background: #f59e0b;
    color: white;
}

.movements-table .badge.success {
    background: #10b981;
    color: white;
}

/* Cell azioni */
.movements-table td:last-child {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

@media (max-width: 768px) {
    .movements-table td:last-child {
        flex-direction: column;
        align-items: stretch;
    }
    .movements-table td:last-child .btn-small {
        width: 100%;
    }
}
/* ============================================
   SPINNER
   ============================================ */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Spinner per pulsanti secondari */
.btn-secondary .spinner {
    border-color: #6b7280;
    border-top-color: transparent;
}

/* Spinner per pulsanti pericolo */
.btn-danger .spinner {
    border-color: #ffffff;
    border-top-color: transparent;
}
