/* ==========================================================================
   MODULE PHARMACIE CENTRALE - DESIGN SYSTEM NOFLAY
   Fichier : assets/css/pharmacie.css
   ========================================================================== */

:root {
    --pharma-primary: #0284c7;
    --pharma-primary-hover: #0369a1;
    --pharma-success: #059669;
    --pharma-danger: #dc2626;
    --pharma-warning: #d97706;
    --pharma-border: #e2e8f0;
    --pharma-bg: #f8fafc;
}

.pharma-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--pharma-bg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #0f172a;
    margin: 0;
}

/* Sidebar */
.pharma-sidebar {
    width: 260px;
    background: #0f172a;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 1.5rem 1rem;
    box-sizing: border-box;
}

.pharma-sidebar .sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
}

.pharma-sidebar .sidebar-logo {
    height: 38px;
    width: auto;
}

.pharma-sidebar .sidebar-title h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
}

.pharma-sidebar .sidebar-title span {
    font-size: 0.75rem;
    color: #94a3b8;
}

.pharma-sidebar .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.pharma-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
}

.pharma-sidebar .nav-link svg {
    width: 20px;
    height: 20px;
}

.pharma-sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.pharma-sidebar .nav-link.active {
    background: var(--pharma-primary);
    color: #ffffff;
}

/* Main Content */
.pharma-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    min-width: 0;
    box-sizing: border-box;
}

.pharma-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.pharma-topbar h1 {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 0 0 0.25rem 0;
    color: #0f172a;
}

.sub-header-date {
    font-size: 0.85rem;
    color: #64748b;
}

.pharma-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Cartes & Box */
.card-box {
    background: #ffffff;
    border: 1px solid var(--pharma-border);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Grille KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 0.5rem;
}

.kpi-card {
    background: #ffffff;
    border: 1px solid var(--pharma-border);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.kpi-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
}

.kpi-card.highlight-warning {
    border-left: 4px solid var(--pharma-warning);
}
.kpi-card.highlight-danger {
    border-left: 4px solid var(--pharma-danger);
    background: #fef2f2;
}
.kpi-card.highlight-danger .kpi-value {
    color: var(--pharma-danger);
}
.kpi-card.highlight-success {
    border-left: 4px solid var(--pharma-success);
}
.kpi-card.highlight-success .kpi-value {
    color: var(--pharma-success);
}

/* Formulaires & Grilles */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.input-form {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #0f172a;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-form:focus {
    border-color: var(--pharma-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Tableaux */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.data-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.data-table tr:hover td {
    background: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-primary { background: #e0f2fe; color: #0369a1; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-slate   { background: #f1f5f9; color: #475569; }

.badge-famille {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #475569;
    text-transform: capitalize;
}

.ticket-pill {
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--pharma-primary);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--pharma-primary-hover);
}

.btn-outline {
    background: #ffffff;
    color: var(--pharma-primary);
    border: 1.5px solid var(--pharma-primary);
}
.btn-outline:hover {
    background: #f0f9ff;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
}
.btn-sm.btn-primary { background: var(--pharma-primary); color: #fff; }
.btn-sm.btn-outline { background: #fff; color: var(--pharma-primary); border: 1px solid var(--pharma-primary); }
.btn-sm.btn-ghost   { background: transparent; color: #64748b; }
.btn-sm.btn-ghost:hover { background: #e2e8f0; color: #0f172a; }

.btn-delete-row {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-delete-row:hover {
    background: #dc2626;
    color: #ffffff;
}

/* Barre de recherche flottante */
.search-actes-wrapper {
    position: relative;
    width: 100%;
}

.actes-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1.5px solid var(--pharma-primary);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1050;
    margin-top: 4px;
}

.actes-search-results.d-none { display: none !important; }

.acte-suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}
.acte-suggestion-item:hover { background: #f0f9ff; }

/* Modales */
/* ==========================================================================
   CORRECTION BOÎTES MODALES & FORMULAIRES - PHARMACIE
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-overlay.d-none {
    display: none !important;
}

.modal-container {
    background: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh; /* Empêche le dépassement de l'écran */
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--pharma-border, #e2e8f0);
    background: #ffffff;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
}

.modal-body-scroll {
    padding: 1.25rem 1.5rem;
    overflow-y: auto; /* Permet le défilement fluide sans bloquer */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--pharma-border, #e2e8f0);
    background: #f8fafc;
    flex-shrink: 0; /* Reste toujours visible en bas */
}

/* Grilles internes souples pour la modale */
.modal-body-scroll .grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.modal-body-scroll .grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.modal-body-scroll .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.modal-body-scroll .form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
}

.modal-body-scroll .input-form {
    padding: 0.55rem 0.75rem;
    font-size: 0.88rem;
}
