/* css/style.css */
/* Design professionnel pour système de pointage PME */

:root {
    /* Palette professionnelle pour le système de pointage */
    --primary: #1f4e79;
    --primary-600: #245d8a;
    --primary-400: #3a77a8;
    --secondary: #2f6fed;
    --success: #2f855a;
    --danger: #b42318;
    --warning: #b7791f;
    --info: #0f766e;
    --light: #ffffff;
    --bg: #f4f7fb; /* page background */
    --bg-start: #f1f3f6;
    --bg-end: #f1f3f6;
    --card-border: #eef2f6;
    --dark: #0b2540;
    --gray: #6c757d;
    --border-radius: 12px;
    --shadow: 0 8px 20px rgba(16,24,40,0.06);
    --transition: all 0.25s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Poppins', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: #1f2937;
    min-height: 100vh;
}

/* subtle layered accent for large screens */
@media (min-width: 1200px) {
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        background-image: radial-gradient(circle at 10% 10%, rgba(47,78,117,0.02) 0%, transparent 25%), radial-gradient(circle at 90% 90%, rgba(47,78,117,0.02) 0%, transparent 25%);
        z-index: 0;
    }
}

/* Respect user's OS theme */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-start: #0b1220;
        --bg-end: #0f1724;
        --bg-accent: rgba(96,145,220,0.03);
    }
    body {
        background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
        color: #e6eef8;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.navbar,
.card,
.stat-card,
.pointage-card,
.form-control,
.alert,
.table thead,
table th,
table td {
    background: #ffffff;
    color: #1f2937;
    border-color: #e2e8f0;
}

.navbar,
.card,
.stat-card,
.pointage-card {
    box-shadow: var(--shadow);
}

.navbar-menu a,
.navbar-brand,
.user-name,
.form-group label,
.card-header h2,
.stat-card .stat-label,
table th,
table td,
.alert,
h1 {
    color: #1f2937;
}

.form-control {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #cbd5e1;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31,78,121,0.12);
}

.table thead {
    background: #f8fafc;
}

table tbody tr:hover {
    background: #f8fafc;
}

.alert-success {
    background: #e8f5e9;
    color: #1b5e20;
    border-color: #a5d6a7;
}

.alert-danger {
    background: #ffebee;
    color: #b71c1c;
    border-color: #ef9a9a;
}

.alert-warning {
    background: #fff3e0;
    color: #e65100;
    border-color: #ffcc80;
}

.alert-info {
    background: #e0f2f1;
    color: #004d40;
    border-color: #80cbc4;
}

/* ===== NAVBAR ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100vh;
    background: var(--primary);
    color: var(--light);
    border-right: 1px solid rgba(255,255,255,0.04);
    padding: 28px 18px;
    box-shadow: 0 6px 20px rgba(2,6,23,0.12);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 40;
}
.navbar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--light);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-brand i {
    font-size: 1.6rem;
    background: rgba(255,255,255,0.08);
    padding: 8px;
    border-radius: 8px;
    color: var(--light);
}

.navbar-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    list-style: none;
    width: 100%;
}

.navbar-menu a {
    text-decoration: none;
    color: var(--light);
    padding: 10px 12px;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    background: transparent;
}

.navbar-menu a:hover,
.navbar-menu a.active {
    background: rgba(255,255,255,0.06);
    color: #ffffff;
}

/* icon circle */
.navbar-menu a i {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    color: var(--light);
    font-size: 1rem;
}

/* pill label look */
.navbar-menu a span.label {
    display: inline-block;
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--light);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
}

.user-name {
    font-weight: 500;
    color: var(--primary);
}

.btn-logout {
    background: var(--danger);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-logout:hover {
    background: #b71c1c;
    transform: translateY(-2px);
}

/* ===== CARTES ===== */
.card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 25px;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.card-header {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.card-header h2 {
    color: var(--primary);
    font-size: 1.3rem;
}

.card-header h2 i {
    margin-right: 10px;
}

/* ===== STATS DASHBOARD ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 25px 20px;
    text-align: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.info::before { background: var(--info); }

.stat-card i {
    font-size: 2.2rem;
    margin-bottom: 15px;
    color: var(--primary);
}

.stat-card.success i { color: var(--success); }
.stat-card.warning i { color: var(--warning); }
.stat-card.danger i { color: var(--danger); }
.stat-card.info i { color: var(--info); }

.stat-card .stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 10px 0;
    color: var(--dark);
}

.stat-card .stat-label {
    color: #64748b;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

/* ===== TABLEAUX ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: var(--light);
}

table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    border-bottom: 2px solid #dee2e6;
}

table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
}

table tbody tr:hover {
    background: var(--light);
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ===== FORMULAIRES ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,60,114,0.1);
}

select.form-control {
    cursor: pointer;
}

/* ===== BOUTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.search-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.search-form .form-control {
    flex: 1;
    min-width: 220px;
}

.search-results {
    margin-top: 20px;
}

.empty-state {
    margin: 20px 0;
    padding: 18px;
    background: rgba(30, 60, 114, 0.08);
    border-left: 4px solid var(--primary);
    color: var(--dark);
    border-radius: 12px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--secondary);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

/* ===== PAGE POINTAGE ===== */
body.page-pointage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}

body.page-pointage .container {
    width: 100%;
    max-width: 380px;
    padding: 0;
    margin: 0 auto;
}

.pointage-card {
    background: #ffffff;
    border: 1px solid #cacbce;
    border-radius: var(--border-radius);
    padding: 46px 28px;
    min-height: 540px;
    width: 100%;
    box-shadow: var(--shadow);
    text-align: center;
}

.clock {
    font-size: 3.5rem;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    margin: 20px 0;
    color: var(--primary);
}

.date {
    font-size: 1.2rem;
    color: var(--gray);
    margin-bottom: 30px;
}

.pin-input {
    width: 250px;
    text-align: center;
    font-size: 1.8rem;
    letter-spacing: 8px;
    margin: 20px auto;
    font-family: monospace;
}

.pointage-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn-pointage {
    padding: 15px 35px;
    font-size: 1.1rem;
}

/* ===== ALERTES ===== */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.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) {
    .container {
        padding: 10px;
    }
    
    .navbar {
        flex-direction: column;
        gap: 15px;
    }
    
    .navbar-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .pointage-buttons {
        flex-direction: column;
    }
    
    .btn-pointage {
        width: 100%;
    }
    
    .card-header {
        flex-direction: column;
        gap: 10px;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* ===== LOADER ===== */
.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* CORRECTION TABLEAU PLEINE LARGEUR */
.table-container {
    width: 100% !important;
    overflow-x: auto;
}

/* Detect pages that use inline body styles (login) and force centering
   This overrides the inline styles on pages like connexion.php without editing PHP */
body[style] {
    /* match global app background for login pages */
    background: var(--bg) !important;
    background-attachment: fixed !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    min-height: 100vh !important;
    padding: 0 !important;
}

body[style] .container {
    margin-left: 0 !important;
    margin: 0 auto !important;
    max-width: 400px !important;
    min-height: 620px !important;
    padding: 0 20px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

body[style] .card {
    box-shadow: 0 12px 30px rgba(31,52,86,0.14);
    width: 100% !important;
    max-width: 380px !important;
    min-height: 520px !important;
    margin: 0 auto !important;
    border-radius: 18px !important;
    padding: 36px 28px !important;
}

/* Hide the fixed sidebar when on pages that set inline body styles (login) */
body[style] .navbar {
    display: none !important;
}

/* Sidebar layout: push main content on wide screens */
@media (min-width: 900px) {
    .container {
        margin-left: 260px;
        max-width: calc(100% - 280px);
        padding-top: 20px;
    }
}

/* Revert sidebar to top nav on small screens */
@media (max-width: 899px) {
    .navbar {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        height: auto;
        padding: 12px 16px;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow);
    }
    .container {
        margin-left: 0;
        max-width: 100%;
    }
    .navbar-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    .navbar-menu a i {
        width: auto;
        height: auto;
        background: transparent;
        color: var(--primary);
        font-size: 1rem;
        padding: 0;
    }
}