/* ============================================================
   VARIABLES ET STYLES DE BASE
   ============================================================ */
:root {
    /* Thème clair */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #60a5fa;
    --secondary: #7c3aed;
    --secondary-light: #a78bfa;
    --success: #10b981;
    --success-light: #34d399;
    --danger: #ef4444;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --dark: #1e293b;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --light: #f1f5f9;
    --white: #ffffff;
    --bg-gradient-start: #f0f4ff;
    --bg-gradient-end: #e8edf5;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 20px 60px rgba(0, 0, 0, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --text-color: #1e293b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
}

/* Thème sombre */
[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --primary-light: #93c5fd;
    --secondary: #a78bfa;
    --secondary-light: #c4b5fd;
    --success: #34d399;
    --success-light: #6ee7b7;
    --danger: #f87171;
    --warning: #fbbf24;
    --warning-light: #fcd34d;
    --dark: #f1f5f9;
    --gray: #94a3b8;
    --gray-light: #64748b;
    --light: #1e293b;
    --white: #0f172a;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 20px 60px rgba(0, 0, 0, 0.5);
    --text-color: #f1f5f9;
    --card-bg: #1e293b;
    --border-color: #334155;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    min-height: 100vh;
    color: var(--text-color);
    direction: ltr;
    overflow-x: hidden;
    transition: var(--transition);
}

/* ============================================================
   SCROLLBAR PERSONNALISÉE
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--light); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ============================================================
   BARRE DE NOUVELLES
   ============================================================ */
.news-bar {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    color: white;
    padding: 8px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(37, 99, 235, 0.3);
}

.news-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
}

.news-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.news-content marquee {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.news-content marquee strong {
    color: #fcd34d;
    font-weight: 700;
}

/* ============================================================
   OVERLAY DE PROTECTION
   ============================================================ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(16px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
}

.overlay.hidden { display: none; }

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal {
    background: var(--card-bg);
    padding: 48px 40px 40px;
    border-radius: var(--radius);
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.5s ease;
    border: 1px solid var(--border-color);
}

.closing-modal {
    border: 2px solid var(--danger);
}

.limit-modal {
    border: 2px solid var(--warning);
}

.lock-icon { font-size: 56px; display: block; margin-bottom: 12px; }
.modal h2 { font-size: 24px; margin-bottom: 8px; color: var(--text-color); }
.modal .subtitle { color: var(--gray); font-size: 14px; margin-bottom: 20px; }

.timer-display {
    font-size: 52px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--primary);
    margin: 16px 0;
    letter-spacing: 4px;
}

.progress-container { margin: 16px 0; }
.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--light);
    border-radius: 10px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 10px;
    transition: width 1s linear;
    width: 0%;
}
.progress-text { font-size: 12px; color: var(--gray); margin-top: 6px; display: block; }

.waiting-message { color: var(--gray); font-size: 14px; margin: 12px 0; }
.search-info {
    background: var(--light);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--gray);
}
.search-info strong { color: var(--text-color); }
.schedule-info {
    background: var(--light);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--gray);
    margin-top: 12px;
}
.schedule-info strong { color: var(--text-color); }

.limit-info {
    background: var(--light);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 16px;
}
.limit-info strong { color: var(--warning); }

/* ============================================================
   EN-TÊTE
   ============================================================ */
header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 20px 20px;
    text-align: center;
    box-shadow: 0 4px 30px rgba(37, 99, 235, 0.3);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon { font-size: 36px; }
.logo h1 { font-size: 24px; font-weight: 700; letter-spacing: 1px; }

.auto-refresh-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: #fcd34d;
    backdrop-filter: blur(4px);
}

.refresh-icon {
    font-size: 16px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.refresh-timer {
    font-weight: 700;
    font-size: 15px;
    font-family: 'Courier New', monospace;
    min-width: 45px;
}

.refresh-label {
    font-size: 11px;
    opacity: 0.8;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.datetime {
    display: flex;
    gap: 12px;
    font-size: 13px;
    background: rgba(255,255,255,0.15);
    padding: 4px 16px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.datetime span { opacity: 0.95; }

.search-counter {
    background: rgba(255,255,255,0.15);
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 13px;
    backdrop-filter: blur(4px);
}

.theme-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    padding: 4px 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(4px);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-btn:hover { background: rgba(255,255,255,0.35); transform: scale(1.05); }

.logout-btn {
    background: rgba(239, 68, 68, 0.3);
    border: none;
    color: white;
    font-size: 20px;
    padding: 4px 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(4px);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.logout-btn:hover {
    background: rgba(239, 68, 68, 0.8);
    transform: scale(1.1);
}

.header-subtitle { font-size: 13px; opacity: 0.9; }

/* ============================================================
   CONTENU PRINCIPAL
   ============================================================ */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

/* ============================================================
   SECTION DE RECHERCHE
   ============================================================ */
.search-section { display: flex; justify-content: center; margin-bottom: 40px; }

.search-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    width: 100%;
    max-width: 650px;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}
.search-card:hover { box-shadow: var(--shadow-hover); }

.search-icon { font-size: 44px; display: block; margin-bottom: 12px; }
.search-card h2 { font-size: 22px; color: var(--text-color); margin-bottom: 4px; }
.search-hint { color: var(--gray); font-size: 14px; margin-bottom: 24px; }

.search-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.search-form input {
    flex: 1;
    min-width: 200px;
    padding: 14px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: var(--transition);
    background: var(--light);
    color: var(--text-color);
}
.search-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.search-btn {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(37, 99, 235, 0.4);
}
.search-btn:active { transform: translateY(0); }
.search-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.search-status {
    margin-top: 16px;
    font-size: 13px;
    color: var(--gray);
    padding: 6px 12px;
    background: var(--light);
    border-radius: 20px;
    display: inline-block;
}

.error-message {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fef2f2;
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 14px;
    border-left: 4px solid var(--danger);
    text-align: left;
}
.error-message.hidden { display: none; }

/* ============================================================
   RÉSULTATS
   ============================================================ */
.results-section {
    animation: fadeInUp 0.6s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.results-section.hidden { display: none; }

/* --- Carte de profil --- */
.profile-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px 28px;
    box-shadow: var(--shadow);
    margin-bottom: 28px;
    border: 1px solid var(--border-color);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.profile-info { flex: 1; min-width: 150px; }
.profile-info h2 { font-size: 22px; margin-bottom: 4px; color: var(--text-color); }
.registration-number { color: var(--gray); font-size: 14px; }
.registration-number span { color: var(--text-color); font-weight: 600; }

.profile-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}
.action-btn:hover { transform: translateY(-2px); }

.excel-btn { background: #217346; color: white; }
.excel-btn:hover { background: #1a5a38; box-shadow: 0 4px 15px rgba(33, 115, 70, 0.4); }

.pdf-btn { background: #dc3545; color: white; }
.pdf-btn:hover { background: #b02a37; box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4); }

.word-btn { background: #2b5797; color: white; }
.word-btn:hover { background: #1d3f6e; box-shadow: 0 4px 15px rgba(43, 87, 151, 0.4); }

/* --- Statistiques --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

.stat-icon { font-size: 28px; flex-shrink: 0; }
.stat-content { display: flex; flex-direction: column; }
.stat-label { font-size: 12px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 22px; font-weight: 700; }

.stat-blue .stat-value { color: var(--primary); }
.stat-green .stat-value { color: var(--success); }

/* --- Graphiques --- */
.charts-section { margin-bottom: 32px; }
.section-title { font-size: 20px; margin-bottom: 18px; color: var(--text-color); }

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 24px;
}

.chart-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}
.chart-card h4 { font-size: 14px; color: var(--gray); margin-bottom: 16px; text-align: center; }
.chart-container { position: relative; height: 250px; }
.chart-full { grid-column: 1 / -1; }
.chart-full .chart-container { height: 280px; }

/* --- Tableau --- */
.table-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.table-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.table-header h3 { font-size: 18px; color: var(--text-color); }
.table-count {
    font-size: 14px;
    color: var(--gray);
    background: var(--light);
    padding: 4px 14px;
    border-radius: 20px;
}

.table-container { overflow-x: auto; padding: 0 4px 4px; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table thead { background: var(--light); }
table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--gray);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}
table tbody tr:hover { background: var(--light); }
table tbody tr:last-child td { border-bottom: none; }

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.status-completed { background: #d1fae5; color: #065f46; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

.type-badge {
    background: #dbeafe;
    color: #1d4ed8;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.role-badge {
    background: #f3e8ff;
    color: #7c3aed;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* --- Pas de résultats --- */
.no-results { animation: fadeInUp 0.5s ease; }
.no-results.hidden { display: none; }

.no-results-card {
    background: var(--card-bg);
    padding: 60px 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
    border: 1px solid var(--border-color);
}
.no-results-icon { font-size: 64px; display: block; margin-bottom: 20px; }
.no-results-card h2 { font-size: 22px; margin-bottom: 8px; color: var(--text-color); }
.no-results-card p { color: var(--gray); margin-bottom: 24px; }

.retry-btn {
    padding: 12px 32px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.retry-btn:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* ============================================================
   PIED DE PAGE
   ============================================================ */
footer {
    background: var(--dark);
    color: var(--white);
    padding: 32px 20px;
    text-align: center;
    border-top: 4px solid var(--primary);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-info p { font-size: 13px; opacity: 0.8; margin: 2px 0; }
.footer-designer { font-size: 15px; opacity: 1 !important; }
.footer-designer strong {
    color: #fcd34d;
    font-weight: 700;
    background: linear-gradient(90deg, #fcd34d, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.footer-version { font-size: 11px; opacity: 0.5; }

.footer-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin: 8px 0;
}

.footer-logo img {
    height: 45px;
    width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.8;
    transition: var(--transition);
}

.footer-logo img:hover {
    filter: brightness(0) invert(1) drop-shadow(0 0 12px rgba(255,255,255,0.3));
    opacity: 1;
    transform: scale(1.05);
}

.footer-logo span {
    font-size: 14px;
    color: #94a3b8;
    font-weight: 500;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 12px;
    opacity: 0.7;
}
.footer-links span { background: rgba(255,255,255,0.05); padding: 4px 12px; border-radius: 12px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .search-card { padding: 24px 20px; }
    .search-form { flex-direction: column; }
    .search-form input { min-width: 100%; }
    .search-btn { width: 100%; justify-content: center; }
    .profile-header { flex-direction: column; text-align: center; }
    .profile-actions { justify-content: center; width: 100%; }
    .stats-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-full { grid-column: 1; }
    .modal { padding: 32px 20px; }
    .timer-display { font-size: 36px; }
    .logo h1 { font-size: 20px; }
    .profile-card { padding: 20px; }
    table th, table td { padding: 8px 10px; font-size: 12px; }
    .header-info { flex-direction: column; gap: 8px; }
    .news-content marquee { font-size: 12px; }
    .footer-links { flex-direction: column; gap: 6px; }
    .header-left { flex-direction: column; gap: 10px; }
    .auto-refresh-indicator { font-size: 12px; }
    .footer-logo img { height: 35px; }
}

@media (max-width: 480px) {
    .timer-display { font-size: 28px; }
    .modal h2 { font-size: 20px; }
    .stat-card { padding: 14px 16px; }
    .stat-value { font-size: 18px; }
    .action-btn { font-size: 11px; padding: 6px 12px; }
    .logo h1 { font-size: 18px; }
    .logo-icon { font-size: 28px; }
}

/* ============================================================
   ANIMATIONS SUPPLÉMENTAIRES
   ============================================================ */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse { animation: pulse 2s infinite; }

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(37, 99, 235, 0.2); }
    50% { box-shadow: 0 0 40px rgba(37, 99, 235, 0.4); }
}

.glow { animation: glow 3s ease-in-out infinite; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake { animation: shake 0.5s ease; }