/* ==============================================
   PAIE Groupe Royal — Styles globaux
   ============================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.6;
}

/* === Header & Nav === */
header {
    background: #1a1a2e;
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

header h1 { font-size: 1.3rem; font-weight: 600; }
header h1 span { color: #7f8fa6; font-weight: 400; }

nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
nav a {
    color: #fff;
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
}
nav a:hover, nav a.active { background: rgba(255,255,255,0.15); }

main { max-width: 100%; margin: 1.5rem; padding: 0; }

h2 { font-size: 1.4rem; margin-bottom: 1rem; color: #1a1a2e; }
h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }

/* === Page toolbar (barre moderne) === */
.page-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a2e;
    color: #fff;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-bar h2 {
    color: #fff;
    margin: 0;
    font-size: 1.2rem;
}

.page-bar-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-bar select,
.page-bar input[type="text"] {
    padding: 0.4rem 0.7rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: rgba(255,255,255,0.15);
    color: #fff;
    cursor: pointer;
}

.page-bar input[type="text"]::placeholder { color: rgba(255,255,255,0.5); }
.page-bar select option { color: #1a1a2e; background: #fff; }

.page-bar .btn {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* === Cards === */
.card {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

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

.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-align: center;
}

.stat-card .number { font-size: 2rem; font-weight: 700; color: #1a1a2e; }
.stat-card .label { font-size: 0.85rem; color: #7f8fa6; margin-top: 0.25rem; }

/* === Tables === */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.75rem; border-bottom: 1px solid #e8e8e8; }
th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
tr:hover { background: #f8f9fb; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
    line-height: 1.4;
}

.btn:hover { opacity: 0.85; }
.btn-primary { background: #2d5be3; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-warning { background: #e67e22; color: #fff; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-secondary { background: #7f8fa6; color: #fff; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.9rem; }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2d5be3;
    box-shadow: 0 0 0 3px rgba(45,91,227,0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* === Flash messages === */
.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; display: none; }
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* === Badges === */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-green { background: #d4edda; color: #155724; }
.badge-red { background: #f8d7da; color: #721c24; }
.badge-blue { background: #d1ecf1; color: #0c5460; }
.badge-orange { background: #fff3cd; color: #856404; }

/* === Filter bar (legacy) === */
.filter-bar { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: end; }
.filter-bar .form-group { margin-bottom: 0; }

/* === Modal === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
}

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

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    width: 95%;
    max-width: 900px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-height: 85vh;
    overflow-y: auto;
}

.modal h3 { margin-bottom: 1rem; }

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

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

/* === Loading === */
.loading { text-align: center; padding: 2rem; color: #7f8fa6; }

/* === Responsive === */
@media (max-width: 768px) {
    header { padding: 0.75rem 1rem; }
    main { padding: 0 1rem; margin: 1rem auto; }
    .form-row { grid-template-columns: 1fr; }
    table { font-size: 0.85rem; }
    th, td { padding: 0.5rem; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .page-bar { padding: 0.6rem 1rem; }
    .page-bar-controls { width: 100%; }
}

@media (max-width: 480px) {
    nav a { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
    .stats { grid-template-columns: 1fr; }
}

/* === Print === */
@media print {
    header, nav, .btn, .filter-bar, .flash, .no-print, .page-bar { display: none !important; }
    main { max-width: 100%; margin: 0; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { background: #fff; }
    .print-header { display: block !important; }
}
