/* ══════════════════════════════════════════
   Driver.js — CAR Book Theme (v3 tooltip)
   Използва CSS vars от style.css (--card, --accent, etc.)
   Подменя стандартния Driver.js popover с нашата v3 структура
   ══════════════════════════════════════════ */

/* Скриваме default Driver.js съдържание — tour_engine.js го заменя */
.driver-popover.cb-tour .driver-popover-title,
.driver-popover.cb-tour .driver-popover-description,
.driver-popover.cb-tour .driver-popover-close-btn,
.driver-popover.cb-tour .driver-popover-footer {
    display: none !important;
}

/* Popover контейнер */
.driver-popover.cb-tour {
    background: var(--card) !important;
    border: 1px solid var(--accent) !important;
    border-radius: 14px !important;
    box-shadow: 0 0 0 1px rgba(59,130,246,.12), 0 8px 32px rgba(0,0,0,.25) !important;
    color: var(--text) !important;
    padding: 0 !important;
    max-width: 300px !important;
    overflow: hidden !important;
    animation: cb-spring .55s cubic-bezier(.34,1.4,.64,1) both;
}
[data-theme="dark"] .driver-popover.cb-tour {
    box-shadow: 0 0 0 1px rgba(74,158,255,.12), 0 8px 40px rgba(0,0,0,.5) !important;
}

/* Arrow */
.driver-popover.cb-tour .driver-popover-arrow {
    display: none !important;
}

/* Spring animation */
@keyframes cb-spring {
    0%   { opacity: 0; transform: scale(.85); }
    55%  { opacity: 1; transform: scale(1.03); }
    75%  { transform: scale(.98); }
    100% { transform: scale(1); }
}

/* ── Accent bar (3px горе) ── */
.cb-bar {
    height: 3px;
    background: var(--accent);
}

/* ── Header ── */
.cb-header {
    background: var(--accent-bg);
    border-bottom: 1px solid var(--glass-border);
    padding: 10px 13px;
}
.cb-title-box {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 8px 10px 9px;
    position: relative;
}
.cb-title-text {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.3;
    letter-spacing: -.2px;
    padding-right: 26px;
}
.cb-close {
    position: absolute;
    top: 7px; right: 8px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-ter);
    font-size: 11px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    transition: background .15s, color .15s;
}
.cb-close:hover {
    background: var(--glass-border);
    color: var(--text);
}

/* ── Body ── */
.cb-body {
    padding: 11px 13px 9px;
}
.cb-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 500;
    color: var(--accent);
    opacity: .18;
    line-height: 1;
    float: right;
    margin: -3px -1px 0 8px;
    user-select: none;
}
.cb-divider {
    width: 24px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
    margin-bottom: 8px;
}
.cb-typing {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 9px 11px;
    min-height: 56px;
    clear: both;
}
.cb-typing-lbl {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-ter);
    margin-bottom: 5px;
}
.cb-typing-text {
    font-size: 13px;
    color: var(--text-sec);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}
@media (max-width: 768px) {
    .cb-typing-text { font-size: 14px; }
}
.cb-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent);
    margin-left: 1px;
    vertical-align: text-bottom;
    border-radius: 1px;
    animation: cb-blink .85s step-end infinite;
}
@keyframes cb-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Footer ── */
.cb-foot {
    background: var(--glass);
    border-top: 1px solid var(--glass-border);
    padding: 9px 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cb-btn-skip {
    background: none;
    border: none;
    color: var(--text-ter);
    font-size: 10px;
    font-weight: 600;
    padding: 4px 0;
    cursor: pointer;
    font-family: inherit;
    margin-right: auto;
}
.cb-btn-skip:hover { color: var(--text-sec); }
.cb-btn-back {
    background: none;
    border: 1px solid var(--glass-border);
    border-radius: 7px;
    color: var(--text-ter);
    font-size: 10px;
    font-weight: 700;
    padding: 5px 12px;
    cursor: pointer;
    font-family: inherit;
}
.cb-btn-back:hover { color: var(--text); border-color: var(--text-ter); }
.cb-btn-next {
    background: var(--accent);
    border: none;
    border-radius: 7px;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 5px 13px;
    cursor: pointer;
    font-family: inherit;
}
.cb-btn-next:hover { filter: brightness(1.1); }
.cb-btn-finish {
    background: var(--green);
    border: none;
    border-radius: 7px;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 5px 13px;
    cursor: pointer;
    font-family: inherit;
}
.cb-btn-finish:hover { filter: brightness(1.1); }

/* ── Green finish state ── */
.cb-tour--finish .cb-bar,
.cb-tour--finish .cb-divider { background: var(--green); }
.cb-tour--finish .cb-num { color: var(--green); }
.cb-tour--finish .cb-header { background: rgba(34,197,94,.08); }
.cb-tour--finish .cb-cursor { background: var(--green); }
.driver-popover.cb-tour.cb-tour--finish {
    border-color: var(--green) !important;
    box-shadow: 0 0 0 1px rgba(34,197,94,.15), 0 8px 32px rgba(0,0,0,.25) !important;
}

/* ── Help "?" button (inline in nav-items and page headers) ── */
.nav-item__help {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--glass); border: 1px solid var(--glass-border);
    color: var(--text-ter); font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; margin-left: auto; flex-shrink: 0;
    transition: background .15s, color .15s, border-color .15s;
    text-decoration: none; line-height: 1;
    vertical-align: middle;
}
.nav-item__help:hover {
    background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent);
}
.nav-item__help-tip {
    display: none;
    pointer-events: none;
}
.nav-item__help-tip strong {
    color: var(--text); font-size: 12px; display: block; margin-bottom: 4px;
}

/* ── Floating help tooltip (appended to body) ── */
.cb-floating-tip {
    position: fixed; z-index: 10002;
    background: var(--card); border: 1px solid var(--accent-border); border-radius: 10px;
    padding: 10px 14px; font-size: 11px; font-weight: 500; color: var(--text-sec);
    line-height: 1.6; width: 240px;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
    pointer-events: none; transform: translateX(-50%);
    animation: cb-tip-in .2s ease both;
}
.cb-floating-tip strong {
    color: var(--text); font-size: 12px; display: block; margin-bottom: 3px;
}
.cb-floating-tip::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: var(--accent-border);
}
@keyframes cb-tip-in {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Demo center overlay (контейнер за start + back) ── */
.demo-center-overlay {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* ── Tour start button ── */
.tour-start-btn {
    background: rgba(59,130,246,0.55);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 18px 40px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 8px 32px rgba(59,130,246,.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: cb-float 3s ease-in-out infinite;
    transition: background .2s, box-shadow .2s;
}
.tour-start-btn:hover {
    background: rgba(59,130,246,0.85);
    box-shadow: 0 12px 40px rgba(59,130,246,.5);
}

/* ── Demo back link (под start бутона) ── */
.demo-back-link {
    font-size: 13px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: .5px;
    padding: 8px 20px;
    background: rgba(13,15,20,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    transition: background .2s, border-color .2s;
}
.demo-back-link:hover {
    background: rgba(13,15,20,0.9);
    border-color: var(--accent);
    color: var(--accent);
}
@media (max-width: 768px) {
    .demo-back-link { font-size: 14px; padding: 10px 24px; }
}
@keyframes cb-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ── Highlight ring around target ── */
.cb-highlight-ring {
    position: fixed;
    z-index: 10001;
    border: 2px solid var(--accent);
    border-radius: 10px;
    pointer-events: none;
    animation: cb-ring-pulse 1.8s ease-in-out infinite;
}
@keyframes cb-ring-pulse {
    0%, 100% {
        border-color: rgba(59,130,246,.35);
        box-shadow: 0 0 0 2px rgba(59,130,246,.06), 0 0 8px rgba(59,130,246,.05);
    }
    50% {
        border-color: var(--accent);
        box-shadow: 0 0 0 5px rgba(59,130,246,.18), 0 0 18px rgba(59,130,246,.15);
    }
}
.cb-tour--finish .cb-highlight-ring,
.cb-highlight-ring--green {
    border-color: var(--green);
    animation-name: cb-ring-pulse-green;
}
@keyframes cb-ring-pulse-green {
    0%, 100% { box-shadow: 0 0 0 4px rgba(34,197,94,.15), 0 0 20px rgba(34,197,94,.1); }
    50% { box-shadow: 0 0 0 7px rgba(34,197,94,.08), 0 0 30px rgba(34,197,94,.15); }
}
