/* =============================================================================
   PHARMACY MANAGEMENT SYSTEM - DESIGN SYSTEM
   Design 2 : Professional & Elegant  (light tinted, pharmacy blue)
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
    /* Brand blue + canonical palette (light SaaS theme).
       Dark saturated tones are for icons/text/buttons/accents only;
       cards and page surfaces stay white or light-tinted. */
    --primary: #1764D8;
    --primary-light: #EAF2FF;
    --success: #15803D;
    --success-light: #EAF8F0;
    --warning: #A16207;
    --warning-light: #FFF5DD;
    --danger: #DC2626;
    --danger-light: #FDECEC;
    --info: #1764D8;
    --info-light: #EAF2FF;
    --purple: #6D28D9;
    --purple-light: #F2ECFF;

    /* Brand - pharmacy blue ramp, anchored on the canonical primary. */
    --brand-50:  #EAF2FF;
    --brand-100: #DBEAFE;
    --brand-200: #BFDBFE;
    --brand-300: #93C5FD;
    --brand-400: #3B82F6;
    --brand-500: #1764D8;
    --brand-600: #1D4ED8;
    --brand-700: #1E40AF;
    --brand: #1764D8;
    --brand-dark: #1254B8;

    /* Soft semantic accents */
    --cyan-50:  #EAF2FF;
    --cyan-100: #CFFAFE;
    --cyan-500: #1764D8;
    --green-50:  #EAF8F0;
    --green-100: #DCFCE7;
    --green-500: #15803D;
    --orange-50:  #FFF5DD;
    --orange-100: #FFEDD5;
    --orange-500: #A16207;
    --red-50:  #FDECEC;
    --red-100: #FEE2E2;
    --red-500: #DC2626;
    --purple-50:  #F2ECFF;
    --purple-100: #EDE9FE;
    --purple-500: #6D28D9;

    /* Neutral surfaces - still light, but the page background is a clear step
       darker than the white cards so depth is obvious without any dark panel. */
    --bg:            #F5F7FB;
    --bg-soft:       #EAF0F8;
    --surface:       #ffffff;
    --card:          #ffffff;
    --surface-tint:  #F5F9FF;
    --surface-hover: #EEF4FE;
    --border:        #DDE6F2;
    --border-strong: #C9D8EA;

    /* Dark navy shell (sidebar + topbar) */
    --sidebar-bg:  #06245A;
    --sidebar-bg2: #031B46;
    --header-bg1:  #061D49;
    --header-bg2:  #0B3475;
    --header-bg3:  #123F82;

    /* Text */
    --text:        #0B214D;
    --text-soft:   #536B89;
    --muted:       #8FA1B8;
    --muted-light: #94A3B8;

    /* Elevation */
    --shadow-xs: 0 1px 2px rgba(18, 45, 85, .06);
    --shadow-sm: 0 1px 3px rgba(18, 45, 85, .08), 0 1px 2px rgba(18, 45, 85, .05);
    --shadow-md: 0 6px 18px rgba(18, 45, 85, .09);
    --shadow-lg: 0 16px 40px rgba(18, 45, 85, .14);

    /* Geometry */
    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    /* Layout */
    --sidebar-width: 264px;
    --sidebar-collapsed: 78px;
    --topbar-height: 64px;

    /* Mobile chrome metrics (used by the bottom tab bar and the sticky page
       header on phones). */
    --bottom-nav-height: 62px;
    --content-pad-inline: 1.5rem;

    --transition: 160ms cubic-bezier(.4, 0, .2, 1);
}

/* -----------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Hind Siliguri', 'Noto Sans Bengali', 'Nirmala UI', 'Segoe UI',
                 Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 .5rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

p { margin: 0 0 1rem; }

a { color: var(--brand-600); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-700); }

img { max-width: 100%; height: auto; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

::selection { background: var(--brand-100); color: var(--brand-700); }

:focus-visible {
    outline: 3px solid var(--brand-200);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Slim, soft scrollbars */
* { scrollbar-width: thin; scrollbar-color: #B9C9DD transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #B9C9DD; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted-light); background-clip: content-box; }

/* -----------------------------------------------------------------------------
   3. Typography helpers
   -------------------------------------------------------------------------- */
.text-muted   { color: var(--muted) !important; }
.text-soft    { color: var(--muted-light) !important; }
.text-brand   { color: var(--brand-600) !important; }
.text-success { color: var(--green-500) !important; }
.text-danger  { color: var(--red-500) !important; }
.text-warning { color: var(--orange-500) !important; }
.text-cyan    { color: var(--cyan-500) !important; }
.text-right   { text-align: right !important; }
.text-center  { text-align: center !important; }
.text-nowrap  { white-space: nowrap; }
.text-mono    { font-variant-numeric: tabular-nums; letter-spacing: .2px; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.fs-xs { font-size: .78rem; }
.fs-sm { font-size: .86rem; }
.fs-lg { font-size: 1.05rem; }

.mb-0 { margin-bottom: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mb-1 { margin-bottom: .35rem !important; }
.mb-2 { margin-bottom: .7rem !important; }
.mb-3 { margin-bottom: 1.1rem !important; }
.mt-1 { margin-top: .35rem !important; }
.mt-2 { margin-top: .7rem !important; }
.mt-3 { margin-top: 1.1rem !important; }

.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.flex-1 { flex: 1 1 auto; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .35rem; }
.gap-2 { gap: .7rem; }
.gap-3 { gap: 1.1rem; }
.w-100 { width: 100% !important; }

/* -----------------------------------------------------------------------------
   4. Cards
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 3px 14px rgba(15, 40, 80, .06);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.card-header.tinted { background: var(--surface-tint); }

.card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .55rem;
}

.card-title svg { color: var(--brand-500); flex-shrink: 0; }

.card-subtitle {
    margin: .15rem 0 0;
    font-size: .82rem;
    color: var(--muted);
    font-weight: 400;
}

.card-body { padding: 1.25rem; }
.card-body.tight { padding: .9rem 1.25rem; }
.card-body.flush { padding: 0; }

.card-footer {
    padding: .85rem 1.25rem;
    background: var(--surface-tint);
    border-top: 1px solid var(--border);
    font-size: .86rem;
    color: var(--muted);
}

/* -----------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .55rem 1.05rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition),
                color var(--transition), box-shadow var(--transition), transform var(--transition);
    text-decoration: none;
    user-select: none;
}

.btn svg { flex-shrink: 0; }

.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn.disabled {
    opacity: .6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: #fff;
    box-shadow: 0 1px 2px rgba(47, 120, 221, .35);
}
.btn-primary:hover { background: #1254B8; border-color: #1254B8; color: #fff; }

.btn-secondary {
    background: #F1F5FB;
    border-color: #D7E2F0;
    color: #173A70;
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--brand-300); color: var(--brand-700); }

.btn-success { background: var(--success-light); border-color: #BFE6CC; color: var(--success); }
.btn-success:hover { background: #DDF2E3; border-color: #BFE6CC; color: var(--success); }

.btn-danger { background: var(--danger-light); border-color: #F3C2C2; color: var(--danger); }
.btn-danger:hover { background: #FADFDF; border-color: #F3C2C2; color: var(--danger); }

.btn-warning { background: var(--orange-500); border-color: var(--orange-500); color: #fff; }
.btn-warning:hover { background: #B45309; border-color: #B45309; color: #fff; }

.btn-cyan { background: var(--cyan-500); border-color: var(--cyan-500); color: #fff; }
.btn-cyan:hover { background: #0f8fa5; border-color: #0f8fa5; color: #fff; }

.btn-outline {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}
.btn-outline:hover { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-700); }

.btn-outline-primary { background: transparent; border-color: var(--brand-300); color: var(--brand-600); }
.btn-outline-primary:hover { background: var(--brand-50); }

.btn-outline-danger { background: transparent; border-color: #f0c4c4; color: var(--red-500); }
.btn-outline-danger:hover { background: var(--red-50); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--brand-600); }

.btn-sm { padding: .34rem .7rem; font-size: .82rem; border-radius: 7px; }
.btn-lg { padding: .75rem 1.4rem; font-size: 1rem; }

.btn-block { width: 100%; }

.btn-icon {
    padding: .42rem;
    width: 34px;
    height: 34px;
    border-radius: 8px;
}
.btn-icon.btn-sm { width: 30px; height: 30px; padding: .3rem; }

.btn-group { display: inline-flex; gap: .35rem; flex-wrap: wrap; }

/* Loading state for buttons */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 15px; height: 15px;
    top: 50%; left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    color: #fff;
    animation: spin .6s linear infinite;
}
.btn-secondary.is-loading::after,
.btn-outline.is-loading::after { color: var(--brand-600); }

@keyframes spin { to { transform: rotate(360deg); } }

/* -----------------------------------------------------------------------------
   6. Badges & pills
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .22rem .6rem;
    border-radius: var(--radius-pill);
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-success { background: var(--green-50);  color: var(--green-500);  border: 1px solid var(--green-100); }
.badge-danger  { background: var(--red-50);    color: var(--red-500);    border: 1px solid var(--red-100); }
.badge-warning { background: var(--orange-50); color: var(--orange-500); border: 1px solid var(--orange-100); }
.badge-orange  { background: var(--orange-50); color: var(--orange-500); border: 1px solid var(--orange-100); }
.badge-info    { background: var(--cyan-50);   color: var(--cyan-500);   border: 1px solid var(--cyan-100); }
.badge-brand   { background: var(--brand-50);  color: var(--brand-600);  border: 1px solid var(--brand-100); }
.badge-muted   { background: var(--bg-soft);   color: var(--muted);      border: 1px solid var(--border); }
.badge-purple  { background: var(--purple-50); color: var(--purple-500); border: 1px solid var(--purple-100); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .75rem;
    border-radius: var(--radius-pill);
    background: var(--brand-50);
    color: var(--brand-600);
    border: 1px solid var(--brand-100);
    font-size: .82rem;
    font-weight: 600;
}

/* -----------------------------------------------------------------------------
   7. Alerts
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .85rem 1.05rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .9rem;
    margin-bottom: 1rem;
}

.alert svg { flex-shrink: 0; margin-top: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert strong { display: block; margin-bottom: .1rem; }

.alert-success { background: var(--green-50);  border-color: var(--green-100);  color: #106b42; }
.alert-danger  { background: var(--red-50);    border-color: var(--red-100);    color: #a53535; }
.alert-warning { background: var(--orange-50); border-color: var(--orange-100); color: #a2620f; }
.alert-info    { background: var(--cyan-50);   border-color: var(--cyan-100);   color: #0d7d90; }
.alert-brand   { background: var(--brand-50);  border-color: var(--brand-100);  color: var(--brand-700); }

.alert-close {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: inherit; opacity: .55; line-height: 1;
}
.alert-close:hover { opacity: 1; }

/* Toast stack */
.toast-stack {
    position: fixed;
    top: calc(var(--topbar-height) + 14px);
    right: 18px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand-500);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .75rem 1rem;
    font-size: .88rem;
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    animation: toastIn .22s cubic-bezier(.4, 0, .2, 1);
}

.toast.toast-success { border-left-color: var(--green-500); }
.toast.toast-error   { border-left-color: var(--red-500); }
.toast.toast-warning { border-left-color: var(--orange-500); }
.toast.toast-info    { border-left-color: var(--cyan-500); }
.toast.hiding { animation: toastOut .18s ease forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(18px); } }

/* -----------------------------------------------------------------------------
   8. Utility: section heading, dividers, empty state
   -------------------------------------------------------------------------- */
.section-heading {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted-light);
    margin: 0 0 .6rem;
}

.divider { height: 1px; background: var(--border); margin: 1rem 0; }

.empty-state {
    text-align: center;
    padding: 2.75rem 1.25rem;
    color: var(--muted);
}

.empty-state-icon {
    width: 62px; height: 62px;
    margin: 0 auto .9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand-50);
    color: var(--brand-400);
}

.empty-state h4 { margin: 0 0 .3rem; color: var(--text); font-size: 1rem; }
.empty-state p  { margin: 0; font-size: .88rem; }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-soft) 25%, var(--surface-hover) 37%, var(--bg-soft) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
    border-radius: 6px;
    height: 14px;
}

@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--brand-100);
    border-top-color: var(--brand-500);
    border-radius: 50%;
    animation: spin .65s linear infinite;
    display: inline-block;
}

.spinner-lg { width: 30px; height: 30px; border-width: 3px; }

/* Global blocking overlay */
.page-loading {
    position: fixed;
    inset: 0;
    background: rgba(244, 247, 251, .72);
    backdrop-filter: blur(1.5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}
.page-loading.active { display: flex; }

/* -----------------------------------------------------------------------------
   9. Avatars
   -------------------------------------------------------------------------- */
.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--brand-100);
    color: var(--brand-700);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--brand-200);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar-lg { width: 60px; height: 60px; font-size: 1.25rem; }

/* -----------------------------------------------------------------------------
   10. Tabs
   -------------------------------------------------------------------------- */
.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: .65rem 1rem;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}

.tab:hover { color: var(--brand-600); }
.tab.active { color: var(--brand-600); border-bottom-color: var(--brand-500); }

/* -----------------------------------------------------------------------------
   11. Modal
   -------------------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}
.modal.open { display: flex; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(30, 51, 80, .45);
    backdrop-filter: blur(1px);
    animation: fadeIn .16s ease;
}

.modal-dialog {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    animation: modalIn .2s cubic-bezier(.4, 0, .2, 1);
    margin: auto;
}

.modal-dialog.modal-sm { max-width: 420px; }
.modal-dialog.modal-lg { max-width: 760px; }
.modal-dialog.modal-xl { max-width: 1000px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-title { margin: 0; font-size: 1.05rem; font-weight: 600; }

.modal-body { padding: 1.25rem; overflow-y: auto; }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .6rem;
    padding: .9rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface-tint);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    flex-wrap: wrap;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

/* -----------------------------------------------------------------------------
   12. Dropdown menu
   -------------------------------------------------------------------------- */
.dropdown { position: relative; }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .35rem;
    z-index: 1100;
    display: none;
    animation: fadeIn .14s ease;
}

.dropdown.open .dropdown-menu { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .7rem;
    border-radius: 6px;
    color: var(--text);
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    width: 100%;
    border: 0;
    background: none;
    font-family: inherit;
    text-align: left;
    text-decoration: none;
}

.dropdown-item:hover { background: var(--brand-50); color: var(--brand-700); }
.dropdown-item.danger { color: var(--red-500); }
.dropdown-item.danger:hover { background: var(--red-50); }
.dropdown-divider { height: 1px; background: var(--border); margin: .3rem 0; }

/* -----------------------------------------------------------------------------
   13. Progress bar
   -------------------------------------------------------------------------- */
.progress {
    height: 7px;
    background: var(--bg-soft);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--brand-500);
    border-radius: 999px;
    transition: width .35s ease;
}
.progress-bar.success { background: var(--green-500); }
.progress-bar.warning { background: var(--orange-500); }
.progress-bar.danger  { background: var(--red-500); }

/* -----------------------------------------------------------------------------
   14. Print - hide chrome, show only the printable area
   -------------------------------------------------------------------------- */
@media print {
    .sidebar, .topbar, .no-print, .btn, .toast-stack, .page-loading { display: none !important; }
}
