/**
 * Thème unifié (pages type Résultat / Clients) — NRV Facturation
 */
:root {
    --nrv-primary: #007bff;
    --nrv-dark: #2c3e50;
    --nrv-muted: #6c757d;
}

body.nrv-app-body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.nrv-brand {
    color: var(--nrv-dark);
    font-weight: 700;
    font-size: 1.35rem;
}
.nrv-brand:hover {
    color: var(--nrv-primary);
    text-decoration: none;
}
.nrv-nav-links .btn {
    border-radius: 8px;
    font-weight: 600;
}

/* --- En-têtes de page --- */
.page-header {
    background: #fff;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-title {
    color: var(--nrv-dark);
    font-weight: 700;
    font-size: 1.75rem;
    margin: 0;
}
.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.year-selector {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    color: var(--nrv-dark);
}

/* Dashboard */
.dashboard-header {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
}
.dashboard-title {
    color: var(--nrv-dark);
    font-weight: 700;
    font-size: 2rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.dashboard-subtitle {
    color: #7f8c8d;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}
.section-title {
    color: var(--nrv-dark);
    font-weight: 700;
    font-size: 1.3rem;
    margin: 2rem 0 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

/* Grilles KPI / stats */
.kpi-grid,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.kpi-card,
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border-left: 5px solid var(--nrv-primary);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}
.stat-card {
    border-left-width: 4px;
    padding: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
}
.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(0, 123, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}
.kpi-label,
.stat-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}
.kpi-value,
.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--nrv-dark);
    margin-bottom: 0.3rem;
    position: relative;
    z-index: 1;
}
.stat-number {
    margin: 0.5rem 0;
}
.kpi-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2.5rem;
    opacity: 0.1;
    z-index: 0;
}
.kpi-subtext,
.kpi-detail {
    font-size: 0.85rem;
    color: #7f8c8d;
    position: relative;
    z-index: 1;
}

/* Variantes bordures KPI */
.kpi-card.ca,
.stat-card { border-left-color: #007bff; }
.kpi-card.ursaf { border-left-color: #ff9800; }
.kpi-card.achats { border-left-color: #dc3545; }
.kpi-card.benefice { border-left-color: #28a745; }
.kpi-card.unpaid { border-left-color: #e74c3c; }
.kpi-card.month { border-left-color: #27ae60; }
.kpi-card.year { border-left-color: #3498db; }
.kpi-card.delay { border-left-color: #f39c12; }
.kpi-card.suivi-1 { border-left-color: #dc3545; }
.kpi-card.suivi-2 { border-left-color: #28a745; }
.kpi-card.suivi-3 { border-left-color: #007bff; }
.kpi-card.suivi-4 { border-left-color: #ffc107; }
.kpi-card.resultat-1 { border-left-color: #007bff; }
.kpi-card.resultat-2 { border-left-color: #ffc107; }
.kpi-card.resultat-3 { border-left-color: #dc3545; }
.kpi-card.resultat-4 { border-left-color: #28a745; }
.kpi-card.clients-1 { border-left-color: #007bff; }
.kpi-card.clients-2 { border-left-color: #28a745; }
.kpi-card.clients-3 { border-left-color: #dc3545; }
.kpi-card.clients-4 { border-left-color: #17a2b8; }
.kpi-card.clients-5 { border-left-color: #6f42c1; }
.stat-card.actifs { border-left-color: #28a745; }
.stat-card.inactifs { border-left-color: #dc3545; }
.stat-card.societes { border-left-color: #17a2b8; }
.stat-card.particuliers { border-left-color: #6f42c1; }
.stat-card.suspendus { border-left-color: #dc3545; }
.stat-card.dues { border-left-color: #ffc107; }
.stat-card.montant { border-left-color: #17a2b8; }

.text-positive { color: #28a745 !important; }
.text-negative { color: #dc3545 !important; }
.text-neutral { color: #007bff !important; }

/* Liens rapides dashboard */
.quick-links-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}
.quick-link {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    text-decoration: none;
    color: var(--nrv-dark);
    transition: all 0.3s ease;
    border-top: 4px solid #007bff;
    position: relative;
    overflow: hidden;
}
.quick-link:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    color: var(--nrv-dark);
}
.quick-link-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--link-color, #007bff);
}
.quick-link-title {
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}
.quick-link-desc {
    font-size: 0.9rem;
    color: #95a5a6;
}
.stats-summary {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #e9ecef;
}
.stat-row:last-child { border-bottom: none; }
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #007bff;
}

/* Suivi devis — onglets : forcer l’affichage du panneau actif (sans dépendre du JS Bootstrap) */
.nrv-devis-tabs .tab-content > .tab-pane {
    display: none;
}
.nrv-devis-tabs .tab-content > .tab-pane.active {
    display: block !important;
    opacity: 1 !important;
}

/* Suivi devis : conteneur tableau (pas .table-card animé) */
.nrv-devis-table-wrap {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    overflow-x: auto;
    overflow-y: visible;
}

/* Cartes tableau (pas d’animation opacity : masquait les tableaux liste factures / devis) */
.table-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    overflow-x: auto;
    overflow-y: visible;
    opacity: 1;
}
.table-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--nrv-dark);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.table-title i {
    color: var(--nrv-primary);
    font-size: 1.2rem;
}
.custom-table {
    margin: 0;
    border: none;
}
.custom-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}
.custom-table thead th {
    border: none;
    color: var(--nrv-dark);
    font-weight: 700;
    padding: 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.custom-table tbody td {
    border: none;
    padding: 0.75rem 1rem;
    vertical-align: middle;
    color: #495057;
}
.custom-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}
.custom-table tbody tr:hover {
    background-color: #f8f9fa;
}
.custom-table tbody tr.family-row {
    background-color: #f0f4ff;
    font-weight: 600;
}
.custom-table tbody tr.presta-row {
    font-size: 0.9rem;
    color: #6c757d;
}
.custom-table tbody tr.presta-row td:first-child {
    padding-left: 2.5rem;
}
.total-row {
    background: #f8f9fa;
    font-weight: 700;
    border-top: 2px solid #dee2e6;
    border-bottom: 2px solid #dee2e6;
}

.currency { font-weight: 600; color: var(--nrv-dark); }
.currency.positive { color: #28a745; }
.currency.negative { color: #dc3545; }
.percentage-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #e7f3ff;
    color: #007bff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}
.percentage-badge.positive {
    background: #d4edda;
    color: #155724;
}
.percentage-badge.negative {
    background: #f8d7da;
    color: #721c24;
}

/* Résultat — URSAF & graphique */
.ursaf-cell { font-size: 0.9rem; }
.ursaf-amount { font-weight: 700; color: #ff9800; }
.ursaf-detail { font-size: 0.75rem; color: #6c757d; margin-top: 0.25rem; }
.chart-container { position: relative; height: 300px; margin-bottom: 2rem; }
.chart-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--nrv-dark);
    margin-bottom: 1rem;
}
.info-box {
    background: #e7f3ff;
    border-left: 4px solid #007bff;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

/* Clients — recherche & filtres */
.search-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.search-input { flex: 1; min-width: 250px; }
.search-input input {
    border-radius: 8px;
    border: 1px solid #e9ecef;
    padding: 0.6rem 1rem;
    width: 100%;
}
.filter-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-btn {
    padding: 0.6rem 1rem;
    border: 1px solid #e9ecef;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.3s ease;
    white-space: nowrap;
}
.filter-btn:hover {
    border-color: #007bff;
    color: #007bff;
}
.filter-btn.active {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}
.client-name { font-weight: 700; color: var(--nrv-dark); font-size: 1rem; }
.client-contact { font-weight: 600; color: #7f8c8d; }
.client-sub { font-size: 0.85rem; color: #95a5a6; margin-top: 0.25rem; }
.badge-type {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: #e9ecef;
    color: #495057;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-status {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}
.badge-status.actif { background: #d4edda; color: #155724; }
.badge-status.inactif { background: #f8d7da; color: #721c24; }
.badge-status.suspendu { background: #f8d7da; color: #721c24; }
.actions-cell { display: flex; gap: 0.5rem; justify-content: flex-end; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}
.btn-icon.edit { color: #007bff; }
.btn-icon.edit:hover { background: #e7f3ff; color: #0056b3; }
.btn-icon.toggle { color: #ffc107; }
.btn-icon.toggle:hover { background: #fff9e6; }
.btn-icon.delete { color: #dc3545; }
.btn-icon.delete:hover { background: #ffe6e6; }

/* Suivi */
.facture-row.paid { opacity: 0.75; background-color: #f8f9fa; }
.facture-row.late { background-color: #ffe6e6; font-weight: 600; }
.facture-row.warning { background-color: #fff9e6; }
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}
.status-badge.paid { background: #d4edda; color: #155724; }
.status-badge.late { background: #f8d7da; color: #721c24; }
.status-badge.warning { background: #fff3cd; color: #856404; }
.status-badge.ok { background: #d1ecf1; color: #0c5460; }
.date-input {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    max-width: 140px;
}
.btn-save {
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}
.btn-save:hover { background: #0056b3; }
.btn-save:disabled { background: #ccc; cursor: not-allowed; }
.clients-en-retard {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}
.clients-en-retard .client-item {
    padding: 1rem;
    border-left: 4px solid #e74c3c;
    background: #fff5f5;
    margin-bottom: 1rem;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.clients-en-retard .client-name { font-weight: 600; }
.client-details { font-size: 0.85rem; color: #7f8c8d; margin-top: 0.25rem; }
.client-montant { font-size: 1.3rem; font-weight: 700; color: #e74c3c; }

/* Abonnements */
.abo-name { font-weight: 700; color: var(--nrv-dark); font-size: 1rem; }
.badge-due {
    background: #fff3cd;
    color: #856404;
    animation: nrv-blink 1.5s infinite;
}
@keyframes nrv-blink {
    50% { opacity: 0.5; }
}
.montant-ht { font-weight: 700; color: #007bff; }

/* Prestations */
.presta-table-card {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
}
.presta-ref { font-weight: 700; color: var(--nrv-dark); }

/* Facturation (fragments) */
.nrv-page-intro .lead { color: #7f8c8d; font-size: 0.95rem; }
.nrv-stat-mini {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 4px solid #007bff;
}
.nrv-stat-mini .label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.nrv-stat-mini.highlight { border-left-color: #17a2b8; }

.no-data {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}
.no-data i { font-size: 3rem; opacity: 0.3; margin-bottom: 1rem; }

/* Modales */
.modal-content {
    border: none;
    border-radius: 12px;
}
.modal-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #fff;
    border: none;
    border-radius: 12px 12px 0 0;
}
.modal-header .close { color: #fff; opacity: 0.9; text-shadow: none; }

/* Animations */
@keyframes nrv-slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.kpi-card,
.stat-card,
.quick-link,
.stats-summary,
.clients-en-retard,
.presta-table-card {
    animation: nrv-slideIn 0.45s ease-out;
}

.spinner {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}
.spinner.show { display: block; }

/* Bootstrap 5 « gap » pour flex (BS4 ne l’a pas) */
.d-flex.gap-2 { gap: 0.5rem; }

@media (max-width: 768px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .kpi-grid,
    .stats-grid { grid-template-columns: 1fr; }
    .search-bar { flex-direction: column; }
    .search-input { width: 100%; min-width: 0; }
    .actions-cell { flex-direction: column; }
}
