/*
 * Charte Graphique — NufiPay
 * Design : Light, sobre, Teal primary, police Urbanist
 */

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

/* ─── VARIABLES ─────────────────────────────────────────────────────────── */
:root {
    /* Couleur primaire Teal */
    --primary:          #0d9488;
    --primary-dark:     #0f766e;
    --primary-light:    #ccfbf1;
    --primary-subtle:   #f0fdfa;

    /* Surfaces */
    --bg:               #f8fafc;
    --surface:          #ffffff;
    --surface-alt:      #f1f5f9;
    --border:           #e2e8f0;
    --border-strong:    #cbd5e1;

    /* Texte */
    --text-primary:     #0f172a;
    --text-secondary:   #64748b;
    --text-muted:       #94a3b8;

    /* États */
    --success:          #16a34a;
    --success-bg:       #f0fdf4;
    --warning:          #d97706;
    --warning-bg:       #fffbeb;
    --danger:           #dc2626;
    --danger-bg:        #fef2f2;
    --danger-light:     #fee2e2;
    --info:             #0369a1;
    --info-bg:          #eff6ff;

    /* Typographie */
    --font:             'Urbanist', system-ui, sans-serif;

    /* Rayons */
    --radius-sm:        6px;
    --radius:           10px;
    --radius-lg:        14px;
    --radius-xl:        20px;

    /* Ombres */
    --shadow-sm:        0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:           0 4px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);
    --shadow-lg:        0 10px 28px rgba(0,0,0,0.09), 0 4px 10px rgba(0,0,0,0.05);

    /* Transitions */
    --transition:       all 0.18s ease;
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-top {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.brand-name { color: var(--text-primary); }
.brand-name span { color: var(--primary); }

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.75rem 0.5rem 0.4rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    text-decoration: none;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-link:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary-subtle);
    color: var(--primary-dark);
    font-weight: 600;
}

.nav-link.active svg { color: var(--primary); }

.nav-link.danger { color: var(--danger); }
.nav-link.danger:hover { background: var(--danger-bg); }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.user-info { overflow: hidden; }

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

/* ─── MAIN CONTENT ───────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 2.5rem;
    max-width: 1300px;
}

/* ─── FLASH MESSAGES ─────────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #bbf7d0;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-light);
}

.alert-inner { display: flex; align-items: center; gap: 0.5rem; }
.alert-inner svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-close { background: none; border: none; color: inherit; cursor: pointer; opacity: 0.6; padding: 2px; }
.alert-close:hover { opacity: 1; }

/* ─── PAGE HEADER ────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-header-title h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
}

.page-header-title p {
    color: var(--text-secondary);
    margin-top: 0.2rem;
    font-size: 0.9375rem;
}

/* ─── CARDS & PANELS ─────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-body { padding: 1.5rem; }
.card-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title svg { width: 18px; height: 18px; color: var(--primary); }

/* ─── STATS GRID ─────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.35rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 46px;
    height: 46px;
    background: var(--primary-subtle);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}

.stat-icon svg { width: 22px; height: 22px; }

.stat-body {}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-value.primary { color: var(--primary-dark); }

/* ─── TABLE ──────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

thead th {
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--primary-subtle); }

tbody td {
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    vertical-align: middle;
}

/* ─── EMPLOYEE AVATAR ────────────────────────────────────────────────────── */
.emp-row { display: flex; align-items: center; gap: 0.65rem; }

.emp-avatar {
    width: 34px;
    height: 34px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.emp-name { font-weight: 600; font-size: 0.9375rem; color: var(--text-primary); }
.emp-meta { font-size: 0.8125rem; color: var(--text-muted); }

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-teal    { background: var(--primary-light); color: var(--primary-dark); }
.badge-slate   { background: var(--surface-alt); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.15rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--danger-light);
}

.btn-danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-sm svg { width: 14px; height: 14px; }

.btn-icon {
    padding: 0.45rem;
    border-radius: var(--radius);
}

.btn-icon svg { width: 16px; height: 16px; }

/* ─── FORMS ──────────────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--surface);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.form-control:disabled,
.form-control[readonly] {
    background: var(--surface-alt);
    color: var(--text-muted);
    cursor: default;
}

select.form-control { cursor: pointer; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ─── DIALOG / MODAL ─────────────────────────────────────────────────────── */
dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    background: var(--surface);
    padding: 0;
    width: min(640px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
}

dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.dialog-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dialog-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.dialog-close:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
}

.dialog-close svg { width: 18px; height: 18px; }

.dialog-body { padding: 1.5rem; }

/* ─── SECTION HEADERS ────────────────────────────────────────────────────── */
.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ─── TABS ───────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.65rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
}

.tab svg { width: 16px; height: 16px; }

.tab:hover { color: var(--text-primary); }

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ─── EMPLOYEE DETAIL ────────────────────────────────────────────────────── */
.profile-hero {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.profile-avatar {
    width: 68px;
    height: 68px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.profile-info { flex: 1; }

.profile-name {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    align-items: center;
}

.profile-meta-item { display: flex; align-items: center; gap: 0.3rem; }
.profile-meta-item svg { width: 14px; height: 14px; color: var(--text-muted); }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.detail-item { display: flex; flex-direction: column; gap: 0.2rem; }

.detail-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ─── BULLETIN (IMPRESSION) ──────────────────────────────────────────────── */
.payslip-wrapper {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 2rem;
    max-width: 820px;
    margin: 0 auto;
    font-family: 'Urbanist', Arial, sans-serif;
    font-size: 9pt;
    color: #111827;
}

.payslip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1rem;
    border-bottom: 2px solid #0d9488;
    margin-bottom: 1rem;
}

.payslip-header h1 {
    font-size: 13pt;
    font-weight: 800;
    color: #0d9488;
    letter-spacing: -0.01em;
}

.payslip-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.payslip-employer,
.payslip-employee {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.75rem;
}

.payslip-block-label {
    font-size: 7pt;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #0d9488;
    margin-bottom: 0.4rem;
}

.payslip-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8.5pt;
    margin-bottom: 1rem;
}

.payslip-table thead th {
    background: #0d9488;
    color: #fff;
    padding: 0.4rem 0.5rem;
    text-align: right;
    font-size: 7.5pt;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.payslip-table thead th:first-child { text-align: left; }

.payslip-table tbody tr { border-bottom: 1px solid #f0f0f0; }
.payslip-table tbody tr:nth-child(even) { background: #fafafa; }
.payslip-table tbody td { padding: 0.35rem 0.5rem; }
.payslip-table tbody td:not(:first-child) { text-align: right; }

.payslip-table .row-subtotal td {
    background: #f0fdfa;
    font-weight: 700;
    color: #0f766e;
    border-top: 1px solid #99f6e4;
    border-bottom: 1px solid #99f6e4;
}

.payslip-table .row-total td {
    background: #0d9488;
    color: #fff;
    font-weight: 800;
    padding: 0.45rem 0.5rem;
}

.payslip-net-box {
    background: #f0fdfa;
    border: 1.5px solid #0d9488;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.net-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
    font-size: 9pt;
    color: #374151;
    border-bottom: 1px dashed #ccfbf1;
}

.net-row:last-child { border-bottom: none; }
.net-row.highlight { font-size: 11pt; font-weight: 800; color: #0f766e; padding-top: 0.6rem; }
.net-row.deduction { color: #dc2626; }

.payslip-footer-note {
    font-size: 7.5pt;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    text-align: center;
}

/* ─── EMPTY STATES ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 44px;
    height: 44px;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ─── MISC ───────────────────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'Courier New', monospace; font-size: 0.85em; }

/* ─── PRINT ──────────────────────────────────────────────────────────────── */
@media print {
    .sidebar, .main-content > .page-header, .print-actions { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .payslip-wrapper { border: none; box-shadow: none; padding: 0; }
    body { background: #fff; }
}

/* ─── LOGIN PAGE ─────────────────────────────────────────────────────────── */
.login-page {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-subtle) 0%, #ffffff 60%, var(--primary-subtle) 100%);
    z-index: 50;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.75rem 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 2.25rem;
}

.login-logo .brand {
    justify-content: center;
    font-size: 1.3rem;
    gap: 0.75rem;
}

.login-logo p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.6rem;
}

/* ─── INPUT AVEC ICÔNE ───────────────────────────────────────────────────── */
.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .input-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.input-icon-wrapper .input-icon svg {
    width: 17px;
    height: 17px;
}

.input-icon-wrapper .form-control {
    padding-left: 2.6rem;
}
