:root {
    --app-primary: #4f8ff7;
    --app-primary-soft: #eaf1fe;
    --app-sidebar-bg: #ffffff;
    --app-body-bg: #f5f7fb;
    --app-border: #e9ecf2;
    --app-text-muted: #7c8598;
}

body {
    background-color: var(--app-body-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.9rem;
    color: #1f2430;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    width: 250px;
    min-height: 100vh;
    background: var(--app-sidebar-bg);
    border-right: 1px solid var(--app-border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1030;
}

.app-sidebar .brand {
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #1f2430;
    text-decoration: none;
}

.app-sidebar .brand img {
    height: 28px;
    width: 28px;
    object-fit: contain;
    border-radius: 6px;
}

.app-sidebar .nav-link {
    color: #4b5265;
    padding: 0.55rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.88rem;
    border-radius: 0;
}

.app-sidebar .nav-link i {
    font-size: 1rem;
    width: 1.1rem;
    text-align: center;
    color: var(--app-text-muted);
}

.app-sidebar .nav-link:hover {
    background: var(--app-primary-soft);
    color: var(--app-primary);
}

.app-sidebar .nav-link:hover i {
    color: var(--app-primary);
}

.app-sidebar .nav-link.active {
    background: var(--app-primary-soft);
    color: var(--app-primary);
    font-weight: 600;
    border-right: 3px solid var(--app-primary);
}

.app-sidebar .nav-link.active i {
    color: var(--app-primary);
}

.app-sidebar .nav-section-label {
    padding: 1rem 1.25rem 0.35rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #a5abba;
    font-weight: 700;
}

/* ---------- Main area ---------- */
.app-main {
    margin-left: 250px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.clinic-chip {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: var(--app-primary-soft);
    border: 1px solid rgba(79, 143, 247, 0.25);
    color: #1f2430;
    text-decoration: none;
    cursor: pointer;
    min-width: 0;
}

.clinic-chip:hover,
.clinic-chip:focus {
    border-color: var(--app-primary);
    color: #1f2430;
}

.clinic-chip.static {
    cursor: default;
}

.clinic-chip .clinic-chip-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    color: var(--app-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.clinic-chip .clinic-chip-label {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.clinic-chip .clinic-chip-name {
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(38vw, 420px);
}

.clinic-chip .clinic-chip-meta {
    font-size: 0.68rem;
    color: var(--app-text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.clinic-chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.clinic-chip-dot.dot-success { background: #22c55e; }
.clinic-chip-dot.dot-warning { background: #f59e0b; }
.clinic-chip-dot.dot-danger { background: #ef4444; }
.clinic-chip-dot.dot-muted { background: #9aa4b2; }

.clinic-chip .bi-chevron-down {
    font-size: 0.7rem;
    color: var(--app-text-muted);
    margin-left: 0.1rem;
}

.clinic-switcher-menu {
    min-width: 260px;
    max-height: 360px;
    overflow-y: auto;
    padding: 0.4rem;
}

.clinic-switcher-menu .dropdown-item {
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.65rem;
}

.clinic-switcher-menu .dropdown-item.active,
.clinic-switcher-menu .dropdown-item:active {
    background: var(--app-primary-soft);
    color: #1f2430;
}

@media (max-width: 576px) {
    .clinic-chip .clinic-chip-name {
        max-width: 45vw;
    }
    .clinic-chip .clinic-chip-meta {
        display: none;
    }
}

.app-topbar > div:first-child {
    min-width: 0;
    overflow: hidden;
}

.app-breadcrumb {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.app-topbar > div:last-child {
    flex-shrink: 0;
}

.app-breadcrumb a {
    color: var(--app-text-muted);
    text-decoration: none;
}

.app-breadcrumb .current {
    color: #1f2430;
    font-weight: 600;
}

.app-content {
    padding: 1.5rem;
    flex: 1;
}

/* ---------- Cards ---------- */
.tile-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 0.75rem;
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s ease, transform .15s ease;
    height: 100%;
}

.tile-card:hover {
    box-shadow: 0 6px 18px rgba(20, 30, 60, .08);
    transform: translateY(-1px);
    color: inherit;
}

.dashboard-stat-card {
    transition: box-shadow .15s ease, transform .15s ease;
}

.dashboard-stat-card:hover {
    box-shadow: 0 6px 18px rgba(20, 30, 60, .08);
    transform: translateY(-1px);
    color: inherit;
}

.tile-icon {
    width: 42px;
    height: 42px;
    border-radius: 0.6rem;
    background: var(--app-primary-soft);
    color: var(--app-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.tile-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: #1f2430;
}

.tile-subtitle {
    font-size: 0.78rem;
    color: var(--app-text-muted);
}

.card {
    border: 1px solid var(--app-border);
    border-radius: 0.75rem;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    font-weight: 600;
}

.btn-primary {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-primary:hover {
    filter: brightness(0.92);
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-outline-primary {
    color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-outline-primary:hover {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

a {
    color: var(--app-primary);
}

.text-primary-app {
    color: var(--app-primary) !important;
}

.badge-soft {
    background: var(--app-primary-soft);
    color: var(--app-primary);
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 0.4rem;
    font-size: 0.72rem;
}

.table > :not(caption) > * > * {
    vertical-align: middle;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #f5f7fb 0%, #eef2fb 100%);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 1rem;
    border: 1px solid var(--app-border);
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(20, 30, 60, .06);
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
    }
}

/* ---------- Package browsing / slot boxes (booking + service log) ---------- */
.package-card {
    background: #f8f9fb;
    border: 1px solid var(--app-border);
    border-radius: .5rem;
    padding: .9rem 1rem;
    cursor: pointer;
    transition: border-color .15s;
}
.package-card:hover { border-color: var(--app-primary); }
.package-card.disabled { cursor: default; opacity: .75; }
.package-status-pill {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    padding: .3rem .6rem;
}
.device-card {
    background: #f8f9fb;
    border: 1px solid var(--app-border);
    border-radius: .5rem;
    padding: .5rem .6rem;
    cursor: pointer;
    text-align: center;
    transition: border-color .15s;
    font-size: .8rem;
}
.device-card i { font-size: 1.15rem !important; }
.device-card img { width: 30px !important; height: 30px !important; }
.device-card:hover { border-color: var(--app-primary); }
.device-card.active { border-color: var(--app-primary); border-width: 2px; background: #eef3ff; }
.device-card.disabled { cursor: default; opacity: .5; pointer-events: none; }
.device-card.disabled:hover { border-color: var(--app-border); }
.slot-box {
    width: 100px;
    border: 2px solid #cfd8ea;
    border-radius: .6rem;
    padding: .7rem .4rem;
    text-align: center;
    position: relative;
}
.slot-box.paid { border-color: var(--app-primary); }
.slot-box.free { border-color: #22c55e; }
.slot-box.used { border-color: #cbd5e1; opacity: .6; }
.slot-box .slot-box-icon { font-size: 1.25rem; color: var(--app-primary); }
.slot-box.free .slot-box-icon { color: #22c55e; }
.slot-box.used .slot-box-icon { color: #94a3b8; }
.slot-box .slot-box-label { font-weight: 600; font-size: .78rem; margin-top: .3rem; }
.slot-box .slot-box-status {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    margin-top: .3rem;
    padding: .1rem .4rem;
    border-radius: .8rem;
    display: inline-block;
}
.slot-box.paid .slot-box-status { background: var(--app-primary-soft); color: var(--app-primary); }
.slot-box.free .slot-box-status { background: #e8faf0; color: #22c55e; }
.slot-box.used .slot-box-status { background: #f1f3f6; color: #94a3b8; }

/* Extra hover lift for the card-style pickers above, layered on top of their base rules. */
.device-card:hover,
.package-card:hover:not(.disabled) {
    box-shadow: 0 8px 20px rgba(20, 30, 60, .09);
    transform: translateY(-2px);
}
.device-card, .package-card {
    transition: border-color .15s, box-shadow .15s, transform .15s, background .15s;
}
.device-card.active { box-shadow: 0 4px 14px rgba(79, 143, 247, .18); }

/* ---------- Booking wizard: progress stepper ---------- */
.booking-stepper {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1.25rem;
}
.booking-step {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .9rem .4rem .4rem;
    border-radius: 999px;
    background: #f1f3f6;
    color: var(--app-text-muted);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}
.booking-step:hover { background: #e6e9ee; }
.booking-step.active:hover { background: var(--app-primary-soft); }
.booking-step:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.booking-step .step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #dbe1ea;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    flex-shrink: 0;
    transition: background .2s ease;
}
.booking-step.active {
    background: var(--app-primary-soft);
    color: var(--app-primary);
}
.booking-step.active .step-num { background: var(--app-primary); }
.booking-step.done { color: #16a34a; }
.booking-step.done .step-num { background: #22c55e; }
.booking-step-arrow { color: #cbd5e1; font-size: .7rem; }

/* ---------- Booking wizard: tappable type tiles (Step 1) ---------- */
.type-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    padding: .35rem .45rem;
    border: 2px solid var(--app-border);
    border-radius: .5rem;
    background: #fff;
    cursor: pointer;
    min-width: 68px;
    text-align: center;
    font-weight: 600;
    font-size: .62rem;
    color: #1f2430;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease;
}
.type-tile i { font-size: .95rem; color: var(--app-primary); }
.type-tile:hover {
    border-color: var(--app-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(20, 30, 60, .09);
}
.btn-check:checked + .type-tile {
    border-color: var(--app-primary);
    background: var(--app-primary-soft);
    box-shadow: 0 4px 14px rgba(79, 143, 247, .18);
}
.btn-check:disabled + .type-tile,
.type-tile.disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------- Booking wizard: "added to booking" toast ---------- */
#addedToast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1080;
    background: #1f2430;
    color: #fff;
    padding: .75rem 1.15rem;
    border-radius: .6rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .85rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .25s ease, transform .25s ease;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}
#addedToast.show { opacity: 1; transform: translateY(0); }
#addedToast i { color: #4ade80; font-size: 1.15rem; flex-shrink: 0; }

/* ---------- Booking wizard: avatar-style entity cards (patient / doctor / review) ---------- */
.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--app-primary-soft);
    color: var(--app-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .7rem;
    flex-shrink: 0;
}
.avatar-circle.sm { width: 26px; height: 26px; font-size: .62rem; }
.avatar-circle.lg { width: 42px; height: 42px; font-size: .9rem; }

.entity-card {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .4rem .6rem;
    border: 1.5px solid var(--app-border);
    border-radius: .5rem;
    background: #fff;
    cursor: pointer;
    font-size: .8rem;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.entity-card:hover { border-color: var(--app-primary); box-shadow: 0 6px 16px rgba(20, 30, 60, .07); }
.entity-card.active { border-color: var(--app-primary); border-width: 2px; background: var(--app-primary-soft); }
.entity-card .entity-name { font-weight: 700; font-size: .78rem; color: #1f2430; }
.entity-card .entity-meta { font-size: .68rem; color: var(--app-text-muted); }
.entity-card .entity-check {
    margin-left: auto;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 2px solid var(--app-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .58rem;
    color: transparent;
    transition: all .15s ease;
}
.entity-card.active .entity-check {
    border-color: var(--app-primary);
    background: var(--app-primary);
    color: #fff;
}

/* Small "open full profile" link on patient cards — stops propagation so it doesn't also select the card. */
.entity-view-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--app-text-muted);
    font-size: .75rem;
    flex-shrink: 0;
    transition: color .15s ease, background .15s ease;
}
.entity-view-link:hover { color: var(--app-primary); background: var(--app-primary-soft); }

/* Compact variant: fits two per row in a Bootstrap grid column (e.g. doctor picker) instead of one
 * full-width card per line. */
.entity-card-compact {
    width: 100%;
    padding: .3rem .5rem;
    gap: .4rem;
}
.entity-card-compact .avatar-circle { width: 26px; height: 26px; font-size: .62rem; flex-shrink: 0; }
.entity-card-compact .entity-name { font-size: .72rem; }
.entity-card-compact .entity-meta { font-size: .62rem; }
.entity-card-compact .entity-check { width: 14px; height: 14px; }
#patientCardList { max-height: 30vh; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; padding-right: 2px; }

/* Category filter chips (doctor services): fixed-height pills so every category reads as the same
 * size regardless of label length, instead of variable-width buttons. */
.category-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    height: 28px;
    padding: 0 .75rem;
    border-radius: 999px;
    border: 1.5px solid var(--app-border);
    background: #fff;
    color: #1f2430;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.category-badge:hover { border-color: var(--app-primary); }
.category-badge.active {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: #fff;
}

/* Service rows: circular colored icon + name/meta + price, replacing the plain left-border list rows.
 * Deliberately roomier than the entity-card / type-tile pickers above — this is the primary "Choose a
 * Service" step, so it gets more visual weight while everything around it shrinks. */
.service-row {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1rem 1.1rem;
    font-size: .95rem;
}
.service-row .entity-name { font-size: .95rem; }
.service-row .entity-meta { font-size: .8rem; }
.service-row .service-row-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.service-row .service-row-price { font-weight: 700; font-size: 1.05rem; color: #1f2430; white-space: nowrap; }

/* Payment method selector: icon cards instead of a plain <select> */
.payment-method-card {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem .85rem;
    border: 1.5px solid var(--app-border);
    border-radius: .65rem;
    cursor: pointer;
    font-weight: 600;
    font-size: .82rem;
    transition: border-color .15s ease, background .15s ease;
}
.payment-method-card i { font-size: 1.3rem; color: var(--app-primary); }
.payment-method-card:hover { border-color: var(--app-primary); }
.btn-check:checked + .payment-method-card { border-color: var(--app-primary); border-width: 2px; background: var(--app-primary-soft); }

/* Review (Tab 4) overview block */
.review-row { display: flex; justify-content: space-between; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--app-border); }
.review-row:last-child { border-bottom: none; }
.review-change-link { font-size: .74rem; font-weight: 600; }
