/* =============================================
   GPEC Standalone — Style Sheet
   Fusion de style.css Qual'Ino + formation.css + layout standalone
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --secondary: #6B7280;
    --bg-main: #F9FAFB;
    --bg-surface: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --font-family: 'Inter', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-md: 8px;
    --radius-lg: 12px;
    --header-height: 68px;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

/* =============================================
   HEADER APPLICATION
   ============================================= */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #1E1B4B;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.app-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-icon-gpec {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: white;
    display: block;
    line-height: 1.1;
}

.brand-sub {
    font-size: 0.72rem;
    color: #A5B4FC;
    display: block;
}

.header-search {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    padding: 7px 12px;
    border-radius: 20px;
    width: 220px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.15);
    color: #D1D5DB;
    transition: all 0.2s;
}
.header-search:focus-within {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.35);
}
.header-search input {
    border: none;
    background: transparent;
    outline: none;
    margin-left: 8px;
    width: 100%;
    font-family: inherit;
    font-size: 0.9rem;
    color: white;
}
.header-search input::placeholder { color: #9CA3AF; }

.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.header-nav::-webkit-scrollbar { display: none; }

.header-tab {
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #A5B4FC;
    white-space: nowrap;
    transition: all 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
    background: none;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
}
.header-tab:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}
.header-tab.active {
    background: rgba(79, 70, 229, 0.4);
    color: white;
    border-color: rgba(165, 180, 252, 0.35);
}

/* =============================================
   CONTENT AREA
   ============================================= */

.content-area {
    margin-top: var(--header-height);
    padding: 28px 32px;
    min-height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.view-section { display: none; animation: fadeIn 0.25s ease; }
.active-view { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.view-header h1 { font-size: 1.7rem; font-weight: 700; color: #111827; }
.view-header p { color: var(--text-muted); margin-top: 4px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-4 { margin-top: 1.5rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.w-100 { width: 100% !important; }

/* =============================================
   KPI GRID
   ============================================= */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.kpi-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
    border: 1px solid var(--border);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0;
}
.card-blue .kpi-icon { background: #E0E7FF; color: #4338CA; }
.card-orange .kpi-icon { background: #FEF3C7; color: #D97706; }
.card-green .kpi-icon { background: #D1FAE5; color: #059669; }
.card-yellow .kpi-icon { background: #FDE68A; color: #B45309; }
.card-red .kpi-icon { background: #FEE2E2; color: #DC2626; }
.card-dark .kpi-icon { background: #F3F4F6; color: #374151; }
.kpi-info .kpi-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.kpi-info p { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

/* =============================================
   TABLES
   ============================================= */

.data-table-container { background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--bg-main); color: var(--text-muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; }
.data-table tbody tr:hover { background: #F8F9FF; }

/* =============================================
   MATRICE
   ============================================= */

.matrice-table th, .matrice-table td { border: 1px solid var(--border); padding: 10px; text-align: center; vertical-align: middle; }
.matrice-container { max-height: calc(100vh - 220px); overflow: auto; position: relative; }
.matrice-table thead th { position: sticky; top: 0; background: #F8FAFC; z-index: 4; }
.matrice-table th:first-child { left: 0; z-index: 5; }
.matrice-table td:first-child { position: sticky; left: 0; background: white; z-index: 2; box-shadow: 2px 0 5px rgba(0,0,0,0.05); }
.matrice-table th { background: #F8FAFC; font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; }

.status-cell { border-radius: 4px; font-weight: 600; font-size: 0.82rem; padding: 5px 8px; display: inline-block; min-width: 55px; }
.status-valide { background: #D1FAE5; color: #065F46; }
.status-renouveler_6m, .status-a_recycler { background: #FEF3C7; color: #92400E; }
.status-renouveler_12m { background: #FDE68A; color: #92400E; }
.status-expiree { background: #FEE2E2; color: #991B1B; }
.status-non_forme { background: #F3F4F6; color: #9CA3AF; }

/* =============================================
   DASHBOARD CHART
   ============================================= */

.dashboard-chart { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-surface); }
.dashboard-chart-header { margin-bottom: 16px; }
.dashboard-chart-header h2 { font-size: 1.1rem; font-weight: 600; }
.expiry-bar-row { display: grid; grid-template-columns: 200px 1fr auto; gap: 16px; align-items: center; margin-bottom: 14px; }
.expiry-bar-label { font-weight: 600; font-size: 0.9rem; }
.expiry-bar-wrapper { background: #E5E7EB; border-radius: 9999px; height: 12px; overflow: hidden; }
.expiry-bar-fill { height: 100%; background: linear-gradient(90deg, #F97316, #F59E0B); border-radius: 9999px; transition: width 0.8s ease; }
.expiry-bar-value { font-size: 0.95rem; font-weight: 700; }

/* =============================================
   EMPLOYEE CARDS
   ============================================= */

.employee-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.employee-card { padding: 18px; border-radius: var(--radius-lg); background: white; box-shadow: var(--shadow-sm); border: 1px solid var(--border); transition: box-shadow 0.2s; }
.employee-card:hover { box-shadow: var(--shadow-md); }
.employee-card-title { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.employee-card-meta { color: var(--text-muted); margin-bottom: 12px; font-size: 0.88rem; }
.employee-card-stats { display: flex; flex-wrap: wrap; gap: 10px; color: var(--text-main); font-weight: 600; font-size: 0.88rem; }

/* =============================================
   BUTTONS
   ============================================= */

.btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.9rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #E5E7EB; color: var(--text-main); }
.btn-secondary:hover { background: #D1D5DB; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-main); border-color: var(--secondary); }

.icon-btn { background: transparent; border: none; font-size: 1.25rem; color: var(--text-muted); cursor: pointer; transition: color 0.2s; }
.icon-btn:hover { color: var(--text-main); }
.icon-btn.text-danger { color: var(--danger); }

/* =============================================
   MODALS
   ============================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,0.7);
    backdrop-filter: blur(3px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-box {
    background: white;
    padding: 36px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4);
    position: relative;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 1.4rem;
}

/* =============================================
   FORMS
   ============================================= */

.form-grid-1 { display: flex; flex-direction: column; gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group label { display: block; font-size: 0.88rem; font-weight: 500; margin-bottom: 6px; color: var(--text-main); }
.form-input {
    width: 100%; padding: 9px 13px; border: 1px solid var(--border);
    border-radius: var(--radius-md); font-family: inherit; font-size: 0.93rem;
    transition: border-color 0.2s; background: white; color: var(--text-main);
}
.form-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(79,70,229,0.08); }
.form-actions { display: flex; gap: 10px; }

/* =============================================
   CARDS (Paramètres etc.)
   ============================================= */

.card { background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 16px 22px; border-bottom: 1px solid var(--border); background: var(--bg-main); }
.card-header h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 22px; }
.card-body p { line-height: 1.6; }

.param-info-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #EEF2FF;
    border: 1px solid #C7D2FE;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: #3730A3;
    font-size: 0.9rem;
}
.param-info-box code { word-break: break-all; font-size: 0.85rem; }

/* =============================================
   UPLOAD DROPZONE
   ============================================= */

.upload-dropzone {
    border: 2px dashed #D1D5DB;
    border-radius: 10px;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: #6B7280;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s, background 0.2s;
}
.upload-dropzone:hover { border-color: var(--primary); background: #F5F3FF; }

/* =============================================
   DASHBOARD DETAILS MODAL
   ============================================= */

.details-list { list-style: none; padding: 0; margin: 0; }
.details-list li { padding: 12px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.details-list li:last-child { border-bottom: none; }
.detail-emp-name { font-weight: 600; }
.detail-emp-days { font-size: 0.83rem; padding: 4px 8px; border-radius: 12px; }
.days-warning { background: #FEF3C7; color: #92400E; }
.days-danger { background: #FEE2E2; color: #991B1B; }

.formation-group { margin-bottom: 20px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.formation-group-header { background: #F8FAFC; padding: 12px 15px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.formation-title { font-weight: 700; color: var(--text-main); font-size: 1rem; }
.formation-cost { font-size: 0.88rem; color: var(--text-muted); background: white; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border); }
.cost-total { font-weight: 700; color: var(--primary); }
.dashboard-details-summary { margin-top: 16px; text-align: right; font-size: 1rem; padding: 12px 16px; background: var(--primary-light); border-radius: var(--radius-md); color: var(--primary); }

/* =============================================
   UTILITY
   ============================================= */

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
code { background: #F3F4F6; padding: 2px 6px; border-radius: 4px; font-size: 0.87em; }

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 900px) {
    .app-header { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
    .header-search { width: 100%; order: 3; flex: 1; }
    .header-nav { order: 4; flex: 1 1 100%; }
    .content-area { padding: 16px; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .expiry-bar-row { grid-template-columns: 140px 1fr auto; }
}

@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .modal-box { padding: 20px; }
}
