/* The shell every signed-in dashboard shares — patient, doctor, pharmacy, medical
   centre and admin.

   Structure follows Doccure's patient-profile page: a page-title banner, then a
   centred container holding a profile/navigation card beside the page content.
   It is written role-neutrally so one stylesheet serves all of them, with a single
   token layer that dark mode re-points rather than repainting rule by rule, and
   logical properties throughout so Arabic mirrors without a second stylesheet. */

/* Declared on the root as well as the shell: the sidebar is also used by the
   doctor and patient areas, which have their own page wrappers and no
   .dashboard-shell element. Scoping the tokens to that class alone left every
   var() unresolved there — a card with no surface, border or shadow. */
:root,
.dashboard-shell {
    --dash-surface: #ffffff;
    --dash-surface-2: #f6f8fc;
    --dash-border: #e6eaf2;
    --dash-text: var(--care-ink, #0f172a);
    --dash-text-muted: #5b6577;
    --dash-accent: var(--care-primary-dark, #1c4fd8);
    --dash-accent-soft: var(--care-accent, #eef3ff);
    --dash-page-bg: #ffffff;
    --dash-banner-bg:
        radial-gradient(circle at 5% 30%, rgba(8, 118, 93, .1), transparent 10rem),
        radial-gradient(circle at 92% 20%, rgba(74, 160, 216, .14), transparent 13rem),
        var(--care-surface-soft, #f4f8ff);
    --dash-radius: .75rem;
    --dash-shadow: 0 .75rem 2rem rgba(15, 23, 42, .06);
}

/* Page-title banner ---------------------------------------------------------- */

.dashboard-page-heading {
    position: relative;
    overflow: hidden;
    padding-block: 2.25rem;
    background: var(--dash-banner-bg);
}

.dashboard-page-heading::after {
    position: absolute;
    inset-block-end: -4.5rem;
    inset-inline-end: 4%;
    width: 9rem;
    height: 9rem;
    content: "";
    border: 2px solid rgba(8, 118, 93, .13);
    border-radius: 50%;
}

.dashboard-page-heading .container {
    position: relative;
    z-index: 1;
}

.dashboard-page-heading h1 {
    margin: 0;
    color: var(--dash-text);
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
}

.dashboard-page-description {
    max-width: 60ch;
    margin-block: .5rem 0;
    color: var(--dash-text-muted);
}

.dashboard-breadcrumb {
    --bs-breadcrumb-divider-color: var(--dash-text-muted);
    --bs-breadcrumb-item-active-color: var(--dash-text-muted);
    font-size: .9rem;
}

.dashboard-breadcrumb a {
    color: var(--dash-accent);
    text-decoration: none;
}

.dashboard-breadcrumb a:hover,
.dashboard-breadcrumb a:focus-visible {
    text-decoration: underline;
}

/* Page body ------------------------------------------------------------------ */

.dashboard-page {
    padding-block: 3rem 4.5rem;
    background: var(--dash-page-bg);
}

/* Sidebar card --------------------------------------------------------------- */

.dashboard-sidebar-card {
    position: sticky;
    inset-block-start: 1rem;
    overflow: hidden;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
    box-shadow: var(--dash-shadow);
}

.dashboard-sidebar-profile {
    position: relative;
}

.dashboard-sidebar-banner {
    height: 5.5rem;
    background:
        radial-gradient(circle at 20% 40%, rgba(8, 118, 93, .35), transparent 60%),
        linear-gradient(135deg, #08765d, #4aa0d8);
}

.dashboard-sidebar-identity {
    position: relative;
    padding: 0 1.25rem 1.25rem;
    text-align: center;
}

.dashboard-sidebar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 5rem;
    height: 5rem;
    margin-block-start: -2.5rem;
    margin-block-end: .75rem;
    overflow: hidden;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--dash-accent);
    border: 4px solid var(--dash-surface);
    border-radius: 50%;
}

.dashboard-sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dashboard-sidebar-name {
    margin: 0;
    color: var(--dash-text);
    font-size: 1.0625rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.dashboard-sidebar-role {
    margin: .125rem 0 0;
    color: var(--dash-accent);
    font-size: .875rem;
    font-weight: 600;
}

.dashboard-sidebar-identifier {
    margin: .25rem 0 0;
    color: var(--dash-text-muted);
    font-size: .8125rem;
    overflow-wrap: anywhere;
}

.dashboard-sidebar-subtitle {
    margin: .25rem 0 0;
    color: var(--dash-text-muted);
    font-size: .8125rem;
}

.dashboard-sidebar-status {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    margin: .5rem 0 0;
    color: var(--dash-text-muted);
    font-size: .8125rem;
}

.dashboard-status-dot {
    width: .5rem;
    height: .5rem;
    background: #16a34a;
    border-radius: 50%;
}

/* Sidebar navigation --------------------------------------------------------- */

.dashboard-sidebar-menu {
    padding: .5rem 0 1rem;
    border-block-start: 1px solid var(--dash-border);
}

.dashboard-sidebar-menu ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dashboard-sidebar-group-title {
    margin: 1rem 0 .25rem;
    padding-inline: 1.25rem;
    color: var(--dash-text-muted);
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.dashboard-sidebar-menu > ul:first-of-type .dashboard-sidebar-group-title:first-child {
    margin-block-start: .5rem;
}

.dashboard-sidebar-link {
    display: flex;
    align-items: center;
    gap: .625rem;
    width: 100%;
    /* Comfortably past the 44px touch target on every device. */
    min-height: 2.75rem;
    padding: .5rem 1.25rem;
    color: var(--dash-text-muted);
    font-size: .9375rem;
    font-weight: 500;
    text-align: start;
    text-decoration: none;
    background: none;
    border: 0;
    /* The active marker is a bar on the reading edge, so it mirrors in Arabic. */
    border-inline-start: 3px solid transparent;
}

.dashboard-sidebar-link > i {
    flex: 0 0 auto;
    width: 1.25rem;
    font-size: 1.05rem;
    text-align: center;
}

/* The chevron is also a span child, so it has to be excluded here — otherwise it
   inherits the label's flex-grow and stretches across the row. */
.dashboard-sidebar-link > span:not(.dashboard-sidebar-arrow):not(.dashboard-sidebar-badge) {
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

.dashboard-sidebar-link:hover,
.dashboard-sidebar-link:focus-visible {
    color: var(--dash-accent);
    background: var(--dash-accent-soft);
}

.dashboard-sidebar-link:focus-visible {
    outline: 2px solid var(--dash-accent);
    outline-offset: -2px;
}

.dashboard-sidebar-item.active > .dashboard-sidebar-link,
.dashboard-sidebar-link.active {
    color: var(--dash-accent);
    font-weight: 600;
    background: var(--dash-accent-soft);
    border-inline-start-color: var(--dash-accent);
}

.dashboard-sidebar-badge {
    flex: 0 0 auto;
    min-width: 1.5rem;
    padding: .0625rem .375rem;
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    text-align: center;
    background: var(--dash-accent);
    border-radius: 999px;
}

/* Collapsible group ---------------------------------------------------------- */

.dashboard-sidebar-arrow {
    flex: 0 0 auto;
    width: .5rem;
    height: .5rem;
    border-inline-end: 2px solid currentcolor;
    border-block-start: 2px solid currentcolor;
    /* Points along the reading direction, so Arabic gets the mirrored chevron. */
    transform: rotate(45deg);
}

[dir="rtl"] .dashboard-sidebar-arrow {
    transform: rotate(-135deg);
}

[aria-expanded="true"] > .dashboard-sidebar-arrow {
    transform: rotate(135deg);
}

[dir="rtl"] [aria-expanded="true"] > .dashboard-sidebar-arrow {
    transform: rotate(135deg);
}

.dashboard-sidebar-submenu .dashboard-sidebar-link {
    padding-inline-start: 3rem;
    font-size: .875rem;
}

.dashboard-sidebar-account {
    margin-block-start: .75rem;
    padding-block-start: .5rem;
    border-block-start: 1px solid var(--dash-border);
}

/* Mobile --------------------------------------------------------------------- */

.dashboard-sidebar-toggle {
    display: none;
    width: 100%;
    margin-block-end: 1rem;
    min-height: 2.75rem;
    padding: .8rem 1rem;
    color: var(--dash-text);
    font-weight: 600;
    text-align: start;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
}

.dashboard-sidebar-toggle > span:first-child {
    margin-inline-end: .5rem;
}

@media (max-width: 991.98px) {
    .dashboard-sidebar-toggle {
        display: block;
    }

    /* Collapsed by default on small screens, opened by the labelled button above
       it — never an unexplained strip of icons. */
    .dashboard-sidebar[hidden] {
        display: none;
    }

    .dashboard-sidebar-card {
        position: static;
    }
}

/* Dark mode ------------------------------------------------------------------ */

/* site.js sets both signals from one stored preference; matching both keeps this
   sheet working next to the Bootstrap-themed and the class-themed stylesheets. */
[data-bs-theme="dark"],
[data-bs-theme="dark"] .dashboard-shell,
.dark-mode,
.dark-mode .dashboard-shell {
    --dash-surface: #112a37;
    --dash-surface-2: #143240;
    --dash-border: #284754;
    --dash-text: #eaf4fb;
    --dash-text-muted: #9db5c6;
    /* Light-on-dark wants the lighter tint of the same hue. */
    --dash-accent: #7fd4bd;
    --dash-accent-soft: rgba(127, 212, 189, .12);
    --dash-page-bg: #0b2029;
    --dash-banner-bg:
        radial-gradient(circle at 5% 30%, rgba(8, 118, 93, .2), transparent 10rem),
        radial-gradient(circle at 92% 20%, rgba(74, 160, 216, .16), transparent 13rem),
        #0e2733;
    --dash-shadow: 0 .75rem 2rem rgba(0, 0, 0, .45);
}

[data-bs-theme="dark"] .dashboard-sidebar-avatar,
.dark-mode .dashboard-sidebar-avatar {
    /* White on the pale accent measures 2.7:1, so the initial goes dark instead. */
    color: #10141c;
}

[data-bs-theme="dark"] .dashboard-sidebar-badge,
.dark-mode .dashboard-sidebar-badge {
    color: #10141c;
}

/* Reduced motion ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .dashboard-sidebar-arrow {
        transition: none;
    }
}
