/* ============================================================
   PSLP Bertoua — Plateforme de Suivi Longitudinal du Patient
   Design v2.0 — Professionnel & Médical
   ============================================================ */

/* ── Variables ── */
:root {
    --pslp-green: #1a6b3c;
    --pslp-green-dark: #145530;
    --pslp-green-mid: #2d8a54;
    --pslp-green-light: #e8f5ee;
    --pslp-accent: #f0a500;
    --sidebar-width: 258px;
    --sidebar-bg: #0f3d24;
    --sidebar-hover: rgba(255, 255, 255, .10);
    --sidebar-active: rgba(255, 255, 255, .18);
    --topbar-height: 58px;
    --border-radius: 0.625rem;
    --shadow-card: 0 2px 14px rgba(0, 0, 0, .07);
    --shadow-card-hover: 0 6px 24px rgba(0, 0, 0, .13);
    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: #f4f6f9;
    color: #1a2332;
    font-size: 0.9rem;
    -webkit-font-smoothing: antialiased;
}

/* ── Couleur principale ── */
.bg-pslp {
    background: linear-gradient(135deg, #0f3d24 0%, var(--pslp-green) 100%) !important;
}

.btn-pslp {
    background: var(--pslp-green);
    border-color: var(--pslp-green);
    color: #fff;
}

.btn-pslp:hover {
    background: var(--pslp-green-dark);
    border-color: var(--pslp-green-dark);
    color: #fff;
}

.text-pslp {
    color: var(--pslp-green) !important;
}

.border-pslp {
    border-color: var(--pslp-green) !important;
}

/* ── Barre de navigation supérieure ── */
.navbar.bg-pslp {
    height: var(--topbar-height);
    background: linear-gradient(135deg, #0f3d24 0%, var(--pslp-green) 100%) !important;
    border-bottom: 3px solid var(--pslp-accent);
}

.navbar-brand .brand-logo {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, .15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar .btn-outline-light {
    border-color: rgba(255, 255, 255, .35);
    color: rgba(255, 255, 255, .85);
    font-size: .8rem;
    padding: .3rem .65rem;
}

.navbar .btn-outline-light:hover {
    background: rgba(255, 255, 255, .15);
    border-color: rgba(255, 255, 255, .6);
    color: #fff;
}

/* ── Indicateur hors-ligne topbar ── */
#offlineIndicator {
    font-size: .75rem;
    padding: .25rem .6rem;
    border-radius: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .7;
    }
}

/* ── Banner hors-ligne global ── */
#offline-banner {
    display: none;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    z-index: 1050;
    background: linear-gradient(135deg, #b45309, #d97706);
    color: #fff;
    text-align: center;
    padding: .6rem 1rem;
    font-size: .82rem;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .2);
}

body.offline-mode #offline-banner {
    display: block;
}

body.offline-mode #wrapper {
    margin-top: 40px;
}

/* ── Layout principal ── */
#wrapper {
    display: flex;
    min-height: calc(100vh - var(--topbar-height));
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-height: calc(100vh - var(--topbar-height));
    flex-shrink: 0;
    background: var(--sidebar-bg);
    transition: transform 0.28s cubic-bezier(.4, 0, .2, 1);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
}

/* ── Profil mini dans sidebar ── */
.sidebar-profile {
    padding: 1rem .9rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: .4rem;
}

.sidebar-profile .profile-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, .15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, .2);
}

.sidebar-profile .profile-name {
    font-size: .81rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.sidebar-profile .profile-role {
    font-size: .68rem;
    color: rgba(255, 255, 255, .55);
}

.sidebar-profile .profile-facility {
    font-size: .67rem;
    color: var(--pslp-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Navigation sidebar ── */
.nav-section-label {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .38);
    padding: .8rem 1rem .25rem;
    display: block;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, .78);
    border-radius: .45rem;
    padding: .5rem .85rem;
    margin: .05rem .45rem;
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: .845rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    text-decoration: none;
}

.sidebar .nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 1.15rem;
    text-align: center;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar .nav-link.active {
    background: var(--pslp-accent);
    color: #1a2332;
    font-weight: 700;
}

.sidebar .nav-link.active i {
    color: #1a2332;
}

/* ── Soft backgrounds ── */
.bg-success-soft {
    background-color: #d1e7dd;
}

.bg-warning-soft {
    background-color: #fff3cd;
}

.bg-danger-soft {
    background-color: #f8d7da;
}

.bg-info-soft {
    background-color: #cff4fc;
}

.bg-primary-soft {
    background-color: #cfe2ff;
}

.bg-purple-soft {
    background-color: #e9d8fd;
}

/* ── Contenu principal ── */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
}

/* ── Cards ── */
.card {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--shadow-card);
}

.card-header {
    border-bottom: 1px solid rgba(0, 0, 0, .05);
    background: #fff;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
    padding: .85rem 1.1rem;
}

/* ── Stat cards ── */
.stat-card {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--shadow-card);
    transition: transform .18s, box-shadow .18s;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card-hover);
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    flex-shrink: 0;
}

.stat-card .stat-number {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: .76rem;
    font-weight: 500;
    color: #6c757d;
    margin-top: .2rem;
}

/* ── Action cards ── */
.card-action {
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    transition: border-color .2s, box-shadow .2s, transform .2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    box-shadow: var(--shadow-card);
    background: #fff;
}

.card-action:hover {
    border-color: var(--pslp-green);
    box-shadow: 0 6px 20px rgba(26, 107, 60, .18);
    transform: translateY(-3px);
    color: var(--pslp-green);
}

/* ── Badges ── */
.badge {
    font-weight: 500;
    font-size: .72rem;
    padding: .32em .65em;
    border-radius: 6px;
}

/* ── Formulaires ── */
.form-control,
.form-select {
    border-radius: .45rem;
    border: 1.5px solid #dee2e6;
    font-size: .875rem;
    padding: .52rem .85rem;
    transition: border-color .2s, box-shadow .2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--pslp-green);
    box-shadow: 0 0 0 3px rgba(26, 107, 60, .12);
}

.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: .35rem;
}

/* ── Boutons ── */
.btn {
    border-radius: .45rem;
    font-weight: 500;
    font-size: .865rem;
    padding: .42rem .9rem;
    transition: all .18s;
}

.btn-success {
    background: var(--pslp-green);
    border-color: var(--pslp-green);
}

.btn-success:hover {
    background: var(--pslp-green-dark);
    border-color: var(--pslp-green-dark);
}

.btn-sm {
    font-size: .79rem;
    padding: .3rem .65rem;
}

.btn-lg {
    padding: .65rem 1.4rem;
    font-size: .95rem;
}

/* ── Tables ── */
.table {
    font-size: .855rem;
}

.table thead th {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6c757d;
    border-bottom: 2px solid #f0f0f0;
    background: #fafafa;
    padding: .65rem .85rem;
}

.table td {
    padding: .65rem .85rem;
    vertical-align: middle;
    border-bottom: 1px solid #f3f3f3;
}

.table-hover tbody tr:hover {
    background: #f8fffe;
}

/* ── Page headers ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-header h4 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: #1a2332;
}

/* ── Avatar ── */
.avatar-initials {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pslp-green), var(--pslp-green-mid));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .78rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(26, 107, 60, .3);
}

/* ── Tabs ── */
.nav-tabs {
    border-bottom: 2px solid #e9ecef;
}

.nav-tabs .nav-link {
    color: #6c757d;
    font-size: .855rem;
    font-weight: 500;
    border: none;
    padding: .6rem 1rem;
    border-radius: 0;
}

.nav-tabs .nav-link:hover {
    color: var(--pslp-green);
    background: none;
}

.nav-tabs .nav-link.active {
    color: var(--pslp-green);
    font-weight: 700;
    border-bottom: 3px solid var(--pslp-green);
    background: none;
}

/* ── Charts ── */
.chart-container {
    position: relative;
    height: 220px;
}

.chart-container-lg {
    position: relative;
    height: 280px;
}

/* ── Login page ── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f3d24 0%, var(--pslp-green) 55%, #2d8a54 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    max-width: 420px;
    width: 100%;
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #0f3d24, var(--pslp-green));
    padding: 2rem;
    text-align: center;
    color: #fff;
}

.login-header .login-logo {
    width: 68px;
    height: 68px;
    background: rgba(255, 255, 255, .15);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
    border: 2px solid rgba(255, 255, 255, .25);
}

.login-body {
    padding: 2rem;
}

/* ── Sidebar overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 150;
}

.sidebar-overlay.show {
    display: block;
}

/* ── Responsive sidebar ── */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        height: calc(100vh - var(--topbar-height));
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, .3);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        padding: 1rem;
    }
}

/* ── Patient header card ── */
.patient-header-card {
    background: linear-gradient(135deg, #0f3d24, var(--pslp-green));
    color: #fff;
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.patient-id-badge {
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff;
    border-radius: 6px;
    font-size: .78rem;
    padding: .25rem .6rem;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

/* ── Info rows ── */
.info-row {
    display: flex;
    gap: .5rem;
    padding: .45rem 0;
    border-bottom: 1px solid #f3f3f3;
    font-size: .855rem;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .info-label {
    min-width: 145px;
    font-weight: 600;
    color: #6c757d;
    font-size: .8rem;
    flex-shrink: 0;
}

/* ── Role badges ── */
.role-administrator {
    background: #1a2332;
    color: #fff;
}

.role-doctor {
    background: #0d6efd;
    color: #fff;
}

.role-nurse {
    background: var(--pslp-green);
    color: #fff;
}

.role-receptionist {
    background: #0dcaf0;
    color: #000;
}

.role-laboratory {
    background: #dc3545;
    color: #fff;
}

/* ── Alerts ── */
.alert {
    border: none;
    border-radius: var(--border-radius);
    font-size: .875rem;
}

.alert-success {
    background: #d1e7dd;
    color: #0a3622;
}

.alert-danger {
    background: #f8d7da;
    color: #58151c;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.empty-state i {
    font-size: 3.5rem;
    opacity: .3;
    display: block;
    margin-bottom: 1rem;
}

/* ── Pagination ── */
.pagination .page-link {
    border-radius: .4rem;
    margin: 0 .1rem;
    font-size: .8rem;
    color: var(--pslp-green);
    border-color: #e0e0e0;
}

.pagination .page-item.active .page-link {
    background: var(--pslp-green);
    border-color: var(--pslp-green);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f3f5;
}

::-webkit-scrollbar-thumb {
    background: #c9cdd1;
    border-radius: 3px;
}

/* ── Print ── */
@media print {

    .sidebar,
    .navbar,
    .btn,
    form,
    #offline-indicator,
    #offline-banner {
        display: none !important;
    }

    .main-content {
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}