/**
 * ==============================================================================
 * PHARMORA - SYSTÈME DE CONCEPTION & FEUILLE DE STYLE COMMUNE
 * ==============================================================================
 * Conçu pour l'application officielle de gestion d'officine pharmaceutique.
 * Ce fichier est destiné à être réutilisé par l'ensemble des modules du groupe.
 *
 * SOMMAIRE :
 * 1. Variables CSS globales (:root) extraites du logo officiel
 * 2. Règles de base et typographie
 * 3. Structure et mise en page (Layout, navigation latérale, Footer)
 * 4. Composants : Boutons
 * 5. Composants : Cartes et conteneurs
 * 6. Composants : Formulaires et champs de saisie
 * 7. Composants : Tableaux de données lisibles
 * 8. Composants : Badges d'état (Péremption, Stock, Rôles)
 * 9. Composants : Alertes et notifications
 * 10. Composants spécifiques : Page de connexion Split-Screen
 * 11. Utilitaires et Media Queries (Responsive)
 * ==============================================================================
 */

/* ==============================================================================
 * 1. VARIABLES CSS GLOBALES (:root)
 * Palette extraite avec précision du logo Pharmora :
 * - Bleu principal de la croix supérieure : #0A61AE
 * - Bleu marine foncé du bloc et texte :   #03214B
 * - Turquoise d'accentuation (stéthoscope) : #1AA89E
 * ============================================================================== */
:root {
    /* Couleurs de marque Pharmora */
    --ph-primary: #0A61AE;              /* Bleu médical principal pour les actions majeures */
    --ph-primary-hover: #084c8a;        /* Survol bleu foncé */
    --ph-primary-light: #eff6ff;        /* Bleu très pâle pour sélections et surlignages */
    --ph-primary-border: #bfdbfe;

    --ph-navy: #03214B;                 /* Bleu marine profond pour la navigation, titres */
    --ph-navy-hover: #021735;
    --ph-navy-light: #1e3a68;

    --ph-btn-cta: #0A61AE;              /* Boutons d'action (Encaisser, Générer, Envoyer...) */
    --ph-btn-cta-hover: #084c8a;
    --ph-accent: #1AA89E;               /* Turquoise d'accent pour points focaux et validations */
    --ph-accent-hover: #158a82;
    --ph-accent-light: #f0fdfa;
    --ph-accent-border: #99f6e4;

    /* Surfaces et fonds neutres */
    --ph-bg-body: #f8fafc;              /* Gris ardoise ultra-léger pour le fond général */
    --ph-bg-card: #ffffff;              /* Blanc pur pour cartes et tableaux */
    --ph-bg-surface: #f1f5f9;           /* Gris clair pour en-têtes de tables et séparateurs */
    --ph-border: #e2e8f0;               /* Bordure douce standard */
    --ph-border-focus: #1AA89E;         /* Halo turquoise sur le focus des champs */

    /* Typographie et contrastes de lecture */
    --ph-text-dark: #03214B;            /* Titres, textes à fort contraste */
    --ph-text-body: #334155;            /* Corps de texte principal (gris ardoise foncé) */
    --ph-text-muted: #64748b;           /* Métadonnées, descriptions secondaires */
    --ph-text-light: #ffffff;           /* Texte blanc pour fonds sombres */

    /* Couleurs d'état universelles (santé / pharmacie) */
    --ph-success: #16a34a;              /* Vert - Lot valide, action réussie */
    --ph-success-bg: #dcfce7;
    --ph-success-border: #bbf7d0;
    --ph-success-text: #15803d;

    --ph-warning: #d97706;              /* Orange - Bientôt périmé (< 90j), stock faible */
    --ph-warning-bg: #fef3c7;
    --ph-warning-border: #fde68a;
    --ph-warning-text: #b45309;

    --ph-danger: #dc2626;               /* Rouge vif - Périmé, rupture, erreur critique */
    --ph-danger-bg: #fee2e2;
    --ph-danger-border: #fecaca;
    --ph-danger-text: #b91c1c;

    --ph-info: #0A61AE;                 /* Bleu information */
    --ph-info-bg: #e0f2fe;
    --ph-info-border: #bae6fd;
    --ph-info-text: #0369a1;

    /* Ombres subtiles */
    --ph-shadow-sm: 0 1px 2px 0 rgba(3, 33, 75, 0.05);
    --ph-shadow-md: 0 4px 6px -1px rgba(3, 33, 75, 0.08), 0 2px 4px -2px rgba(3, 33, 75, 0.05);
    --ph-shadow-lg: 0 10px 15px -3px rgba(3, 33, 75, 0.08), 0 4px 6px -4px rgba(3, 33, 75, 0.04);

    /* Arrondis */
    --ph-radius-sm: 6px;
    --ph-radius-md: 10px;
    --ph-radius-lg: 16px;
}

/* ==============================================================================
 * 2. RÈGLES DE BASE ET TYPOGRAPHIE
 * ============================================================================== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--ph-bg-body);
    color: var(--ph-text-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--ph-text-dark);
    font-weight: 700;
    letter-spacing: -0.02em;
}

a {
    color: var(--ph-primary);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: var(--ph-primary-hover);
}

/* ==============================================================================
 * 3. STRUCTURE ET MISE EN PAGE (Layout)
 * ============================================================================== */
.app-body {
    display: block;
    min-width: 320px;
    overflow-x: hidden;
}

.app-layout {
    min-height: 100vh;
    background: var(--ph-bg-body);
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    width: 264px;
    flex-direction: column;
    overflow: hidden;
    background: #0b2545;
    color: #f8fafc;
    box-shadow: 3px 0 18px rgba(3, 33, 75, 0.12);
    transition: width .22s ease, transform .22s ease;
}

.sidebar-brand {
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.sidebar-brand-link {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: .7rem;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 750;
    white-space: nowrap;
}

.sidebar-brand-link:hover { color: #fff; }

.sidebar-logo {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 9px;
    background: #fff;
    object-fit: contain;
    padding: 2px;
}

.sidebar-brand-name { overflow: hidden; }

.sidebar-collapse-button,
.topbar-menu-button {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 9px;
    background: transparent;
    color: #e2e8f0;
    font-size: 1.05rem;
    transition: background-color .18s ease, color .18s ease;
}

.sidebar-collapse-button:hover,
.sidebar-collapse-button:focus-visible {
    background: rgba(255, 255, 255, .11);
    color: #fff;
}

.sidebar-navigation {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding: .8rem .75rem 1rem;
    scrollbar-color: rgba(255,255,255,.25) transparent;
    scrollbar-width: thin;
}

.sidebar-section + .sidebar-section { margin-top: 1.1rem; }

.sidebar-section-title {
    margin: 0 0 .4rem;
    padding: 0 .75rem;
    color: #91a6c1;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .11em;
    line-height: 1.5;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-link {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: .8rem;
    overflow: hidden;
    margin: .15rem 0;
    padding: .55rem .75rem;
    border-radius: 8px;
    color: #d7e2f0;
    font-size: .87rem;
    font-weight: 550;
    text-decoration: none;
    white-space: nowrap;
    transition: color .16s ease, background-color .16s ease;
}

.sidebar-link > i {
    width: 19px;
    flex: 0 0 19px;
    color: #afc3dc;
    font-size: 1rem;
    text-align: center;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.sidebar-link:hover > i { color: #fff; }

.sidebar-link.active,
.sidebar-link.active:hover {
    background: #1d63b8;
    color: #fff;
    box-shadow: 0 5px 12px rgba(4, 17, 39, .2);
}

.sidebar-link.active > i { color: #fff; }

.app-main {
    display: flex;
    min-width: 0;
    min-height: 100vh;
    flex-direction: column;
    margin-left: 264px;
    transition: margin-left .22s ease;
}

.app-topbar {
    position: sticky;
    z-index: 1020;
    top: 0;
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: .75rem clamp(1rem, 2.2vw, 2rem);
    border-bottom: 1px solid #e8edf3;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 2px 10px rgba(3, 33, 75, .035);
    backdrop-filter: blur(12px);
}

.topbar-leading,
.topbar-actions {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: .85rem;
}

.topbar-leading { flex: 1; }
.topbar-actions { flex: 0 0 auto; }

.global-search {
    position: relative;
    display: flex;
    width: min(100%, 560px);
    min-height: 42px;
    align-items: center;
    gap: .65rem;
    padding: 0 .8rem;
    border: 1px solid #e1e7ef;
    border-radius: 10px;
    background: #f8fafc;
    color: #718096;
    transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

.global-search:focus-within {
    border-color: #8db9e8;
    background: #fff;
    box-shadow: 0 0 0 .2rem rgba(29, 99, 184, .1);
}

.global-search-icon { flex: 0 0 auto; color: #718096; }

.global-search-input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #1e293b;
    font: inherit;
    font-size: .88rem;
}

.global-search-input::placeholder { color: #8a97a8; opacity: 1; }

.global-search-shortcut {
    display: inline-flex;
    min-width: 23px;
    height: 23px;
    align-items: center;
    justify-content: center;
    border: 1px solid #dfe5ec;
    border-radius: 5px;
    background: #fff;
    color: #8793a2;
    font-family: inherit;
    font-size: .76rem;
}

.global-search-results {
    position: absolute;
    z-index: 1080;
    top: calc(100% + .45rem);
    right: 0;
    left: 0;
    overflow: hidden;
    padding: .35rem;
    border: 1px solid #e4e9f0;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(3, 33, 75, .16);
}

.global-search-result {
    display: flex;
    min-height: 52px;
    align-items: center;
    gap: .7rem;
    padding: .5rem .65rem;
    border-radius: 7px;
    color: #27364a;
    text-decoration: none;
}

.global-search-result:hover,
.global-search-result:focus-visible {
    outline: 0;
    background: #f1f6fc;
    color: #173c68;
}

.global-search-result-icon {
    display: inline-flex;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #edf5fd;
    color: #1d63b8;
}

.global-search-result-copy { display: grid; min-width: 0; gap: .1rem; }
.global-search-result-title { overflow: hidden; font-size: .85rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.global-search-result-detail { overflow: hidden; color: #778496; font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.global-search-message { margin: 0; padding: .75rem; color: #748195; font-size: .84rem; }

.topbar-icon-button {
    position: relative;
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #506177;
    font-size: 1.12rem;
    transition: background-color .16s ease, color .16s ease;
}

.topbar-icon-button:hover,
.topbar-icon-button[aria-expanded="true"],
.topbar-icon-button.is-active {
    background: #eff5fb;
    color: #1d63b8;
}

.topbar-alert-badge {
    position: absolute;
    top: 3px;
    right: 1px;
    display: inline-flex;
    min-width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    padding: 0 .28rem;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: .63rem;
    font-weight: 700;
    line-height: 1;
}

.profile-menu-button {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: .6rem;
    padding: .25rem .4rem .25rem .25rem;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: #24354b;
    text-align: left;
}

.profile-menu-button:hover,
.profile-menu-button[aria-expanded="true"] { border-color: #e4eaf1; background: #f8fafc; }

.profile-avatar {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e9f2fb;
    color: #1d63b8;
    font-size: .95rem;
    font-weight: 750;
}

.profile-summary { display: grid; gap: .12rem; }
.profile-name { max-width: 145px; overflow: hidden; font-size: .84rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.profile-role { width: fit-content; padding: .18rem .38rem; font-size: .6rem; letter-spacing: .025em; }
.profile-chevron { color: #8995a5; font-size: .72rem; }

.topbar-dropdown {
    min-width: 230px;
    margin-top: .55rem !important;
    padding: .4rem;
    border: 1px solid #e8edf3;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(3, 33, 75, .14);
}

.topbar-dropdown .dropdown-item {
    display: flex;
    min-height: 40px;
    align-items: center;
    border-radius: 7px;
    color: #35445a;
    font-size: .84rem;
}

.topbar-dropdown .dropdown-item:hover { background: #f2f6fb; color: #173c68; }
.topbar-dropdown .dropdown-item.active { background: #edf5fd; color: #1d63b8; }
.topbar-dropdown .dropdown-item-danger { color: #c62838; }
.topbar-dropdown .dropdown-item-danger:hover { background: #fff0f1; color: #ad1f2d; }
.topbar-dropdown-heading { padding: .55rem .65rem .4rem; color: #738095; font-size: .7rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.profile-dropdown { min-width: 260px; }
.profile-dropdown-heading { display: grid; gap: .15rem; padding: .65rem .7rem .45rem; }
.profile-dropdown-heading strong { color: #26364b; font-size: .88rem; }
.profile-dropdown-heading span { overflow: hidden; color: #7a8798; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }

.topbar-menu-button { display: none; }
.sidebar-backdrop { display: none; }

.sidebar-collapsed .app-sidebar { width: 76px; }
.sidebar-collapsed .app-main { margin-left: 76px; }
.sidebar-collapsed .sidebar-brand { justify-content: space-between; gap: 0; padding-inline: .25rem; }
.sidebar-collapsed .sidebar-brand-link { width: 38px; flex: 0 0 38px; gap: 0; }
.sidebar-collapsed .sidebar-brand-name { display: none; }
.sidebar-collapsed .sidebar-collapse-button { width: 26px; height: 30px; flex-basis: 26px; padding: 0; font-size: .85rem; }
.sidebar-collapsed .sidebar-section-title { overflow: hidden; padding-inline: .4rem; font-size: 0; }
.sidebar-collapsed .sidebar-section-title::after { display: block; width: 22px; height: 1px; margin: .55rem auto; background: rgba(255,255,255,.18); content: ""; }
.sidebar-collapsed .sidebar-navigation { padding-inline: .55rem; }
.sidebar-collapsed .sidebar-link { justify-content: center; gap: 0; padding-inline: .4rem; }
.sidebar-collapsed .sidebar-link > i { width: 22px; flex-basis: 22px; font-size: 1.08rem; }
.sidebar-collapsed .sidebar-link > span { display: none; }

/* En-tête de page intérieur */
.page-header {
    background: #ffffff;
    border-bottom: 1px solid var(--ph-border);
    padding: 1.25rem 0;
    margin-bottom: 1.75rem;
}

.page-header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ph-navy);
    margin: 0;
}

.page-header-subtitle {
    font-size: 0.875rem;
    color: var(--ph-text-muted);
    margin-top: 0.25rem;
    margin-bottom: 0;
}

/* Pied de page */
.footer-pharmora {
    background-color: #ffffff;
    border-top: 1px solid var(--ph-border);
    margin-top: auto;
    padding: 1.25rem 0;
    font-size: 0.85rem;
    color: var(--ph-text-muted);
}

/* ==============================================================================
 * 4. COMPOSANTS : BOUTONS PHARMORA
 * ============================================================================== */
.btn-ph-primary {
    background-color: var(--ph-primary);
    border-color: var(--ph-primary);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--ph-radius-md);
    padding: 0.55rem 1.25rem;
    transition: all 0.2s ease;
    box-shadow: var(--ph-shadow-sm);
}

.btn-ph-primary:hover,
.btn-ph-primary:focus {
    background-color: var(--ph-primary-hover);
    border-color: var(--ph-primary-hover);
    color: #ffffff;
    box-shadow: var(--ph-shadow-md);
    transform: translateY(-1px);
}

.btn-ph-navy {
    background-color: var(--ph-navy);
    border-color: var(--ph-navy);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--ph-radius-md);
    padding: 0.55rem 1.25rem;
    transition: all 0.2s ease;
}

.btn-ph-navy:hover,
.btn-ph-navy:focus {
    background-color: var(--ph-navy-hover);
    border-color: var(--ph-navy-hover);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Bouton d'action principal : bleu de la marque (était turquoise/vert). Une seule variable à changer : --ph-btn-cta */
.btn-ph-accent {
    background-color: var(--ph-btn-cta);
    border-color: var(--ph-btn-cta);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--ph-radius-md);
    padding: 0.55rem 1.25rem;
    transition: all 0.2s ease;
}

.btn-ph-accent:hover,
.btn-ph-accent:focus {
    background-color: var(--ph-btn-cta-hover);
    border-color: var(--ph-btn-cta-hover);
    color: #ffffff;
}

.btn-ph-outline {
    background-color: transparent;
    border: 1px solid var(--ph-border);
    color: var(--ph-text-body);
    font-weight: 500;
    border-radius: var(--ph-radius-md);
    padding: 0.55rem 1.25rem;
    transition: all 0.2s ease;
}

.btn-ph-outline:hover {
    background-color: var(--ph-bg-surface);
    color: var(--ph-navy);
    border-color: #cbd5e1;
}

.btn-ph-danger {
    background-color: var(--ph-danger);
    border-color: var(--ph-danger);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--ph-radius-md);
    padding: 0.55rem 1.25rem;
}

.btn-ph-danger:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff;
}

/* ==============================================================================
 * 5. COMPOSANTS : CARTES ET CONTENEURS
 * ============================================================================== */
.card-ph {
    background-color: var(--ph-bg-card);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-lg);
    box-shadow: var(--ph-shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.card-ph-hover:hover {
    box-shadow: var(--ph-shadow-md);
    transform: translateY(-2px);
}

.card-ph .card-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--ph-border);
    font-weight: 700;
    color: var(--ph-navy);
    padding: 1.15rem 1.5rem;
}

.card-ph .card-body {
    padding: 1.5rem;
}

/* ==============================================================================
 * 6. COMPOSANTS : FORMULAIRES ET CHAMPS DE SAISIE
 * ============================================================================== */
.form-label-ph {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--ph-navy);
    margin-bottom: 0.4rem;
}

.form-control-ph,
.form-select-ph,
.form-control,
.form-select {
    border-radius: var(--ph-radius-md);
    border: 1.5px solid var(--ph-border);
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
    color: var(--ph-text-body);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control-ph:focus,
.form-select-ph:focus,
.form-control:focus,
.form-select:focus {
    border-color: var(--ph-primary);
    box-shadow: 0 0 0 3px rgba(10, 97, 174, 0.18);
    outline: none;
}

.input-feedback-error {
    color: var(--ph-danger-text);
    font-size: 0.825rem;
    margin-top: 0.35rem;
    font-weight: 500;
}

/* ==============================================================================
 * 7. COMPOSANTS : TABLEAUX DE DONNÉES LISIBLES
 * ============================================================================== */
.table-ph-wrapper {
    background-color: #ffffff;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-lg);
    box-shadow: var(--ph-shadow-sm);
    overflow: hidden;
}

.table-ph {
    margin-bottom: 0;
    width: 100%;
    vertical-align: middle;
}

.table-ph thead th {
    background-color: #f8fafc;
    color: var(--ph-navy);
    font-weight: 700;
    font-size: 0.825rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.95rem 1.25rem;
    border-bottom: 2px solid var(--ph-border);
    white-space: nowrap;
}

.table-ph tbody tr {
    transition: background-color 0.15s ease;
}

.table-ph tbody tr:hover {
    background-color: var(--ph-primary-light);
}

.table-ph tbody td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ph-border);
    color: var(--ph-text-body);
    font-size: 0.925rem;
}

.table-ph tbody tr:last-child td {
    border-bottom: none;
}

/* Cellule d'actions */
.table-ph .table-actions {
    text-align: right;
    white-space: nowrap;
}

.user-table {
    min-width: 860px;
    table-layout: fixed;
}

.user-column-account { width: 28%; }
.user-column-role { width: 13%; }
.user-column-created { width: 19%; }
.user-column-status { width: 12%; }
.user-column-actions { width: 28%; }

.user-role-badge {
    white-space: nowrap;
}

.user-table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: .3rem;
    white-space: nowrap;
}

.user-table-actions form {
    flex: 0 0 auto;
    margin: 0;
}

.user-table-actions .btn {
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: .35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.user-list-wrapper .table-responsive { overflow-x: auto; }
.user-table td, .user-table th { vertical-align: middle; }
.user-table td:nth-child(2), .user-table td:nth-child(3), .user-table td:nth-child(4), .user-role-badge { white-space: nowrap; }
.user-table td:first-child { overflow-wrap: anywhere; }
.user-table-actions form { display: inline-flex; }

@media (max-width: 1399.98px) {
    .admin-utilisateurs-form, .admin-utilisateurs-liste { flex: 0 0 100%; max-width: 100%; }
    .admin-utilisateurs-form { order: 0; }
    .admin-utilisateurs-liste { order: 1; }
}

@media (min-width: 1400px) {
    .admin-utilisateurs-form { flex: 0 0 33.333%; max-width: 33.333%; }
    .admin-utilisateurs-liste { flex: 0 0 66.667%; max-width: 66.667%; }
}

/* ==============================================================================
 * 8. COMPOSANTS : BADGES D'ÉTAT (PÉREMPTION, STOCKS, RÔLES)
 * ============================================================================== */
.badge-ph {
    font-size: 0.775rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.02em;
}

/* Rôles utilisateurs */
.badge-role-pharmacien {
    background-color: #e0f2fe;
    color: var(--ph-navy);
    border: 1px solid #bae6fd;
}

.badge-role-admin {
    background-color: #ede9fe;
    color: #4c1d95;
    border: 1px solid #c4b5fd;
}

.badge-role-caissier {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.badge-role-admin {
    background-color: #ede9fe;
    color: #4c1d95;
    border: 1px solid #c4b5fd;
}

/* Statuts de péremption des lots */
.badge-ph-valide {
    background-color: var(--ph-success-bg);
    color: var(--ph-success-text);
    border: 1px solid var(--ph-success-border);
}

.badge-ph-bientot-perime {
    background-color: var(--ph-warning-bg);
    color: var(--ph-warning-text);
    border: 1px solid var(--ph-warning-border);
}

.badge-ph-perime {
    background-color: var(--ph-danger-bg);
    color: var(--ph-danger-text);
    border: 1px solid var(--ph-danger-border);
}

/* Statuts de stock */
.badge-stock-ok {
    background-color: var(--ph-success-bg);
    color: var(--ph-success-text);
    border: 1px solid var(--ph-success-border);
}

.badge-stock-alerte {
    background-color: var(--ph-warning-bg);
    color: var(--ph-warning-text);
    border: 1px solid var(--ph-warning-border);
    font-weight: 700;
}

.badge-stock-rupture {
    background-color: var(--ph-danger-bg);
    color: var(--ph-danger-text);
    border: 1px solid var(--ph-danger-border);
    font-weight: 700;
}

/* ==============================================================================
 * 9. COMPOSANTS : ALERTES ET NOTIFICATIONS
 * ============================================================================== */
.alert-ph {
    border-radius: var(--ph-radius-md);
    border-width: 1px;
    border-style: solid;
    padding: 0.95rem 1.25rem;
    font-size: 0.925rem;
    box-shadow: var(--ph-shadow-sm);
}

.alert-ph-success {
    background-color: var(--ph-success-bg);
    border-color: var(--ph-success-border);
    color: var(--ph-success-text);
}

.alert-ph-danger {
    background-color: var(--ph-danger-bg);
    border-color: var(--ph-danger-border);
    color: var(--ph-danger-text);
}

.alert-ph-warning {
    background-color: var(--ph-warning-bg);
    border-color: var(--ph-warning-border);
    color: var(--ph-warning-text);
}

.alert-ph-info {
    background-color: var(--ph-info-bg);
    border-color: var(--ph-info-border);
    color: var(--ph-info-text);
}

/* ==============================================================================
 * 10. COMPOSANTS : PAGE DE CONNEXION SPLIT-SCREEN
 * Inspiré de la disposition 50/50 de la référence utilisateur
 * ============================================================================== */
.login-split-wrapper {
    min-height: 100vh;
    display: flex;
    width: 100%;
}

/* Panneau gauche : Visuel immersif aux couleurs de Pharmora */
.login-visual-panel {
    flex: 1.1;
    background-image: linear-gradient(145deg, rgba(3, 33, 75, 0.88) 0%,rgba(6, 57, 113, 0.78) 60%, rgba(10, 97, 174, 0.78) 100%),url("../image/download.jfif");
    background-position: center, center 30%;
    background-size: cover, cover;
    background-repeat: no-repeat;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3.5rem;
    color: #ffffff;
    overflow: hidden;
}

.login-visual-panel::before {
    content: '';
    position: absolute;
    top: -100px;
    right: -100px;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(26, 168, 158, 0.25) 0%, rgba(26, 168, 158, 0) 70%);
    pointer-events: none;
}

.login-visual-panel::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: -80px;
    width: 350px;
    height: 350px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(10, 97, 174, 0.3) 0%, rgba(10, 97, 174, 0) 70%);
    pointer-events: none;
}

.login-visual-top {
    position: relative;
    z-index: 2;
}

.login-visual-logo {
    height: 60px;
    width: auto;
    background: #ffffff;
    padding: 6px 12px;
    border-radius: var(--ph-radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.login-visual-bottom {
    position: relative;
    z-index: 2;
    max-width: 520px;
}

.login-visual-headline {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.login-visual-slogan {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
    margin-bottom: 0;
}

/* Panneau droit : Formulaire d'authentification */
.login-form-panel {
    flex: 0.9;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem 2rem;
}

.login-form-container {
    width: 100%;
    max-width: 420px;
}

.login-eyebrow {
    color: var(--ph-accent);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.login-eyebrow.login-profile-admin { color: #5548a6; }
.login-eyebrow.login-profile-pharmacien { color: #0b817a; }
.login-eyebrow.login-profile-caissier { color: #a45d0a; }

.login-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--ph-navy);
    margin-bottom: 0.4rem;
}

.login-subtitle {
    color: var(--ph-text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

/* ==============================================================================
 * 11. MEDIA QUERIES (RESPONSIVE)
 * ============================================================================== */
@media (max-width: 991.98px) {
    .login-split-wrapper {
        flex-direction: column;
    }

    .login-visual-panel {
        flex: none;
        padding: 2rem;
        min-height: auto;
    }

    .login-visual-headline {
        font-size: 1.5rem;
    }

    .login-visual-slogan {
        font-size: 0.95rem;
    }

    .login-form-panel {
        padding: 2.5rem 1.5rem;
    }
}

/* ==============================================================================
 * 12. COMPOSANTS ADDITIONNELS (modules Produits, Catégories, Fournisseurs, Lots)
 * Réutilisables par les autres modules du groupe.
 * ============================================================================== */
.text-ph-accent { color: var(--ph-accent); }
.text-ph-navy { color: var(--ph-navy); }

/* Titre de page avec bouton d'action à droite */
.page-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Barre de filtres au-dessus d'un tableau */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
    background: #ffffff;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--ph-shadow-sm);
}
.filter-bar .form-control, .filter-bar .form-select { min-width: 200px; }

/* Cartes d'indicateurs (stats rapides) */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #ffffff;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-lg);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--ph-shadow-sm);
    color: inherit;
    height: 100%;
}
a.stat-card:hover { box-shadow: var(--ph-shadow-md); border-color: var(--ph-primary-border); color: inherit; }
.stat-card .stat-value { font-size: 1.65rem; font-weight: 800; color: var(--ph-navy); line-height: 1.1; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--ph-text-muted); }
.stat-icon {
    flex: 0 0 auto;
    width: 46px; height: 46px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--ph-radius-md);
    font-size: 1.35rem;
}
.stat-icon.is-primary { background: var(--ph-primary-light); color: var(--ph-primary); }
.stat-icon.is-accent  { background: var(--ph-accent-light);  color: var(--ph-accent-hover); }
.stat-icon.is-warning { background: var(--ph-warning-bg);    color: var(--ph-warning-text); }
.stat-icon.is-danger  { background: var(--ph-danger-bg);     color: var(--ph-danger-text); }

/* Puces de filtre rapide (lots : valide / bientôt périmé / périmé) */
.chip-filter {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    border: 1px solid var(--ph-border);
    background: #ffffff;
    color: var(--ph-text-body);
    font-size: 0.85rem; font-weight: 600;
}
.chip-filter:hover { border-color: var(--ph-primary-border); color: var(--ph-navy); }
.chip-filter.is-active { background: var(--ph-navy); border-color: var(--ph-navy); color: #ffffff; }

/* Boutons d'action compacts dans les tableaux */
.btn-icon {
    width: 34px; height: 34px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--ph-radius-sm);
}

/* Ligne de tableau mise en évidence selon l'état */
.table-ph tbody tr.row-perime { background-color: #fff7f7; }
.table-ph tbody tr.row-alerte { background-color: #fffcf2; }

/* Message "aucun résultat" */
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--ph-text-muted); }
.empty-state i { font-size: 2.5rem; color: #cbd5e1; display: block; margin-bottom: 0.5rem; }

/* Bouton afficher / masquer le mot de passe */
.btn-eye { border: 1.5px solid var(--ph-border); border-left: 0; background: #ffffff; color: var(--ph-text-muted); }
.btn-eye:hover { color: var(--ph-navy); background: var(--ph-bg-surface); }

/* Focus clavier visible partout */
a:focus-visible, button:focus-visible, .form-control:focus-visible, .form-select:focus-visible {
    outline: 2px solid var(--ph-accent);
    outline-offset: 2px;
}

/* Bannière d'accueil du tableau de bord */
.welcome-banner {
    background: linear-gradient(135deg, var(--ph-navy) 0%, #063971 65%, var(--ph-primary) 100%);
    color: #ffffff;
    border-radius: var(--ph-radius-lg);
    padding: 1.75rem 2rem;
    position: relative;
    overflow: hidden;
}
.welcome-banner h1 { color: #ffffff; }
.welcome-banner::after {
    content: '';
    position: absolute; right: -60px; top: -60px;
    width: 220px; height: 220px; border-radius: 50%;
    background: radial-gradient(circle, rgba(26,168,158,0.35) 0%, rgba(26,168,158,0) 70%);
    pointer-events: none;
}

/* Icône des cartes de modules */
.module-icon {
    width: 52px; height: 52px; flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--ph-radius-md);
    font-size: 1.5rem;
}

/* Page d'initialisation centrée */
.centered-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ==============================================================================
 * RESPONSIVE GLOBAL
 * Ajustements communs à tous les modules (tableaux, formulaires, navigation).
 * ==============================================================================
 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }
* { box-sizing: border-box; }
img, svg, canvas { max-width: 100%; }
.container-fluid, main, .card-ph, .table-ph-wrapper { min-width: 0; }
.table-ph-wrapper { max-width: 100%; }
.table-responsive { -webkit-overflow-scrolling: touch; }
.form-control, .form-select, .input-group { min-width: 0; }
.page-title-row > *, .filter-bar > * { min-width: 0; }

/* Sécurité globale contre les débordements de texte et de composants */
main, section, article, aside, form, .card-ph, .card-body,
.page-title-row, .filter-bar, .welcome-banner, .modal-content { min-width: 0; }
.card-ph, .card-body, .filter-bar, .page-title-row,
.welcome-banner, .stat-card, .mini-kpi, .ticket { overflow-wrap: anywhere; }
.table-ph-wrapper, .table-responsive, .modal-dialog { max-width: 100%; }
.table-responsive { width: 100%; }
.table-responsive table { margin-bottom: 0; }
.table-ph .table-actions { white-space: normal; }
.table-actions .btn { margin: 0.15rem; }
.modal-dialog { margin: 0.5rem auto; }
.modal-body, .modal-header, .modal-footer { min-width: 0; }
.btn-group { max-width: 100%; flex-wrap: wrap; }
.btn, .form-control, .form-select { max-width: 100%; }
.input-group { width: 100%; }
.alert, .badge-ph { overflow-wrap: anywhere; }
.d-flex.gap-2, .d-flex.gap-3 { flex-wrap: wrap; }

@media (max-width: 1599.98px) {
    .page-header { margin-bottom: 1.25rem; }
    main.flex-grow-1 { padding-top: 1.25rem !important; }
    .container-fluid { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .welcome-banner { padding: 1.35rem 1.25rem; }
    .welcome-banner .btn { min-height: 44px; }
    .card-ph .card-header { padding: 1rem 1.1rem; }
    .card-ph .card-body { padding: 1.1rem; }
    .filter-bar .form-control,
    .filter-bar .form-select { width: 100%; min-width: 0; }
    .filter-bar > div { flex: 1 1 220px; }
    .filter-bar > .btn { min-height: 44px; }
}

@media (max-width: 575.98px) {
    .page-title-row {
        align-items: flex-start;
        margin-bottom: 1.1rem;
    }
    .page-title-row > div:last-child,
    .page-title-row > a,
    .page-title-row > .btn { width: 100%; }
    .page-title-row > div:last-child .btn,
    .page-title-row > .btn { width: 100%; }
    .page-header-title { font-size: 1.25rem; line-height: 1.25; }
    .page-header-subtitle { font-size: 0.82rem; }

    .welcome-banner h1 { font-size: 1.35rem; }
    .welcome-banner p { font-size: 0.9rem; }
    .welcome-banner .d-flex.flex-wrap > .btn { flex: 1 1 100%; }

    .filter-bar { padding: 0.85rem; }
    .filter-bar > div { flex-basis: 100%; }
    .filter-bar > .btn,
    .filter-bar > a.btn { width: 100%; }

    .stat-card {
        align-items: flex-start;
        gap: 0.65rem;
        padding: 0.85rem 0.75rem;
    }
    .stat-card .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
    .stat-card .stat-value { font-size: 1.25rem; }
    .stat-card .stat-label { font-size: 0.75rem; line-height: 1.25; }

    .btn, .form-control, .form-select, .input-group-text { min-height: 44px; }
    .btn-icon { min-height: 34px; height: 34px; }
    .card-ph .card-body { padding: 0.9rem; }
    .table-ph thead th { padding: 0.75rem 0.85rem; }
    .table-ph tbody td { padding: 0.75rem 0.85rem; }
    .table-ph-wrapper .table-responsive {
        margin: 0;
        border-radius: var(--ph-radius-lg);
    }
    .thumb-produit { width: 42px; height: 42px; }

    .footer-pharmora { padding: 0.85rem 0; }
    .footer-pharmora .container-fluid { gap: 0.25rem !important; }
    .login-split-wrapper { min-height: 100dvh; }
    .login-visual-panel {
        min-height: 190px;
        padding: 1.25rem;
        justify-content: flex-end;
    }
    .login-visual-logo { height: 44px; }
    .login-visual-headline { font-size: 1.35rem; margin-bottom: 0.35rem; }
    .login-visual-slogan { display: none; }
    .login-form-panel { padding: 1.5rem 1rem; justify-content: flex-start; }
    .login-title { font-size: 1.65rem; }
    .login-subtitle { margin-bottom: 1.25rem; }

    .modal-dialog { width: calc(100% - 1rem); }
    .modal-header, .modal-body, .modal-footer { padding: 0.9rem; }
    .modal-footer { gap: 0.5rem; }
    .modal-footer > .btn { flex: 1 1 140px; }
    .produit-photo-apercu { width: 96px; height: 96px; }
    .filter-bar .d-flex,
    .page-title-row .d-flex,
    .card-body .d-flex { min-width: 0; }
    .filter-bar .d-flex.gap-2 > *,
    .page-title-row .d-flex.gap-2 > *,
    .card-body .d-flex.gap-2 > .btn { max-width: 100%; }
    .mini-kpi { min-height: 72px; }
    .mini-kpi .v { font-size: 1.05rem; }
    .ticket { border-radius: 0; padding: 1rem 0.75rem; }
    .ticket table { font-size: 0.82rem; }
}

@media (max-width: 359.98px) {
    html, body { width: 100%; max-width: 100%; }
    .row { margin-left: 0 !important; margin-right: 0 !important; }
    .row > [class*="col-"] { padding-left: 0.375rem; padding-right: 0.375rem; }
    .container-fluid { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .stat-card { display: block; }
    .stat-card .stat-icon { margin-bottom: 0.5rem; }
    .stat-card .stat-value { font-size: 1.1rem; }
    .btn, .btn-group, .badge-ph { overflow-wrap: anywhere; }
    .modal-dialog { width: calc(100% - 0.5rem); margin-left: 0.25rem; margin-right: 0.25rem; }
    .mini-kpi .v { font-size: 0.95rem; }
}


/* ==============================================================================
 * PHOTOS DES PRODUITS (catalogue, formulaire produit)
 * ============================================================================== */
.thumb-produit, .produit-photo-apercu {
    display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex: 0 0 auto;
    background: var(--ph-bg-surface); border: 1px solid var(--ph-border); color: var(--ph-text-muted);
}
.thumb-produit { width: 48px; height: 48px; border-radius: var(--ph-radius-md); font-size: 1.3rem; }
.thumb-produit img { width: 100%; height: 100%; object-fit: contain; background: #ffffff; }
.produit-photo-apercu { width: 120px; height: 120px; border-radius: var(--ph-radius-lg); font-size: 2.6rem; }
.produit-photo-apercu img { width: 100%; height: 100%; object-fit: contain; background: #ffffff; }

@media (max-width: 991.98px) {
    .app-main,
    .sidebar-collapsed .app-main { margin-left: 0; }

    .app-sidebar {
        z-index: 1060;
        width: min(292px, calc(100vw - 56px));
        transform: translateX(-105%);
    }

    .sidebar-collapsed .app-sidebar { width: min(292px, calc(100vw - 56px)); }
    .sidebar-open .app-sidebar { transform: translateX(0); }
    .sidebar-open .sidebar-brand { justify-content: space-between; padding-inline: 1rem; }
    .sidebar-open .sidebar-brand-name,
    .sidebar-open .sidebar-collapse-button { display: inline-flex; }
    .sidebar-open .sidebar-brand-name { display: block; }
    .sidebar-open .sidebar-section-title { overflow: visible; padding-inline: .75rem; font-size: .66rem; }
    .sidebar-open .sidebar-section-title::after { display: none; }
    .sidebar-open .sidebar-navigation { padding-inline: .75rem; }
    .sidebar-open .sidebar-link { justify-content: flex-start; gap: .8rem; padding-inline: .75rem; }
    .sidebar-open .sidebar-link > i { width: 19px; flex-basis: 19px; }
    .sidebar-open .sidebar-link > span { display: inline; }

    .sidebar-backdrop {
        position: fixed;
        z-index: 1050;
        inset: 0;
        display: block;
        border: 0;
        background: rgba(8, 20, 38, .48);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    .topbar-menu-button { display: inline-flex; border-color: #e4eaf1; color: #43556d; }
    .topbar-menu-button:hover { background: #f0f5fa; color: #1d63b8; }
}

@media (max-width: 575.98px) {
    .app-topbar { min-height: 62px; gap: .5rem; padding: .55rem .65rem; }
    .topbar-leading,
    .topbar-actions { gap: .4rem; }
    .topbar-menu-button { width: 38px; height: 38px; flex-basis: 38px; }
    .global-search { min-height: 39px; gap: .45rem; padding-inline: .6rem; }
    .global-search-input { font-size: .78rem; }
    .global-search-shortcut { display: none; }
    .topbar-icon-button { width: 38px; height: 38px; }
    .profile-menu-button { min-height: 40px; gap: .35rem; padding-right: .1rem; }
    .profile-avatar { width: 34px; height: 34px; flex-basis: 34px; }
    .profile-summary { display: none; }
    .profile-chevron { font-size: .65rem; }
    .topbar-dropdown { position: absolute; }
}

@media (max-width: 359.98px) {
    .app-topbar { padding-inline: .45rem; }
    .topbar-leading,
    .topbar-actions { gap: .25rem; }
    .global-search { padding-inline: .45rem; }
    .global-search-input { font-size: .72rem; }
}
