/* ============================================================
   Components — Cards, Tables, Dropdowns, Breadcrumbs, Alerts,
   Badges, Modals, Tooltips, Avatars, Icon Boxes, Progress Bars
   ============================================================ */


/* ── Cards ────────────────────────────────────────────────── */
.card {
    --bs-card-spacer-y: 1.3125rem;
    --bs-card-spacer-x: 1.3125rem;
    --bs-card-title-spacer-y: 0.25rem;
    --bs-card-border-width: 0.0625rem;
    --bs-card-border-color: var(--border-light);
    --bs-card-border-radius: 0.75rem;
    --bs-card-box-shadow: 0rem 0.375rem 0.75rem rgba(140, 152, 164, 0.075);
    --bs-card-inner-border-radius: 0.6875rem;
    --bs-card-cap-padding-y: 1.3125rem;
    --bs-card-cap-padding-x: 1.3125rem;
    --bs-card-cap-bg: transparent;
    --bs-card-bg: #fff;
    --bs-card-img-overlay-padding: 1.3125rem 1.3125rem;
    --bs-card-group-margin: 0.75rem;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: var(--bs-card-height);
    word-wrap: break-word;
    background-color: var(--bs-card-bg);
    background-clip: border-box;
    border: var(--bs-card-border-width) solid var(--bs-card-border-color);
    border-radius: var(--bs-card-border-radius);
    transition:
        box-shadow var(--dur-normal) var(--ease-out-expo),
        transform var(--dur-normal) var(--ease-out-expo);
}

.card:hover { box-shadow: var(--shadow-lg); }

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

.card-body   { padding: var(--bs-card-spacer-y) var(--bs-card-spacer-x); flex: 1 1 auto; }
.card-header { padding: var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x); background-color: var(--bs-card-cap-bg); border-bottom: var(--bs-card-border-width) solid var(--bs-card-border-color); }
.card-footer { padding: var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x); background-color: var(--bs-card-cap-bg); border-top: var(--bs-card-border-width) solid var(--bs-card-border-color); }

/* No `backdrop-filter` / `transform` / `filter` here. `.card-flush` wraps every
   data table on the platform; any of those properties would make it the
   containing block for `position: fixed` descendants, breaking the
   `.dropdown-action-btn` row menus positioned by
   [static/core/js/table-dropdown.js](static/core/js/table-dropdown.js). The blur
   was visually inert anyway over the flat gray page backgrounds. */
.card-flush {
    border: 1px solid rgba(0, 0, 0, 0.03);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
    border-radius: 0.875rem;
    overflow: visible;
    background: #fff;
}

.card-stat-glass {
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 0.875rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* ── Stat Card (modern) ──────────────────────────────────── */
.card-stat {
    background: #fff;
    border-radius: 0.875rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: box-shadow var(--dur-normal) var(--ease-out-expo),
                transform var(--dur-normal) var(--ease-out-expo);
}

.card-stat:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.stat-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 0.75rem;
    flex-shrink: 0;
    font-size: 1.15rem;
}

.stat-icon-box.text-primary   { background: var(--soft-primary-bg);   }
.stat-icon-box.text-success   { background: var(--soft-success-bg);   }
.stat-icon-box.text-danger    { background: var(--soft-danger-bg);    }
.stat-icon-box.text-warning   { background: var(--soft-warning-bg);   }
.stat-icon-box.text-info      { background: var(--soft-info-bg);      }
.stat-icon-box.text-secondary { background: var(--soft-secondary-bg); }

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--bs-heading-color, #1e2022);
    letter-spacing: -0.02em;
}

.stat-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-sub, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.125rem;
}

.card-section-header {
    background-color: var(--bs-card-bg, #fff);
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--bs-gray-300);
}

.card-section-footer {
    background-color: var(--bs-card-bg, #fff);
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--bs-gray-300);
}

.gradient-top-bar {
    height: 4px;
    background: linear-gradient(135deg, var(--bs-primary), #3AA0C6);
}


/* ── Tables ───────────────────────────────────────────────── */
.table {
    --bs-table-color: var(--bs-body-color);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border-light);
    --bs-table-accent-bg: transparent;
    --bs-table-striped-color: var(--bs-body-color);
    --bs-table-striped-bg: var(--bs-gray-100);
    --bs-table-active-color: var(--bs-body-color);
    --bs-table-active-bg: rgba(0, 0, 0, 0.1);
    --bs-table-hover-color: var(--bs-body-color);
    --bs-table-hover-bg: rgba(231, 234, 243, 0.4);
    width: 100%;
    margin-bottom: 1rem;
    color: var(--bs-table-color);
    vertical-align: top;
    border-color: var(--bs-table-border-color);
}

.table > :not(caption) > * > * {
    padding: 0.75rem;
    background-color: var(--bs-table-bg);
    border-bottom-width: 0.0625rem;
    box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg);
    transition: background-color var(--dur-fast) ease;
}

.table > tbody { vertical-align: inherit; }
.table > thead { vertical-align: bottom; }
.table img     { max-width: 50px; max-height: 50px; object-fit: cover; }
.table .badge  { margin-right: 5px; }

.table-head-light th {
    background: var(--bs-gray-100);
    color: var(--text-sub);
    font-size: 0.75rem;
    font-weight: 600;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    white-space: nowrap;
}

.table-head-uppercase th {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--bs-gray-300);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.table-cell-border td {
    border-bottom: 1px solid var(--bs-gray-300);
}

.table-responsive-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.08) transparent;
}
.table-responsive-wrapper::-webkit-scrollbar {
    height: 5px;
    background: transparent;
}
.table-responsive-wrapper::-webkit-scrollbar-track {
    background: rgba(0,0,0,.02);
    border-radius: 100px;
    margin: 0 16px;
}
.table-responsive-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.08);
    border-radius: 100px;
}
.table-responsive-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,.14);
}
.table-responsive-wrapper::-webkit-scrollbar-thumb:active {
    background: rgba(0,0,0,.14);
}
.table-responsive-wrapper > .table {
    background: var(--bs-body-bg, #fff);
    margin-bottom: 0;
}


/* ── Dropdowns ────────────────────────────────────────────── */
.dropdown-toggle::after { border: none; }
.btn-reveal.dropdown-toggle::after { display: none !important; }

.btn-reveal.dropdown-toggle:active:focus,
.btn-reveal.dropdown-toggle:active,
.btn-reveal.dropdown-toggle:focus {
    box-shadow: var(--shadow-dropdown);
}

.dropdown-menu {
    --bs-dropdown-zindex: 1000;
    --bs-dropdown-min-width: 10rem;
    --bs-dropdown-padding-x: 0.5rem;
    --bs-dropdown-padding-y: 0.5rem;
    --bs-dropdown-spacer: 0.625rem;
    --bs-dropdown-font-size: 0.875rem;
    --bs-dropdown-color: #677788;
    --bs-dropdown-bg: #fff;
    --bs-dropdown-border-color: var(--bs-border-color-translucent);
    --bs-dropdown-border-radius: 0.5rem;
    --bs-dropdown-border-width: 0;
    --bs-dropdown-inner-border-radius: 0.5rem;
    --bs-dropdown-divider-bg: var(--border-light);
    --bs-dropdown-divider-margin-y: 0.5rem;
    --bs-dropdown-box-shadow: 0rem 0.6125rem 2.5rem 0.6125rem rgba(140, 152, 164, 0.175);
    --bs-dropdown-link-color: var(--bs-gray-900);
    --bs-dropdown-link-hover-color: #1b1d1f;
    --bs-dropdown-link-hover-bg: rgba(189, 197, 209, 0.2);
    --bs-dropdown-link-active-color: var(--bs-gray-900);
    --bs-dropdown-link-active-bg: rgba(189, 197, 209, 0.2);
    --bs-dropdown-link-disabled-color: #97a4af;
    --bs-dropdown-item-padding-x: 1rem;
    --bs-dropdown-item-padding-y: 0.5rem;
    --bs-dropdown-header-color: var(--bs-gray);
    --bs-dropdown-header-padding-x: 1rem;
    --bs-dropdown-header-padding-y: 0.5rem;
    box-shadow: var(--shadow-dropdown);
    margin-top: 0.3125rem;
    animation: dropdownEnter var(--dur-fast) var(--ease-out-expo);
}

@keyframes dropdownEnter {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
    transition:
        background-color var(--dur-instant) ease,
        color var(--dur-instant) ease;
    border-radius: var(--bs-border-radius-sm);
}

.navbar-nav .dropdown-menu { position: absolute; }

.dropdown-header {
    letter-spacing: 0.08rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 300;
    color: var(--bs-dark) !important;
}

/* ── Table row member-cell link ─────────────────────────────────
   Wraps avatar + name + email in the first column so the whole cell
   navigates to the row's primary edit page. Stays neutral until
   hovered, then promotes the name colour to the brand. */
.member-cell-link { color: inherit; }
.member-cell-link:hover .member-cell-name,
.member-cell-link:focus-visible .member-cell-name { color: var(--bs-primary); }
.member-cell-link:focus-visible {
    outline: 2px solid var(--soft-primary-bg, rgba(99, 102, 241, .25));
    outline-offset: 2px;
    border-radius: 0.5rem;
}

/* Defensive guard: the row dropdown menu uses `position: fixed` with
   viewport-relative coordinates (see [static/core/js/table-dropdown.js](static/core/js/table-dropdown.js)).
   Any ancestor with `transform`, `filter`, `backdrop-filter`, `perspective`,
   `will-change` of those, or `contain: layout/paint/strict/content` becomes
   the containing block for the menu, and it lands far below the trigger.
   We forcibly neutralize those properties on the table card ancestors so
   adding visual effects (frosted glass, hover lift, etc.) to a parent
   doesn't silently break every row dropdown across the app. */
.card.card-flush,
.table-responsive-wrapper {
    transform: none !important;
    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    perspective: none !important;
}

/* ── Table row action dropdown ─────────────────────────────────
   Used by every list view (clinics, EHR clinics, locations, …) for
   per-row "View / Edit / Delete"-style menus. The trigger is a 32px
   circle that sits quietly in the row until hovered; the menu opens
   as a soft floating card with a subtle entrance, refined item
   spacing, and a danger variant for destructive actions. */
.dropdown-action-btn {
    background: transparent;
    color: var(--text-sub, #6b7280);
    border: none;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: .95rem;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    transition:
        background-color 160ms cubic-bezier(.4, 0, .2, 1),
        color 160ms cubic-bezier(.4, 0, .2, 1);
}
.dropdown-action-btn > i {
    transition: transform 220ms cubic-bezier(.4, 0, .2, 1);
}
.dropdown-action-btn:hover,
.dropdown-action-btn:focus-visible {
    background: var(--soft-primary-bg);
    color: var(--bs-primary);
    box-shadow: none;
    outline: none;
}
.dropdown-action-btn:focus { box-shadow: none; outline: none; }
.dropdown-action-btn.show {
    background: var(--soft-primary-bg);
    color: var(--bs-primary);
    box-shadow: none;
}
.dropdown-action-btn.show > i { transform: rotate(90deg); }
.dropdown-action-btn::after { display: none; }

.dropdown-action-btn + .dropdown-menu {
    --bs-dropdown-zindex: 1080;
    --bs-dropdown-min-width: 10.5rem;
    --bs-dropdown-padding-x: 0.375rem;
    --bs-dropdown-padding-y: 0.375rem;
    --bs-dropdown-item-padding-x: 0.75rem;
    --bs-dropdown-item-padding-y: 0.5rem;
    --bs-dropdown-font-size: 0.8125rem;
    --bs-dropdown-border-radius: 0.75rem;
    --bs-dropdown-border-color: rgba(15, 23, 42, 0.06);
    margin-top: 0.375rem;
    border: 1px solid rgba(15, 23, 42, 0.05);
    border-radius: 0.75rem;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 8px 24px -4px rgba(15, 23, 42, 0.10),
        0 16px 40px -8px rgba(15, 23, 42, 0.08);
    z-index: 1080;
    overflow: hidden;
    transform-origin: top right;
    animation: dropdownActionMenuFade 160ms cubic-bezier(.16, 1, .3, 1) both !important;
}
@keyframes dropdownActionMenuFade {
    from { opacity: 0; transform: translateY(-6px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-action-btn + .dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.25;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0;
    color: var(--bs-body-color);
    white-space: nowrap;
    transition:
        background-color 140ms cubic-bezier(.4, 0, .2, 1),
        color 140ms cubic-bezier(.4, 0, .2, 1);
}
.dropdown-action-btn + .dropdown-menu .dropdown-item + .dropdown-item { margin-top: 1px; }
.dropdown-action-btn + .dropdown-menu .dropdown-item i {
    flex: 0 0 1rem;
    width: 1rem;
    margin-right: 0.625rem;
    font-size: 0.875rem;
    text-align: center;
    color: var(--text-sub);
    transition: color 140ms cubic-bezier(.4, 0, .2, 1);
}
.dropdown-action-btn + .dropdown-menu .dropdown-item:hover,
.dropdown-action-btn + .dropdown-menu .dropdown-item:focus {
    background: var(--soft-primary-bg);
    color: var(--bs-primary);
    outline: none;
}
.dropdown-action-btn + .dropdown-menu .dropdown-item:hover i,
.dropdown-action-btn + .dropdown-menu .dropdown-item:focus i {
    color: var(--bs-primary);
}
.dropdown-action-btn + .dropdown-menu .dropdown-item:active,
.dropdown-action-btn + .dropdown-menu .dropdown-item.active {
    background: var(--soft-primary-bg-hover);
    color: var(--bs-primary);
}

.dropdown-action-btn + .dropdown-menu .dropdown-divider {
    margin: 0.375rem -0.375rem;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    opacity: 1;
}

/* Danger variant — used for destructive items like "Delete". */
.dropdown-action-danger { color: var(--color-danger, var(--bs-danger)); }
.dropdown-action-danger i { color: var(--color-danger, var(--bs-danger)); }
.dropdown-action-btn + .dropdown-menu .dropdown-item.dropdown-action-danger:hover,
.dropdown-action-btn + .dropdown-menu .dropdown-item.dropdown-action-danger:focus {
    background: var(--soft-danger-bg);
    color: var(--color-danger, var(--bs-danger));
}
.dropdown-action-btn + .dropdown-menu .dropdown-item.dropdown-action-danger:hover i,
.dropdown-action-btn + .dropdown-menu .dropdown-item.dropdown-action-danger:focus i {
    color: var(--color-danger, var(--bs-danger));
}
.dropdown-action-btn + .dropdown-menu .dropdown-item.dropdown-action-danger:active,
.dropdown-action-btn + .dropdown-menu .dropdown-item.dropdown-action-danger.active {
    background: var(--soft-danger-bg-hover);
    color: var(--color-danger, var(--bs-danger));
}

@media (prefers-reduced-motion: reduce) {
    .dropdown-action-btn,
    .dropdown-action-btn > i,
    .dropdown-action-btn + .dropdown-menu,
    .dropdown-action-btn + .dropdown-menu .dropdown-item,
    .dropdown-action-btn + .dropdown-menu .dropdown-item i {
        transition: none !important;
        animation: none !important;
    }
    .dropdown-action-btn.show > i { transform: none !important; }
}


/* ── Breadcrumbs ──────────────────────────────────────────── */
.breadcrumb {
    --bs-breadcrumb-padding-x: 0;
    --bs-breadcrumb-padding-y: 0;
    --bs-breadcrumb-margin-bottom: 0;
    --bs-breadcrumb-item-padding-x: 0.375rem;
    --bs-breadcrumb-item-active-color: var(--bs-body-color);
    display: flex;
    flex-wrap: wrap;
}

.breadcrumb .breadcrumb-link {
    color: var(--text-sub);
    text-decoration: none;
    font-size: 0.8rem !important;
    transition: color var(--dur-fast) var(--ease-out-expo);
}

.breadcrumb .breadcrumb-link:hover { color: var(--bs-primary); }


/* ── Alerts & Messages ────────────────────────────────────── */
.alert {
    border-radius: var(--auth-radius);
    border-left-width: 4px;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
    animation: alert-enter var(--auth-dur-slow) var(--auth-ease-out);
}

.alert-danger  { background: rgba(var(--bs-danger-rgb), 0.08) !important;  border-color: rgba(var(--bs-danger-rgb), 0.25) !important;  color: var(--bs-danger) !important; }
.alert-success { background: rgba(var(--bs-success-rgb), 0.08) !important; border-color: rgba(var(--bs-success-rgb), 0.25) !important; color: var(--bs-success) !important; }
.alert-warning { background: rgba(var(--bs-warning-rgb), 0.08) !important; border-color: rgba(var(--bs-warning-rgb), 0.25) !important; color: var(--color-warning) !important; }
.alert-info    { background: rgba(var(--bs-info-rgb), 0.08) !important;    border-color: rgba(var(--bs-info-rgb), 0.25) !important;    color: var(--bs-info) !important; }

.alert .btn-close       { opacity: 0.4; }
.alert .btn-close:hover { opacity: 0.7; }


/* ── Badges & Soft Backgrounds ────────────────────────────── */
.bg-soft-primary   { background-color: rgba(0, 105, 166, 0.1) !important; }
.bg-soft-secondary { background-color: var(--soft-secondary-bg) !important; }
.bg-soft-success   { background-color: var(--soft-success-bg) !important; }
.bg-soft-info      { background-color: var(--soft-info-bg) !important; }
.bg-soft-warning   { background-color: var(--soft-warning-bg) !important; }
.bg-soft-danger    { background-color: var(--soft-danger-bg) !important; }
.bg-soft-light     { background-color: rgba(249, 250, 252, 0.1) !important; }
.bg-soft-dark      { background-color: rgba(19, 33, 68, 0.1) !important; }

.badge-soft-primary,
.badge-soft-success,
.badge-soft-info,
.badge-soft-warning,
.badge-soft-danger,
.badge-soft-secondary { font-weight: 500; }

.badge-soft-primary   { background: var(--soft-primary-bg);   color: var(--bs-primary); }
.badge-soft-success   { background: var(--soft-success-bg);   color: var(--bs-success); }
.badge-soft-info      { background: var(--soft-info-bg);      color: var(--bs-info); }
.badge-soft-warning   { background: var(--soft-warning-bg);   color: var(--color-warning); }
.badge-soft-danger    { background: var(--soft-danger-bg);    color: var(--bs-danger); }
.badge-soft-secondary { background: var(--soft-secondary-bg); color: var(--text-sub); }

.badge-feature    { font-size: 0.625rem; }
.badge-feature-lg { font-size: 0.75rem; font-weight: 500; padding: 0.35em 0.7em; border-radius: 4px; }

.badge-code {
    font-size: 0.75rem;
    background: var(--soft-primary-bg);
    color: var(--bs-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--bs-font-monospace);
}


/* ── Avatars ──────────────────────────────────────────────── */
.avatar {
    display: inline-block;
    position: relative;
    overflow: hidden;
    transition: transform var(--dur-normal) var(--ease-out-expo);
}

.avatar-2  { width: 2rem;   height: 2rem; }
.avatar-sm { width: 2.7rem; height: 2.7rem; }
.avatar-md { width: 3.5rem; height: 3.5rem; }
.avatar-lg { width: 6.5rem; height: 6.5rem; }
.avatar-xl { width: 8rem;   height: 8rem; }
.avatar-10 { width: 10rem;  height: 10rem; }
.avatar-15 { width: 15rem;  height: 15rem; }

.avatar-circle { border-radius: 50%; }

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.avatar-dark {
    background-color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-initials {
    font-size: 1.25rem;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
}

.avatar:hover { transform: scale(1.05); }

.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 600;
    flex-shrink: 0;
}

.avatar-placeholder-primary {
    color: var(--bs-primary);
    background: var(--soft-primary-bg);
}

.avatar-placeholder-gradient {
    background: var(--gradient-primary);
    color: #fff;
}


/* ── Icon Boxes ───────────────────────────────────────────── */
.icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--bs-border-radius-lg);
    flex-shrink: 0;
}

.icon-box-48 { width: 48px; height: 48px; }
.icon-box-44 { width: 44px; height: 44px; }
.icon-box-36 { width: 36px; height: 36px; }
.icon-box-32 { width: 32px; height: 32px; }
.icon-box-64 { width: 64px; height: 64px; }
.icon-box-72 { width: 72px; height: 72px; }
.icon-box-88 { width: 88px; height: 88px; }
.icon-box-circle { border-radius: 50%; }

.icon-box-primary   { background: var(--soft-primary-bg);   color: var(--bs-primary); }
.icon-box-success   { background: var(--soft-success-bg);   color: var(--bs-success); }
.icon-box-info      { background: var(--soft-info-bg);      color: var(--bs-info); }
.icon-box-warning   { background: var(--soft-warning-bg);   color: var(--color-warning); }
.icon-box-danger    { background: var(--soft-danger-bg);    color: var(--bs-danger); }
.icon-box-secondary { background: var(--soft-secondary-bg); color: var(--text-sub); }
.icon-box-success-strong { background: var(--soft-success-bg-hover); color: var(--bs-success); }


/* ── Empty State ──────────────────────────────────────────── */
.empty-state-cell { text-align: center; padding: 2.5rem 1rem; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 30rem;
    margin: 0 auto;
}

.empty-state-block { padding: 3rem 1.5rem; }

.empty-state-card {
    padding: 3.25rem 1.75rem 2.75rem;
    max-width: none;
    width: 100%;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfd 100%);
    border: 1px solid var(--bs-gray-200);
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 28px -18px rgba(15, 23, 42, 0.10);
    position: relative;
    overflow: hidden;
}

.empty-state-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 140px;
    background:
        radial-gradient(60% 100% at 50% 0%, rgba(var(--bs-primary-rgb), 0.07), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.empty-state-card > * { position: relative; z-index: 1; }

.empty-state-icon {
    width: 84px;
    height: 84px;
    border-radius: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb), 0.14) 0%, rgba(var(--bs-primary-rgb), 0.04) 100%);
    color: var(--bs-primary);
    margin-bottom: 1.25rem;
    position: relative;
    box-shadow:
        inset 0 0 0 1px rgba(var(--bs-primary-rgb), 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.65),
        0 8px 20px -10px rgba(var(--bs-primary-rgb), 0.30);
}

.empty-state-icon::before {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 28px;
    background: radial-gradient(circle at 50% 40%, rgba(var(--bs-primary-rgb), 0.10), transparent 70%);
    z-index: -1;
}

.empty-state-icon i {
    font-size: 2.1rem;
    line-height: 1;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--bs-gray-800);
    margin: 0 0 0.4rem;
    letter-spacing: -0.015em;
}

.empty-state-message {
    font-size: 0.875rem;
    color: var(--bs-gray-600);
    margin: 0 0 1.5rem;
    line-height: 1.55;
    max-width: 26rem;
}

.empty-state-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0;
}

.empty-state-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5625rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 10px;
    line-height: 1.2;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn.empty-state-action {
    box-shadow: 0 1px 2px rgba(var(--bs-primary-rgb), 0.16), 0 6px 14px -4px rgba(var(--bs-primary-rgb), 0.28);
}

.btn.empty-state-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(var(--bs-primary-rgb), 0.20), 0 10px 20px -6px rgba(var(--bs-primary-rgb), 0.32);
}

.empty-state-action--ghost {
    background: #fff;
    border: 1px solid var(--bs-gray-300);
    color: var(--bs-gray-700);
}

.empty-state-action--ghost:hover {
    transform: translateY(-1px);
    border-color: var(--bs-gray-400);
    box-shadow: 0 4px 10px -6px rgba(15, 23, 42, 0.15);
    color: var(--bs-gray-800);
}

.empty-state-action i { font-size: 0.95rem; }

.empty-state-hint {
    margin: 1rem 0 0;
    font-size: 0.75rem;
    color: var(--bs-gray-500);
    letter-spacing: 0.01em;
}

.empty-state-chips {
    list-style: none;
    padding: 0;
    margin: 0 auto 1.25rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    max-width: 32rem;
}

.empty-state-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.7rem 0.25rem 0.3rem;
    border-radius: 100px;
    background: #f8fafc;
    border: 1px solid var(--bs-gray-200);
    font-size: 0.75rem;
    color: var(--bs-gray-800);
}

.empty-state-chip-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(var(--bs-primary-rgb), 0.10);
    color: var(--bs-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    line-height: 1;
    flex-shrink: 0;
}

.empty-state-chip-name {
    font-weight: 600;
    color: var(--bs-gray-800);
}

.empty-state-chip-meta {
    color: var(--bs-gray-600);
    font-size: 0.7rem;
    font-weight: 500;
}

.empty-state-chip--more {
    padding: 0.3rem 0.75rem;
    border-style: dashed;
    color: var(--bs-gray-600);
    background: transparent;
    font-weight: 500;
}


/* ── Progress Bars ────────────────────────────────────────── */
.progress-thin {
    height: 6px;
    border-radius: 3px;
    background: var(--bs-gray-300);
}

.progress-thin .progress-bar { border-radius: 3px; }

.progress-bar-thin {
    height: 6px;
    border-radius: 3px;
}

.progress-height-8 { height: 8px; }


/* ── Modals ───────────────────────────────────────────────── */
.modal.fade .modal-dialog {
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    transition:
        transform var(--dur-normal) var(--ease-out-expo),
        opacity var(--dur-normal) var(--ease-out-expo);
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-content {
    border: none;
    border-radius: var(--bs-border-radius-xl);
    box-shadow: var(--shadow-2xl);
    overflow: hidden;
}

.modal-header { border-bottom: 1px solid var(--bs-border-color); padding: 1.25rem 1.5rem; }
.modal-footer { border-top: 1px solid var(--bs-border-color); padding: 1rem 1.5rem; }
.modal-body   { padding: 1.5rem; }

.modal-backdrop.show {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}


/* ── Tooltips ─────────────────────────────────────────────── */
.tooltip {
    --bs-tooltip-bg: var(--bs-dark);
    --bs-tooltip-color: #fff;
    --bs-tooltip-padding-x: 0.75rem;
    --bs-tooltip-padding-y: 0.375rem;
    --bs-tooltip-font-size: 0.8125rem;
    --bs-tooltip-border-radius: 0.5rem;
    font-weight: 450;
    letter-spacing: 0.005em;
}

.tooltip .tooltip-inner { box-shadow: var(--shadow-lg); }


/* ── Glassmorphism ────────────────────────────────────────── */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    border: 1px solid var(--glass-border);
}

.glass-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--shadow-md);
    transition:
        box-shadow var(--dur-normal) var(--ease-out-expo),
        transform var(--dur-normal) var(--ease-out-expo);
}

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

.glass-navbar {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(200%);
    -webkit-backdrop-filter: blur(20px) saturate(200%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}


/* ── Notification Badges ──────────────────────────────────── */
.notification-badge {
    position: relative;
    display: inline-flex;
}

.notification-badge .badge-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bs-danger);
    border: 2px solid #fff;
    z-index: 1;
}

.notification-badge .badge-count {
    position: absolute;
    top: -6px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border: 2px solid #fff;
    z-index: 1;
    animation: badge-pop var(--dur-normal) var(--ease-spring);
}

.pulse-indicator {
    position: relative;
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bs-success);
}

.pulse-indicator::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: var(--bs-success);
    opacity: 0;
    animation: pulse-ring 2s ease-out infinite;
}

.pulse-indicator-danger { background: var(--bs-danger); }
.pulse-indicator-danger::before { background: var(--bs-danger); }
.pulse-indicator-warning { background: var(--bs-warning); }
.pulse-indicator-warning::before { background: var(--bs-warning); }
.pulse-indicator-info { background: var(--bs-info); }
.pulse-indicator-info::before { background: var(--bs-info); }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.375rem;
    flex-shrink: 0;
}

.status-dot-success { background: var(--bs-success); }
.status-dot-danger  { background: var(--bs-danger); }
.status-dot-warning { background: var(--bs-warning); }
.status-dot-info    { background: var(--bs-info); }
.status-dot-primary { background: var(--bs-primary); }
.status-dot-muted   { background: var(--bs-gray-400); }


/* ── Feature Cards ────────────────────────────────────────── */
.feature-card { height: 225px; }

.feature-card .card-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feature-card .card-title {
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Clinic Switcher (CRM list-page header pill) ───────────── */
#clinic-switcher-select {
    min-width: 240px;
    max-width: 320px;
    padding: 0.4rem 2.4rem 0.4rem 0.95rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bs-body-color);
    background-color: #fff;
    border: 1px solid var(--bs-border-color, #e5e7eb);
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236b7280'%3E%3Cpath d='M3.204 5h9.592L8 10.481 3.204 5zm-.753.659l4.796 5.48a1 1 0 0 0 1.506 0l4.796-5.48c.566-.647.106-1.659-.753-1.659H3.204a1 1 0 0 0-.753 1.659z'/%3E%3C/svg%3E");
    background-position: right 0.95rem center;
    background-size: 12px 12px;
    text-overflow: ellipsis;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

#clinic-switcher-select:hover:not(:disabled) {
    border-color: var(--bs-primary, #6366f1);
    background-color: #fafbff;
}

#clinic-switcher-select:focus,
#clinic-switcher-select:focus-visible {
    border-color: var(--bs-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    outline: none;
}

#clinic-switcher-select:disabled {
    background-color: #f9fafb;
    color: var(--bs-secondary-color, #6b7280);
    cursor: not-allowed;
    opacity: 0.85;
}

#clinic-switcher-select option {
    font-weight: 500;
    padding: 0.4rem 0.6rem;
}


/* ── Toast Stack ─────────────────────────────────────────────
   Fixed bottom-right notification stack. Replaces inline Django
   messages alerts. Slides in from right, auto-dismisses with a
   progress bar, pauses on hover. */
.toast-stack {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast-stack .toast-item,
.toast-item {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background-color: #ffffff !important;
    background-image: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    opacity: 1 !important;
    isolation: isolate;
    border: 1px solid #e2e8f0;
    border-left: 3px solid var(--toast-accent, #6366f1);
    border-radius: 12px;
    box-shadow: 0 18px 38px -14px rgba(15, 23, 42, 0.22), 0 6px 14px -6px rgba(15, 23, 42, 0.14);
    color: #0f172a;
    font-size: 0.875rem;
    line-height: 1.4;
    pointer-events: auto;
    overflow: hidden;
    animation: toast-in 320ms var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.toast-item.is-leaving {
    animation: toast-out 240ms var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1)) forwards;
}

.toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--toast-icon-bg, rgba(99, 102, 241, 0.12));
    color: var(--toast-accent, #6366f1);
    font-size: 1rem;
    flex-shrink: 0;
}

.toast-body {
    min-width: 0;
    color: var(--text-primary, #111827);
    font-weight: 500;
    word-wrap: break-word;
}

.toast-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted, #6b7280);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}
.toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary, #111827);
}
.toast-close:focus-visible {
    outline: 2px solid var(--toast-accent, #6366f1);
    outline-offset: 1px;
}

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: var(--toast-accent, #6366f1);
    opacity: 0.55;
    transform-origin: left center;
    animation: toast-progress linear forwards;
    animation-play-state: paused;
}

.toast-success {
    --toast-accent: #10b981;
    --toast-icon-bg: rgba(16, 185, 129, 0.12);
}
.toast-info {
    --toast-accent: #0ea5e9;
    --toast-icon-bg: rgba(14, 165, 233, 0.12);
}
.toast-warning {
    --toast-accent: #f59e0b;
    --toast-icon-bg: rgba(245, 158, 11, 0.15);
}
.toast-danger {
    --toast-accent: #ef4444;
    --toast-icon-bg: rgba(239, 68, 68, 0.12);
}
.toast-debug {
    --toast-accent: #6b7280;
    --toast-icon-bg: rgba(107, 114, 128, 0.12);
}

@keyframes toast-in {
    from { opacity: 0; transform: translate3d(24px, 8px, 0) scale(0.96); }
    to   { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translate3d(0, 0, 0) scale(1); max-height: 200px; margin-bottom: 0.625rem; padding-top: 0.875rem; padding-bottom: 0.875rem; }
    to   { opacity: 0; transform: translate3d(28px, 0, 0) scale(0.96); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
}
@keyframes toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* Dark mode */
body.dark-mode .toast-stack .toast-item,
body.dark-mode .toast-item,
[data-theme="dark"] .toast-stack .toast-item,
[data-theme="dark"] .toast-item {
    background-color: #222633 !important;
    background-image: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-color: #2c3142;
    border-left-color: var(--toast-accent, #6366f1);
    color: #f0f2f5;
    box-shadow: 0 18px 38px -12px rgba(0, 0, 0, 0.6), 0 6px 14px -6px rgba(0, 0, 0, 0.4);
}
body.dark-mode .toast-body,
[data-theme="dark"] .toast-body {
    color: var(--dark-text-primary, #f0f2f5);
}
body.dark-mode .toast-close,
[data-theme="dark"] .toast-close {
    color: var(--dark-text-secondary, #9ba3b5);
}
body.dark-mode .toast-close:hover,
[data-theme="dark"] .toast-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--dark-text-primary, #f0f2f5);
}

/* Mobile: full-width across bottom, slimmer padding */
@media (max-width: 575.98px) {
    .toast-stack {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast-item,
    .toast-item.is-leaving,
    .toast-progress {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* ── Provider form: location multi-select rows ────────────── */
.location-row {
    cursor: pointer;
    background: #fff;
    border-color: var(--bs-gray-300, #e5e7eb) !important;
    transition: background-color var(--dur-fast, 120ms) ease,
                border-color var(--dur-fast, 120ms) ease,
                box-shadow var(--dur-fast, 120ms) ease;
}

.location-row:hover {
    background: var(--bs-gray-100, #f8fafc);
    border-color: var(--bs-primary, #3AA0C6) !important;
}

.location-row:has(.location-row__checkbox:checked) {
    background: var(--soft-primary-bg, rgba(58, 160, 198, 0.08));
    border-color: var(--bs-primary, #3AA0C6) !important;
    box-shadow: 0 0 0 1px var(--bs-primary, #3AA0C6) inset;
}

.location-row__checkbox {
    flex-shrink: 0;
}

.location-pin {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--soft-primary-bg, rgba(58, 160, 198, 0.12));
    color: var(--bs-primary, #3AA0C6);
    font-size: 0.95rem;
}

.location-row:has(.location-row__checkbox:checked) .location-pin {
    background: var(--bs-primary, #3AA0C6);
    color: #fff;
}

.provider-form-wrap {
    width: 100%;
    max-width: none;
}

.provider-color-swatch {
    height: calc(1.5em + 0.5rem + 2px);
    padding: 0.125rem;
}

.text-teal {
    color: #0d9488;
}
