/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box, .register-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1, .register-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
}

.login-box h2, .register-box h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-submit:hover {
    transform: translateY(-2px);
}

.message {
    margin-top: 20px;
    padding: 10px;
    border-radius: 5px;
    display: none;
}

.message.success {
    display: block;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.login-footer a {
    color: #667eea;
    text-decoration: none;
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-wrap: wrap;
    min-height: 100vh;
}

.navbar {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    position: fixed;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    font-size: 20px;
    font-weight: bold;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-logout {
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
}

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

.sidebar {
    width: 250px;
    background: #2c3e50;
    padding-top: 80px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar ul li a {
    display: block;
    padding: 15px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: background 0.3s;
}

.sidebar ul li a:hover, .sidebar ul li a.active {
    background: #34495e;
}

.main-content {
    margin-left: 250px;
    margin-top: 70px;
    padding: 30px;
    flex: 1;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3 {
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-card p {
    font-size: 30px;
    font-weight: bold;
    color: #667eea;
}

.stats-details {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.stats-details h2 {
    margin-bottom: 20px;
    color: #333;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

/* Table */
.table {
    width: 100%;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 20px;
}

.table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.table th, .table td {
    padding: 12px 15px;
    text-align: left;
}

.table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.table tbody tr:hover {
    background: #f0f0f0;
}

/* Badges */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge.present {
    background: #d4edda;
    color: #155724;
}

.badge.absent {
    background: #f8d7da;
    color: #721c24;
}

.badge.retard {
    background: #fff3cd;
    color: #856404;
}

.badge.justifie {
    background: #d1ecf1;
    color: #0c5460;
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.controls select, .controls input {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
}

.btn-primary {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-danger {
    padding: 5px 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

/* Form container */
.form-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 20px;
}

.form-container form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-container form .form-group {
    margin-bottom: 0;
}

.form-container form button {
    grid-column: span 2;
}

/* Scan */
.scan-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.scan-header {
    text-align: center;
    padding: 20px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    margin-bottom: 20px;
}

.scan-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 768px) {
    .scan-content {
        grid-template-columns: 1fr;
    }
}

#reader {
    width: 100%;
}

.scan-form {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.scan-form h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.presence-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.stat-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
}

.stat-badge.present {
    background: #d4edda;
    color: #155724;
}

.stat-badge.absent {
    background: #f8d7da;
    color: #721c24;
}

.stat-badge.retard {
    background: #fff3cd;
    color: #856404;
}

.stat-badge.justifie {
    background: #d1ecf1;
    color: #0c5460;
}

/* Loader animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s ease;
}

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


/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* QR Grid */
.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    padding: 10px 0;
}

/* QR Card */
.qr-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    animation: fadeInUp 0.5s ease both;
}

.qr-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.qr-card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 5px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qr-card-header .class-name {
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.qr-card-header .class-id {
    color: rgba(255,255,255,0.8);
    font-size: 12px;
}

.qr-card-body {
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-image-wrapper {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    margin-bottom: 20px;
    transition: transform 0.3s;
}

.qr-image-wrapper:hover {
    transform: scale(1.05);
}

.qr-image-wrapper img {
    width: 180px;
    height: 180px;
    display: block;
    border-radius: 8px;
}

.qr-info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.qr-info-item .label {
    color: #6c757d;
}

.qr-info-item .value {
    color: #2c3e50;
    font-weight: 500;
}

.qr-code-value {
    color: #667eea;
    font-weight: 600;
    font-family: monospace;
    font-size: 12px;
}

.qr-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin-top: 5px;
}

.qr-actions button {
    padding: 10px 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.qr-actions .btn-download {
    background: #667eea;
    color: white;
}

.qr-actions .btn-download:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

.qr-actions .btn-print {
    background: #28a745;
    color: white;
}

.qr-actions .btn-print:hover {
    background: #218838;
    transform: translateY(-2px);
}

.qr-actions .btn-delete {
    background: #dc3545;
    color: white;
}

.qr-actions .btn-delete:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.05);
}

.empty-state .icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.empty-state h3 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.empty-state p {
    color: #6c757d;
    margin-bottom: 20px;
}

/* Modal */
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.qr-modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: scaleIn 0.3s ease;
    position: relative;
}

.qr-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    cursor: pointer;
    background: none;
    border: none;
    color: #6c757d;
    transition: color 0.3s;
}

.qr-modal-close:hover {
    color: #333;
}

.qr-modal-image {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    display: inline-block;
    margin-bottom: 20px;
}

.qr-modal-image img {
    width: 300px;
    height: 300px;
    display: block;
    border-radius: 10px;
}

.qr-modal-code {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.qr-modal-code .label {
    margin: 5px 0;
    color: #6c757d;
    font-size: 14px;
}

.qr-modal-code .code {
    margin: 5px 0;
    font-weight: 600;
    font-family: monospace;
    font-size: 18px;
    color: #667eea;
}

.qr-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.qr-modal-actions button {
    padding: 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s;
}

.qr-modal-actions button:hover {
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .qr-grid {
        grid-template-columns: 1fr;
    }
    
    .qr-image-wrapper img {
        width: 150px;
        height: 150px;
    }
    
    .qr-actions {
        grid-template-columns: 1fr;
    }
    
    .qr-modal-image img {
        width: 200px;
        height: 200px;
    }
    
    .qr-modal-actions {
        grid-template-columns: 1fr;
    }
}

/* Styles pour l'impression des QR codes */
@media print {
    /* Masquer les éléments inutiles */
    .no-print {
        display: none !important;
    }
    
    /* Optimiser l'impression */
    .print-container {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    .qr-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    /* Couleurs pour l'impression */
    .header {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .rules {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .sanction {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Badges de paiement */
.badge-paiement {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    white-space: nowrap;
}
.badge-paiement.paye { background: #d4edda; color: #155724; }
.badge-paiement.partiel { background: #fff3cd; color: #856404; }
.badge-paiement.impaye { background: #f8d7da; color: #721c24; }
.badge-paiement.non_defini { background: #e2e3e5; color: #383d41; }

.btn-paiement {
    padding: 5px 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 5px;
}
.btn-paiement:hover { background: #218838; }

.btn-scolarite {
    padding: 8px 18px;
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.btn-scolarite:hover { background: #138496; }


/* Badges de paiement */
.badge-paiement {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    white-space: nowrap;
}

.badge-paiement.paye {
    background: #d4edda;
    color: #155724;
}

.badge-paiement.partiel {
    background: #fff3cd;
    color: #856404;
}

.badge-paiement.impaye {
    background: #f8d7da;
    color: #721c24;
}

.badge-paiement.non_defini {
    background: #e2e3e5;
    color: #383d41;
}

.badge.entree {
    background: #d4edda;
    color: #155724;
}

.badge.sortie {
    background: #d1ecf1;
    color: #0c5460;
}