/* ========== VARIABLES ========== */
:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --accent: #e74c3c;
    --success: #27ae60;
    --warning: #f39c12;
    --bg: #f5f6fa;
    --card: #ffffff;
    --text: #2c3e50;
    --border: #dcdde1;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 260px;
    background: var(--primary);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.logo {
    padding: 25px 20px;
    font-size: 1.3rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i { font-size: 1.6rem; color: var(--secondary); }

.nav-links { list-style: none; padding: 15px 0; }

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.nav-links li a:hover,
.nav-links li a.active {
    background: rgba(255,255,255,0.08);
    color: white;
    border-left-color: var(--secondary);
}

.nav-links li a i { width: 20px; text-align: center; }

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
}

.top-bar {
    background: var(--card);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar h1 { font-size: 1.5rem; color: var(--primary); }

.container { padding: 30px; max-width: 1400px; }

/* ========== BUTTONS ========== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-primary { background: var(--secondary); color: white; }
.btn-primary:hover { background: #2980b9; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #e67e22; }

.btn-danger { background: var(--accent); color: white; }
.btn-danger:hover { background: #c0392b; }

.btn-outline {
    background: transparent;
    border: 2px solid var(--secondary);
    color: var(--secondary);
}
.btn-outline:hover { background: var(--secondary); color: white; }

/* ========== CARDS ========== */
.card {
    background: var(--card);
    border-radius: 10px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.card-title { font-size: 1.2rem; color: var(--primary); }

/* ========== GRID ========== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--card);
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
}

.stat-icon.blue { background: var(--secondary); }
.stat-icon.green { background: var(--success); }
.stat-icon.orange { background: var(--warning); }
.stat-icon.red { background: var(--accent); }

.stat-info h3 { font-size: 1.8rem; margin-bottom: 4px; }
.stat-info p { color: #7f8c8d; font-size: 0.9rem; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--primary);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

select.form-control { cursor: pointer; }

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

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

/* ========== TABLES ========== */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 8px;
    overflow: hidden;
}

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

th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

tr:hover { background: rgba(52, 152, 219, 0.03); }

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: #7f8c8d;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}

.tab-btn.active {
    color: var(--secondary);
    border-bottom-color: var(--secondary);
    font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== SIGNATURE CANVAS ========== */
.signature-pad {
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: #fafafa;
    cursor: crosshair;
    display: block;
    margin-bottom: 10px;
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal {
    background: var(--card);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: modalSlide 0.3s ease;
}

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

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

.modal-body { padding: 25px; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    transform: translateX(150%);
    transition: transform 0.4s ease;
    z-index: 2000;
}

.toast.show { transform: translateX(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--accent); }
.toast.warning { background: var(--warning); }

/* ========== PDF PREVIEW ========== */
.pdf-preview {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 40px;
    min-height: 600px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    font-family: 'Times New Roman', serif;
    line-height: 1.6;
}

.pdf-header {
    text-align: center;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.pdf-section { margin-bottom: 25px; }
.pdf-section h3 {
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.pdf-field {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    min-height: 36px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar { width: 70px; }
    .sidebar .logo span,
    .nav-links li a span { display: none; }
    .main-content { margin-left: 70px; }
    .grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

/* ========== UTILITIES ========== */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.gap-10 { gap: 10px; }

/* ========== STATISTIQUES (page d'accueil) ========== */
.stats-title { font-size: 1.05rem; color: var(--primary); margin: 10px 0 15px; }
.stats-title i { color: var(--secondary); margin-right: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; margin-bottom: 25px; }
.stat-icon.purple { background: #8e44ad; }
.stat-icon.teal { background: #16a085; }
.stat-icon.grey { background: #7f8c8d; }

.bar-row { display: grid; grid-template-columns: 140px 1fr auto; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 0.9rem; }
.bar-track { background: #ecf0f1; border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--secondary); border-radius: 6px; }
.bar-fill.green { background: var(--success); }
.bar-fill.orange { background: var(--warning); }
.bar-fill.red { background: var(--accent); }

.col-chart { display: flex; align-items: stretch; gap: 6px; height: 190px; }
.col-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.col-chart .col-plot { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.col-chart .col-bar { width: 100%; background: var(--secondary); border-radius: 4px 4px 0 0; min-height: 2px; }
.col-chart .col-val { font-size: 0.7rem; font-weight: bold; margin-top: 5px; white-space: nowrap; }
.col-chart .col-label { font-size: 0.7rem; color: #7f8c8d; }

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .bar-row { grid-template-columns: 90px 1fr auto; }
}

/* ========== FILTRES DE TABLEAUX ========== */
.table-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 15px; padding: 12px; background: #f8f9fa; border: 1px solid var(--border); border-radius: 8px; }
.table-filter .tf-search { position: relative; flex: 1 1 220px; min-width: 180px; }
.table-filter .tf-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #95a5a6; pointer-events: none; }
.table-filter .tf-search input { padding-left: 36px; }
.table-filter select.form-control { width: auto; min-width: 150px; flex: 0 1 auto; }
.table-filter .form-control { margin: 0; padding-top: 10px; padding-bottom: 10px; }
.table-filter .tf-reset { white-space: nowrap; }
.table-filter .tf-count { margin-left: auto; font-size: 0.85rem; color: #7f8c8d; white-space: nowrap; }
.tf-empty { display: none; text-align: center; color: #7f8c8d; padding: 15px; }
@media (max-width: 768px) {
    .table-filter select.form-control { flex: 1 1 140px; }
    .table-filter .tf-count { margin-left: 0; width: 100%; }
}
