:root {
    --primary: #0d6efd;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --dark: #343a40;
    --light: #f8f9fa;
    --gray: #6c757d;
    --border: #dee2e6;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
    color: var(--dark);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #555;
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #f8f9ff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: #333; }
.btn-secondary { background: var(--gray); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-block { display: block; width: 100%; }

/* Navbar */
.navbar {
    background: white;
    padding: 12px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--dark);
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    list-style: none;
}

.navbar-nav a {
    color: var(--gray);
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.navbar-nav a:hover, .navbar-nav a.active {
    color: var(--primary);
    background: #e8f0fe;
    text-decoration: none;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--gray);
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: white;
}

.badge-admin { background: var(--danger); }
.badge-agent { background: var(--info); }

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
    background: var(--light);
}

.card-body {
    padding: 20px;
}

/* Filters */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
}

.filters-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}

.info-text {
    color: var(--warning);
    font-size: 13px;
    margin-left: 12px;
}

/* Events list */
.event-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
    background: white;
    transition: box-shadow 0.2s;
}

.event-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.event-header {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
    gap: 8px;
}

.event-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.event-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--gray);
}

.event-agent {
    font-weight: 700;
}

.event-type {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.event-plaque {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    background: var(--dark);
    color: white;
}

.event-date {
    color: var(--gray);
    font-size: 13px;
}

.event-site {
    color: var(--gray);
    font-size: 13px;
}

.event-body {
    padding: 16px 20px;
}

.event-description {
    margin-bottom: 12px;
    line-height: 1.6;
}

.event-description img {
    max-width: 100%;
    height: auto;
}

.event-files {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.event-file-thumb {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}

.event-file-thumb:hover {
    transform: scale(1.05);
}

.event-pdf-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fef3f3;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    color: var(--danger);
    font-size: 13px;
}

.event-gps-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #e8f5e9;
    border-radius: 6px;
    color: var(--success);
    font-size: 12px;
}

.event-horodatage {
    font-size: 12px;
    color: var(--gray);
    font-style: italic;
}

.event-actions .btn {
    padding: 6px 10px;
    font-size: 18px;
    background: none;
    border: none;
}

.event-actions .btn-edit { color: var(--success); }
.event-actions .btn-delete { color: var(--danger); }

/* Connected users */
.connected-users {
    background: white;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.connected-users h3 {
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 12px;
}

.connected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.connected-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #e8f5e9;
    border-radius: 20px;
    font-size: 13px;
}

.connected-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
    padding: 4px 8px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Admin page */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--light);
    font-weight: 600;
    font-size: 13px;
    color: var(--gray);
}

.table tr:hover td {
    background: #f8f9ff;
}

/* Header with count */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 24px;
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--gray);
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.lightbox.active { display: flex; }

.lightbox img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
}

/* QR Scanner */
#qr-reader {
    width: 100%;
    max-width: 400px;
    margin: 10px auto;
}

/* Alert */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 10px;
    }
    .navbar-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }
    .event-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .admin-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Display count selector */
.display-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--gray);
}

.display-controls select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
}
