@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
    --pharma-navy: #0b1e3b;
    --pharma-navy-dark: #071428;
    --pharma-sidebar: #0b1e3b;
    --pharma-sidebar-hover: #132d54;
    --pharma-primary: #1877f2;
    --pharma-primary-dark: #0d6efd;
    --pharma-primary-light: #eaf3ff;
    --pharma-sky: #38bdf8;
    --pharma-sky-light: #e0f2fe;
    --pharma-emerald: #10b981;
    --pharma-emerald-light: #e6f9f1;
    --pharma-amber: #f59e0b;
    --pharma-amber-light: #fff4e5;
    --pharma-rose: #ef4444;
    --pharma-rose-light: #ffeef0;
    --pharma-indigo: #1877f2;
    --pharma-indigo-light: #eaf3ff;
    --pharma-bg: #f3f7fb;
    --pharma-card: #ffffff;
    --pharma-border: #e6eff8;
    --pharma-text-dark: #0b1e3b;
    --pharma-text-muted: #64748b;
    --sidebar-width: 270px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', system-ui, -apple-system, sans-serif !important;
    background-color: var(--pharma-bg);
    color: var(--pharma-text-dark);
    margin: 0;
    padding: 0;
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
}

/* ========================================================
   SIDEBAR ARCHITECTURE (DEEP NAVY + ROYAL BLUE HARMONY)
   ======================================================== */
.pharma-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0b1e3b 0%, #091932 60%, #071428 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    box-shadow: -6px 0 28px rgba(11, 30, 59, 0.14);
    border-left: 1px solid rgba(255, 255, 255, 0.07);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pharma-sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-icon-box {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #1877f2 0%, #38bdf8 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.4rem;
    box-shadow: 0 6px 16px rgba(24, 119, 242, 0.35);
}

.brand-title {
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 900;
    margin: 0;
    line-height: 1.1;
}

.brand-title span {
    color: #60a5fa;
}

.brand-subtitle {
    color: #93b4d8;
    font-size: 0.72rem;
    margin: 0;
    font-weight: 500;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.sidebar-category {
    font-size: 0.72rem;
    font-weight: 800;
    color: #6c8db5;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 14px 16px 6px;
}

.sidebar-item {
    margin-bottom: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #d8e6f8 !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.91rem;
    border-radius: 11px;
    transition: all 0.2s ease;
}

/* Unified harmonious ice-blue icons across the entire sidebar */
.sidebar-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    color: #7cc0ff !important;
    transition: color 0.2s ease;
}

.sidebar-link:hover {
    background: rgba(24, 119, 242, 0.16);
    color: #ffffff !important;
    transform: translateX(-2px);
}

.sidebar-link:hover i {
    color: #ffffff !important;
}

.sidebar-link.active {
    background: linear-gradient(135deg, #1877f2 0%, #0d6efd 100%);
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(24, 119, 242, 0.4);
}

.sidebar-link.active i {
    color: #ffffff !important;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(5, 14, 30, 0.35);
}

/* ========================================================
   MAIN CONTENT WRAPPER & TOPBAR
   ======================================================== */
.pharma-main-wrapper {
    margin-right: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    background-color: var(--pharma-bg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pharma-main-wrapper.expanded {
    margin-right: 0 !important;
    width: 100% !important;
}
.pharma-sidebar.d-none-desktop {
    transform: translateX(100%);
}

/* TOP NAVBAR */
.pharma-topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--pharma-border);
    padding: 14px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(11, 30, 59, 0.03);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* ========================================================
   CARDS, HERO & KPI CONTAINERS (CLEAN WHITE & AZURE HARMONY)
   ======================================================== */
.card-custom, .card {
    background: #ffffff;
    border: 1px solid var(--pharma-border) !important;
    border-radius: 16px !important;
    padding: 22px;
    box-shadow: 0 4px 18px rgba(11, 30, 59, 0.035) !important;
    transition: all 0.22s ease;
    margin-bottom: 24px;
}

.card-custom:hover {
    box-shadow: 0 8px 26px rgba(11, 30, 59, 0.065) !important;
}

/* Clean airy light welcome header matching the reference dashboard */
.hero-banner {
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%) !important;
    border-radius: 18px;
    color: var(--pharma-navy) !important;
    box-shadow: 0 4px 20px rgba(11, 30, 59, 0.04);
    border: 1px solid #dbeafe !important;
}

.hero-banner h1,
.hero-banner h6,
.hero-banner .text-white {
    color: var(--pharma-navy) !important;
}

.hero-banner h1 span {
    color: var(--pharma-primary) !important;
}

.hero-banner .text-light {
    color: #475569 !important;
}

.hero-banner .text-info {
    color: var(--pharma-primary) !important;
}

.hero-banner .btn-outline-light {
    color: var(--pharma-navy) !important;
    border-color: #cbd5e1 !important;
    background: #ffffff;
}

.hero-banner .btn-outline-light:hover {
    background: var(--pharma-primary-light) !important;
    border-color: var(--pharma-primary) !important;
    color: var(--pharma-primary) !important;
}

.hero-banner .btn-outline-warning {
    color: var(--pharma-primary) !important;
    border-color: #bfdbfe !important;
    background: #eff6ff;
}

.hero-banner .btn-outline-warning:hover {
    background: var(--pharma-primary) !important;
    color: #ffffff !important;
}

.hero-banner .col-lg-4 > div {
    background: #ffffff !important;
    border: 1px solid #dbeafe !important;
    box-shadow: 0 4px 14px rgba(24, 119, 242, 0.06);
}

.hero-banner .progress {
    background: #e2e8f0 !important;
}

.hero-banner .progress-bar {
    background: linear-gradient(90deg, #1877f2 0%, #38bdf8 100%) !important;
}

.hero-banner .brand-icon-box {
    background: linear-gradient(135deg, #1877f2 0%, #38bdf8 100%) !important;
    color: #ffffff !important;
    border-radius: 14px !important;
    box-shadow: 0 6px 16px rgba(24, 119, 242, 0.25) !important;
}

/* Unified KPI Card styling like the reference screenshot */
.kpi-card {
    background: var(--pharma-card) !important;
    border: 1px solid var(--pharma-border) !important;
    border-radius: 16px !important;
    padding: 18px 22px !important;
    box-shadow: 0 4px 18px rgba(11, 30, 59, 0.035) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    box-shadow: 0 8px 24px rgba(11, 30, 59, 0.07) !important;
    transform: translateY(-2px);
}

.kpi-value {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--pharma-navy) !important;
    margin: 4px 0;
    line-height: 1.2;
}

.kpi-icon-pill {
    width: 50px;
    height: 50px;
    border-radius: 14px !important;
    background-color: var(--pharma-primary-light) !important;
    color: var(--pharma-primary) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* Soft unified border & icon boxes on KPI cards */
.card-custom.border-start.border-4,
.card-custom.border-top.border-4 {
    border-left: 1px solid var(--pharma-border) !important;
    border-right: 1px solid var(--pharma-border) !important;
    border-top: 1px solid var(--pharma-border) !important;
    border-bottom: 1px solid var(--pharma-border) !important;
}

.card-custom .rounded-circle {
    border-radius: 14px !important;
    background-color: var(--pharma-primary-light) !important;
    color: var(--pharma-primary) !important;
    width: 52px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.card-custom h3.text-danger,
.card-custom h4.text-danger,
.card-custom h3.text-primary,
.card-custom h4.text-primary,
.card-custom h3.text-success,
.card-custom h4.text-success,
.card-custom h3.text-info,
.card-custom h4.text-info,
.card-custom h3.text-warning-emphasis {
    color: var(--pharma-navy) !important;
}

.kpi-card.border-primary-subtle,
.kpi-card.border-success-subtle,
.kpi-card.border-warning-subtle,
.kpi-card.border-danger-subtle,
.kpi-card.border-info-subtle {
    border-right: 1px solid var(--pharma-border) !important;
}

.card-header {
    background-color: #ffffff !important;
    border-bottom: 1px solid var(--pharma-border) !important;
}

.btn-teal {
    background: linear-gradient(135deg, #1877f2 0%, #0d6efd 100%) !important;
    border: none !important;
    border-radius: 10px !important;
    color: #ffffff !important;
}

.text-teal, .text-emerald {
    color: var(--pharma-primary) !important;
}

/* ========================================================
   TABLES (CLEAN SOFT HEADER & ROWS LIKE REFERENCE)
   ======================================================== */
.table-pharma,
.table {
    background: #ffffff !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    border-color: var(--pharma-border) !important;
    width: 100%;
}

.table-pharma thead,
.table thead,
.table thead.table-dark,
.table-dark {
    background: #f4f8fc !important;
    border-bottom: 1px solid #e2eaf4 !important;
    --bs-table-bg: #f4f8fc !important;
    --bs-table-color: #5a6e85 !important;
    --bs-table-border-color: #e2eaf4 !important;
}

.table-pharma thead th,
.table thead th,
.table thead.table-dark th {
    padding: 13px 16px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    background: #f4f8fc !important;
    color: #5a6e85 !important;
    white-space: nowrap !important;
    border: none !important;
    border-bottom: 1px solid #e2eaf4 !important;
    vertical-align: middle !important;
}

.table-pharma tbody td,
.table tbody td {
    padding: 13px 16px !important;
    font-size: 13.5px !important;
    color: var(--pharma-navy);
    vertical-align: middle !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

.table-pharma tbody tr:hover td,
.table-hover tbody tr:hover td {
    background-color: #f8fbff !important;
}

/* عمود التاريخ لمنع تكسر التواريخ */
.col-date, .col-nowrap {
    white-space: nowrap !important;
    min-width: 115px !important;
    font-variant-numeric: tabular-nums !important;
}

/* Soft pastel status pills matching the reference image */
.badge-fefo, .badge-safe, .badge-danger-soft, .badge-neutral {
    display: inline-block !important;
    padding: 5px 12px !important;
    border-radius: 20px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    line-height: 1.3 !important;
    vertical-align: middle !important;
}
.badge-fefo {
    background-color: #fff4e5 !important;
    color: #d97706 !important;
    border: 1px solid #fde68a !important;
}
.badge-safe {
    background-color: #eaf3ff !important;
    color: #1877f2 !important;
    border: 1px solid #bfdbfe !important;
}
.badge-danger-soft {
    background-color: #ffeef0 !important;
    color: #e11d48 !important;
    border: 1px solid #fecdd3 !important;
}
.badge-neutral {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #e2e8f0 !important;
}

/* ========================================================
   BUTTONS, BADGES & CONTROLS
   ======================================================== */
.btn-pharma,
.btn-primary {
    background: linear-gradient(135deg, #1877f2 0%, #0d6efd 100%) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 11px;
    font-weight: 700;
    padding: 10px 22px;
    box-shadow: 0 4px 14px rgba(24, 119, 242, 0.28);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-pharma:hover,
.btn-primary:hover {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(24, 119, 242, 0.38);
}

.btn-pharma-emerald {
    background: linear-gradient(135deg, #1877f2 0%, #0284c7 100%);
    color: #ffffff !important;
    border: none;
    border-radius: 11px;
    font-weight: 700;
    padding: 10px 22px;
    box-shadow: 0 4px 14px rgba(24, 119, 242, 0.25);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-pharma-emerald:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.35);
}

.text-primary {
    color: #1877f2 !important;
}

.bg-primary:not(.bg-opacity-10):not(.bg-opacity-25):not(.bg-opacity-50):not(.bg-opacity-75) {
    background-color: #1877f2 !important;
}

/* High-contrast readable text & icon colors on white backgrounds */
.text-info {
    color: #0284c7 !important;
}

.text-warning {
    color: #d97706 !important;
}

.text-success {
    color: #15803d !important;
}

.text-danger {
    color: #dc2626 !important;
}

.text-muted {
    color: #334155 !important;
    font-weight: 600 !important;
}

.card-custom h4,
.card-custom h5,
.card-custom h6,
.card h4,
.card h5,
.card h6 {
    color: #0b1e3b !important;
    font-weight: 800 !important;
}

.card-custom p.small,
.card p.small {
    font-size: 0.9rem !important;
    line-height: 1.65 !important;
    color: #334155 !important;
    font-weight: 600 !important;
}

/* High-visibility tinted outline buttons */
.btn-outline-primary {
    background-color: #eaf3ff !important;
    color: #1877f2 !important;
    border: 1.5px solid #93c5fd !important;
    font-weight: 800 !important;
    border-radius: 10px !important;
    padding: 8px 16px;
}
.btn-outline-primary:hover {
    background-color: #1877f2 !important;
    color: #ffffff !important;
    border-color: #1877f2 !important;
}

.btn-outline-info {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
    border: 1.5px solid #7dd3fc !important;
    font-weight: 800 !important;
    border-radius: 10px !important;
    padding: 8px 16px;
}
.btn-outline-info:hover {
    background-color: #0284c7 !important;
    color: #ffffff !important;
    border-color: #0284c7 !important;
}

.btn-outline-success {
    background-color: #dcfce7 !important;
    color: #15803d !important;
    border: 1.5px solid #86efac !important;
    font-weight: 800 !important;
    border-radius: 10px !important;
    padding: 8px 16px;
}
.btn-outline-success:hover {
    background-color: #16a34a !important;
    color: #ffffff !important;
    border-color: #16a34a !important;
}

.btn-outline-warning {
    background-color: #fef3c7 !important;
    color: #b45309 !important;
    border: 1.5px solid #fcd34d !important;
    font-weight: 800 !important;
    border-radius: 10px !important;
    padding: 8px 16px;
}
.btn-outline-warning:hover {
    background-color: #d97706 !important;
    color: #ffffff !important;
    border-color: #d97706 !important;
}

.btn-outline-secondary {
    background-color: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1.5px solid #cbd5e1 !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
}
.btn-outline-secondary:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
    border-color: #334155 !important;
}

.btn-outline-danger {
    background-color: #ffeef0 !important;
    color: #dc2626 !important;
    border: 1.5px solid #fca5a5 !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
}
.btn-outline-danger:hover {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
}

.form-control, .form-select {
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background-color: #f8fafd;
    padding: 9px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--pharma-navy);
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    background-color: #ffffff;
    border-color: #1877f2;
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.14);
}

[dir="rtl"] .form-select {
    padding-inline-end: 2.25rem;
}

.badge {
    padding: 6px 12px;
    font-weight: 700;
    border-radius: 20px;
    font-size: 0.78rem;
}

/* RESPONSIVE */
@media (max-width: 992px) {
    html, body {
        overflow-x: hidden;
    }
    .pharma-sidebar {
        transform: translateX(100%);
        visibility: hidden;
    }
    .pharma-main-wrapper {
        margin-right: 0;
        width: 100%;
    }
    .pharma-sidebar.show {
        transform: translateX(0);
        visibility: visible;
    }
    .card, .card-custom {
        overflow: hidden;
    }
}

@media (max-width: 767.98px) {
    .pharma-topbar {
        padding: 0.6rem 0.85rem;
    }
    .btn {
        min-height: 40px;
    }
}

/* ========================================================
   PRINT MEDIA QUERY (CSS Fix for Printing Reports)
   ======================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 0.5cm;
    }

    .pharma-sidebar,
    .pharma-topbar,
    footer,
    .btn:not(.print-btn-keep),
    .no-print {
        display: none !important;
    }
    
    body {
        background-color: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
        width: 100% !important;
    }

    .pharma-main-wrapper {
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        min-height: auto !important;
        display: block !important;
    }
    
    main {
        padding: 0 !important;
        display: block !important;
        width: 100% !important;
    }
    
    .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }
    
    .card-custom, .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    /* Force Grid Columns to not stack in A4 Print */
    .row {
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
        width: 100% !important;
    }
    .col-md-3 { flex: 0 0 25% !important; max-width: 25% !important; }
    .col-md-4 { flex: 0 0 33.333333% !important; max-width: 33.333333% !important; }
    .col-md-6 { flex: 0 0 50% !important; max-width: 50% !important; }

    /* Remove horizontal scroll from tables */
    .table-responsive {
        overflow-x: visible !important;
        width: 100% !important;
    }

    .table-pharma {
        border: 1px solid #000 !important;
        width: 100% !important;
        max-width: 100% !important;
        font-size: 11px !important;
        table-layout: auto !important;
    }
    .table-pharma th, .table-pharma td {
        border: 1px solid #000 !important;
        color: #000 !important;
        padding: 6px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
    }

    /* Format Header Toolbar for clean print */
    .report-header-toolbar {
        background: #fff !important;
        color: #000 !important;
        border: 2px solid #333 !important;
        box-shadow: none !important;
        padding: 10px !important;
    }
    .report-header-toolbar * {
        color: #000 !important;
    }
    .report-header-toolbar .brand-icon-box {
        background: none !important;
        border: 1px solid #000;
        color: #000 !important;
    }

    /* Thermal Print Settings (80mm) */
    body.thermal-mode {
        width: 80mm !important;
        margin: 0 auto !important;
        padding: 0 !important;
        font-size: 10px !important;
    }
    body.thermal-mode * {
        line-height: 1.2 !important;
    }
    body.thermal-mode .table-pharma th, body.thermal-mode .table-pharma td {
        padding: 4px 2px !important;
        font-size: 9px !important;
        border-bottom: 1px dashed #000 !important;
        border-right: none !important;
        border-left: none !important;
        border-top: none !important;
    }
    body.thermal-mode .table-pharma {
        border: none !important;
    }
    body.thermal-mode h4, body.thermal-mode h6 {
        font-size: 14px !important;
        text-align: center !important;
    }
    body.thermal-mode .kpi-card {
        display: none !important;
    }
}
