/* ══════════════════════════════════════════════════════════
   راهنمای گام‌به‌گام روی صفحه (clinic-tour.js + TourLauncher)
   رنگ‌ها از توکن‌های clinic-theme.css می‌آیند تا در هر دو تم درست بمانند.
   لایه: بالای پنجره‌های تلریک (حدود ۱۰۰۰۰) و زیر تقویم، هشدار مانع و پیام‌ها (۲۰۰۰۰ به بالا).
   ══════════════════════════════════════════════════════════ */
html[data-bs-theme="light"] {
    --ctour-dim: rgba(15, 23, 42, 0.62);
    --ctour-ring: #ffffff;
    --ctour-glow: rgba(59, 130, 246, 0.55);
    --ctour-shadow: 0 24px 60px rgba(15, 23, 42, 0.30), 0 2px 8px rgba(15, 23, 42, 0.12);
    --ctour-ok-bg: #ecfdf5;
    --ctour-stop-bg: #fef2f2;
    --ctour-warn-bg: #fffbeb;
}

html[data-bs-theme="dark"] {
    --ctour-dim: rgba(2, 6, 14, 0.74);
    --ctour-ring: #93c5fd;
    --ctour-glow: rgba(96, 165, 250, 0.6);
    --ctour-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(96, 165, 250, 0.18);
    --ctour-ok-bg: rgba(34, 197, 94, 0.12);
    --ctour-stop-bg: rgba(239, 68, 68, 0.13);
    --ctour-warn-bg: rgba(245, 158, 11, 0.13);
}

/* ── دکمهٔ نوار بالا ─────────────────────────────────── */
.ctour-launch {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.45);
    animation: ctour-beacon 2.6s ease-out 1s 3;
}

@keyframes ctour-beacon {
    0% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.45); }
    70%, 100% { box-shadow: 0 0 0 10px rgba(var(--primary-rgb), 0); }
}

/* ── بخش روشن و تیرگی دورش ───────────────────────────── */
.ctour {
    position: fixed;
    inset: 0;
    z-index: 15000;
    pointer-events: none;
    animation: ctour-fade 0.22s ease-out;
}

.ctour.is-leaving {
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

.ctour-hole {
    position: fixed;
    border-radius: 12px;
    box-shadow: 0 0 0 200vmax var(--ctour-dim);
    pointer-events: none;
}

.ctour-hole.is-moving {
    transition: left 0.38s cubic-bezier(0.22, 1, 0.36, 1), top 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.38s cubic-bezier(0.22, 1, 0.36, 1), height 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.ctour-hole::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid var(--ctour-ring);
    box-shadow: 0 0 0 4px var(--ctour-glow);
    animation: ctour-pulse 1.8s ease-in-out infinite;
}

.ctour-hole.is-none::after,
.ctour.is-free .ctour-hole {
    display: none;
}

@keyframes ctour-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--ctour-glow); opacity: 1; }
    50% { box-shadow: 0 0 0 9px transparent; opacity: 0.85; }
}

@keyframes ctour-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* فهرست بازشوی تلریک باید روی تیرگی بیاید تا بشود از آن انتخاب کرد. */
html.ctour-on .k-animation-container {
    z-index: 15010 !important;
}

/* ── حباب توضیح ──────────────────────────────────────── */
.ctour-pop {
    position: fixed;
    width: min(25rem, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--ctour-shadow);
    pointer-events: auto;
    direction: rtl;
    text-align: right;
    font-family: 'IRANSansWeb';
    transition: left 0.32s cubic-bezier(0.22, 1, 0.36, 1), top 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.ctour-pop.is-in .ctour-body {
    animation: ctour-rise 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.ctour-pop.is-nudge {
    animation: ctour-nudge 0.36s ease;
}

@keyframes ctour-rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes ctour-nudge {
    0%, 100% { transform: none; }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.ctour-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    transform: rotate(45deg);
}

.ctour-pop[data-side="bottom"] .ctour-arrow { top: -8px; border-right: 0; border-bottom: 0; }
.ctour-pop[data-side="top"] .ctour-arrow { bottom: -8px; border-left: 0; border-top: 0; }
.ctour-pop[data-side="left"] .ctour-arrow { right: -8px; border-left: 0; border-bottom: 0; }
.ctour-pop[data-side="right"] .ctour-arrow { left: -8px; border-right: 0; border-top: 0; }
.ctour-pop[data-side="none"] .ctour-arrow { display: none; }

.ctour-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.8rem 1rem 0.6rem;
}

.ctour-count {
    flex: none;
    padding: 0.16rem 0.6rem;
    border-radius: 999px;
    background: var(--primary);
    color: var(--primary-contrast);
    font-size: 0.74rem;
    font-weight: 800;
}

.ctour-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.ctour-x,
.ctour-ask-x {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.ctour-x:hover,
.ctour-ask-x:hover {
    background: var(--btn-face-hover);
    color: var(--text);
}

.ctour-bar {
    height: 3px;
    margin: 0 1rem;
    border-radius: 3px;
    background: var(--muted-bg);
    overflow: hidden;
}

.ctour-bar > i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.ctour-body {
    padding: 0.85rem 1rem 0.3rem;
    overflow: auto;
}

.ctour-title {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.7;
}

.ctour-text {
    margin: 0 0 0.7rem;
    font-size: 0.9rem;
    line-height: 2;
}

.ctour-do,
.ctour-dont,
.ctour-hint,
.ctour-missing {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin: 0 0 0.5rem;
    padding: 0.5rem 0.65rem;
    border-radius: 11px;
    font-size: 0.84rem;
    line-height: 1.9;
}

.ctour-do[hidden],
.ctour-dont[hidden],
.ctour-hint[hidden],
.ctour-missing[hidden] {
    display: none;
}

.ctour-do .bi,
.ctour-dont .bi,
.ctour-hint .bi,
.ctour-missing .bi {
    flex: none;
    margin-top: 0.3rem;
    font-size: 0.95rem;
}

.ctour-do { background: var(--ctour-ok-bg); }
.ctour-do .bi { color: var(--success); }
.ctour-dont { background: var(--ctour-stop-bg); }
.ctour-dont .bi { color: var(--danger); }
.ctour-missing { background: var(--ctour-warn-bg); font-weight: 600; }
.ctour-missing .bi { color: var(--warning); }

.ctour-hint {
    padding: 0.1rem 0.15rem;
    color: var(--primary);
    font-weight: 700;
}

.ctour-foot {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 1rem 0.9rem;
}

.ctour-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.25rem;
    padding: 0.35rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--btn-face);
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.ctour-btn:hover {
    background: var(--btn-face-hover);
    color: var(--text);
}

.ctour-btn:active {
    transform: translateY(1px);
}

.ctour-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.ctour-btn.is-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--primary-contrast);
}

.ctour-btn.is-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--primary-contrast);
}

.ctour-btn:focus-visible,
.ctour-x:focus-visible,
.ctour-ask-x:focus-visible,
.ctour-ask-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── پنجرهٔ «می‌خواهید چه کاری انجام دهید؟» ─────────── */
.ctour-ask {
    position: fixed;
    inset: 0;
    z-index: 15000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: var(--ctour-dim);
    backdrop-filter: blur(3px);
    animation: ctour-fade 0.2s ease-out;
}

.ctour-ask-card {
    position: relative;
    width: min(37rem, 100%);
    max-height: min(88vh, 46rem);
    overflow: auto;
    padding: 1.4rem 1.4rem 1.1rem;
    border-radius: 22px;
    background:
        radial-gradient(900px 200px at 100% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 60%),
        var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--ctour-shadow);
    direction: rtl;
    text-align: right;
    animation: ctour-pop-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes ctour-pop-in {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

.ctour-ask-x {
    position: absolute;
    top: 0.8rem;
    left: 0.8rem;
}

.ctour-ask-head {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    padding-left: 2rem;
}

.ctour-ask-badge {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 15px;
    background: var(--primary);
    color: var(--primary-contrast);
    font-size: 1.35rem;
}

.ctour-ask-badge.is-stop { background: var(--danger); }
.ctour-ask-badge.is-warn { background: var(--warning); }
.ctour-ask-badge.is-ok { background: var(--success); }

.ctour-ask-kicker {
    margin: 0 0 0.2rem;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
}

.ctour-ask-head h2 {
    margin: 0 0 0.35rem;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.7;
}

.ctour-ask-lead {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.95;
}

.ctour-ask-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-top: 1.1rem;
}

.ctour-ask-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 15px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: right;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.ctour-ask-item:hover:not(:disabled) {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.14);
}

.ctour-ask-item:disabled {
    opacity: 0.6;
    cursor: progress;
}

.ctour-ask-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 12px;
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
    font-size: 1.15rem;
}

.ctour-ask-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.ctour-ask-main strong {
    font-size: 0.98rem;
}

.ctour-ask-main em {
    font-style: normal;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.8;
}

.ctour-ask-meta {
    flex: none;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
}

.ctour-ask-go {
    flex: none;
    color: var(--primary);
}

.ctour-ask-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}

.ctour-ask-foot > a:not(.ctour-btn) {
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
}

/* ── فهرست پیش‌نیازها با وضعیت همین لحظه ─────────────── */
.ctour-needs {
    list-style: none;
    margin: 1.1rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ctour-needs li {
    display: flex;
    gap: 0.75rem;
    padding: 0.8rem 0.9rem;
    border-radius: 15px;
    border: 1px solid var(--border);
}

.ctour-needs li.is-ok { background: var(--ctour-ok-bg); }
.ctour-needs li.is-stop { background: var(--ctour-stop-bg); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.ctour-needs li.is-warn { background: var(--ctour-warn-bg); border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }

.ctour-need-mark {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    color: #fff;
    font-size: 0.9rem;
}

.is-ok .ctour-need-mark { background: var(--success); }
.is-stop .ctour-need-mark { background: var(--danger); }
.is-warn .ctour-need-mark { background: var(--warning); }

.ctour-needs strong {
    font-size: 0.95rem;
}

.ctour-need-state {
    margin-right: 0.5rem;
    font-size: 0.74rem;
    font-weight: 800;
}

.is-ok .ctour-need-state { color: var(--success-text); }
.is-stop .ctour-need-state { color: var(--danger-text); }
.is-warn .ctour-need-state { color: var(--warning-text); }

.ctour-needs p {
    margin: 0.25rem 0 0;
    font-size: 0.86rem;
    line-height: 1.95;
}

.ctour-need-foreign {
    color: var(--text-muted);
    font-weight: 600;
}

.ctour-need-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.6rem;
}

@media (max-width: 575.98px) {
    .ctour-launch-text { display: none; }
    .ctour-ask { padding: 0.6rem; align-items: flex-end; }
    .ctour-ask-card { padding: 1.1rem 1rem 0.9rem; border-radius: 18px; }
    .ctour-ask-meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ctour, .ctour-pop, .ctour-pop.is-in .ctour-body, .ctour-ask, .ctour-ask-card, .ctour-launch { animation: none; }
    .ctour-hole::after { animation: none; }
    .ctour-hole.is-moving, .ctour-pop, .ctour-bar > i { transition: none; }
}

@media print {
    .ctour, .ctour-ask, .ctour-launch { display: none !important; }
}
