/**
 * Guided Tours Styles
 *
 * Supports both light and dark themes via CSS variables.
 */

/* ========== Prevent Scrolling When Tour Active ========== */
html.tour-active,
html.tour-active body {
    overflow: hidden !important;
}

body.tour-active {
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
}

/* ========== Overlay ========== */
.tour-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 99990;
    opacity: 0;
    animation: tourFadeIn 0.3s ease forwards;
}

/* ========== Spotlight ========== */
.tour-spotlight {
    position: fixed;
    z-index: 99991;
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.65),
        0 0 15px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    pointer-events: none;
    transition: all 0.3s ease;
}

/* Spotlight pulse animation */
.tour-spotlight::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px solid var(--accent-color, #4AAEDC);
    border-radius: inherit;
    animation: tourSpotlightPulse 2s ease-in-out infinite;
}

/* ========== Tooltip ========== */
.tour-tooltip {
    position: fixed;
    z-index: 99992;
    background: var(--tour-bg, #1a1a2e);
    border: 1px solid var(--tour-border, #2a2a4a);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    min-width: 280px;
    max-width: min(420px, calc(100vw - 20px));
    opacity: 0;
    animation: tourSlideIn 0.3s ease forwards;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Centered tooltip (no target) */
.tour-tooltip-center {
    position: fixed;
    animation: tourScaleIn 0.3s ease forwards;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .tour-tooltip {
        min-width: 260px;
        max-width: calc(100vw - 20px);
    }
}

/* ========== Tooltip Arrow ========== */
.tour-tooltip-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--tour-bg, #1a1a2e);
    border: 1px solid var(--tour-border, #2a2a4a);
    transform: rotate(45deg);
}

.tour-tooltip-bottom .tour-tooltip-arrow {
    top: -7px;
    left: 50%;
    margin-left: -6px;
    border-right: none;
    border-bottom: none;
}

.tour-tooltip-top .tour-tooltip-arrow {
    bottom: -7px;
    left: 50%;
    margin-left: -6px;
    border-left: none;
    border-top: none;
}

.tour-tooltip-left .tour-tooltip-arrow {
    right: -7px;
    top: 50%;
    margin-top: -6px;
    border-left: none;
    border-bottom: none;
}

.tour-tooltip-right .tour-tooltip-arrow {
    left: -7px;
    top: 50%;
    margin-top: -6px;
    border-right: none;
    border-top: none;
}

.tour-tooltip-bottom-start .tour-tooltip-arrow {
    top: -7px;
    left: 24px;
    border-right: none;
    border-bottom: none;
}

.tour-tooltip-bottom-end .tour-tooltip-arrow {
    top: -7px;
    right: 24px;
    border-right: none;
    border-bottom: none;
}

.tour-tooltip-top-start .tour-tooltip-arrow {
    bottom: -7px;
    left: 24px;
    border-left: none;
    border-top: none;
}

.tour-tooltip-top-end .tour-tooltip-arrow {
    bottom: -7px;
    right: 24px;
    border-left: none;
    border-top: none;
}

.tour-tooltip-center .tour-tooltip-arrow {
    display: none;
}

/* ========== Tooltip Header ========== */
.tour-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px 16px;
    border-bottom: 1px solid var(--tour-border, #2a2a4a);
    flex-shrink: 0;
}

.tour-tooltip-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--tour-title, #fff);
    margin: 0;
}

.tour-tooltip-close {
    background: none;
    border: none;
    color: var(--tour-text-secondary, #888);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s ease;
}

.tour-tooltip-close:hover {
    color: var(--tour-text, #fff);
}

/* ========== Tooltip Content ========== */
.tour-tooltip-content {
    padding: 16px;
    color: var(--tour-text, #e0e0e0);
    font-size: 14px;
    line-height: 1.6;
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - 200px); /* Leave room for header and footer */
}

.tour-tooltip-content p {
    margin: 0 0 12px 0;
}

.tour-tooltip-content p:last-child {
    margin-bottom: 0;
}

.tour-tooltip-content ul,
.tour-tooltip-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.tour-tooltip-content li {
    margin-bottom: 6px;
}

.tour-tooltip-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.tour-tooltip-content a {
    color: var(--accent-color, #4AAEDC);
    text-decoration: none;
}

.tour-tooltip-content a:hover {
    text-decoration: underline;
}

/* ========== Tooltip Footer ========== */
.tour-tooltip-footer {
    padding: 12px 16px 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

/* Progress */
.tour-tooltip-progress {
    flex: 1;
}

.tour-progress-text {
    font-size: 12px;
    color: var(--tour-text-secondary, #888);
    margin-bottom: 4px;
    display: block;
}

.tour-progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.tour-progress-fill {
    height: 100%;
    background: var(--accent-color, #4AAEDC);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Actions */
.tour-tooltip-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ========== Buttons ========== */
.tour-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 70px;
}

.tour-btn-primary {
    background: var(--accent-color, #4AAEDC);
    color: #fff;
}

.tour-btn-primary:hover {
    background: var(--accent-hover, #3a9ecc);
    transform: translateY(-1px);
}

.tour-btn-secondary {
    background: transparent;
    color: var(--tour-text-secondary, #888);
    border: 1px solid var(--tour-border, #2a2a4a);
}

.tour-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--tour-text, #e0e0e0);
}

/* ========== Animations ========== */
@keyframes tourFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes tourSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tourScaleIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes tourSpotlightPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ========== Dark Mode (Default) ========== */
:root {
    --tour-bg: #1a1a2e;
    --tour-border: #2a2a4a;
    --tour-title: #ffffff;
    --tour-text: #e0e0e0;
    --tour-text-secondary: #888888;
    --accent-color: #4AAEDC;
    --accent-hover: #3a9ecc;
}

/* ========== Light Mode ========== */
.dark-mode .tour-overlay,
body.dark-mode .tour-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.dark-mode .tour-spotlight,
body.dark-mode .tour-spotlight {
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(0, 0, 0, 0.2);
}

.dark-mode .tour-tooltip,
body.dark-mode .tour-tooltip {
    --tour-bg: #ffffff;
    --tour-border: #e0e0e0;
    --tour-title: #1a1a1a;
    --tour-text: #333333;
    --tour-text-secondary: #666666;
    background: var(--tour-bg);
    border-color: var(--tour-border);
}

.dark-mode .tour-tooltip-arrow,
body.dark-mode .tour-tooltip-arrow {
    background: var(--tour-bg);
    border-color: var(--tour-border);
}

.dark-mode .tour-tooltip-header,
body.dark-mode .tour-tooltip-header {
    border-bottom-color: var(--tour-border);
}

.dark-mode .tour-tooltip-content code,
body.dark-mode .tour-tooltip-content code {
    background: rgba(0, 0, 0, 0.05);
}

.dark-mode .tour-progress-bar,
body.dark-mode .tour-progress-bar {
    background: rgba(0, 0, 0, 0.1);
}

.dark-mode .tour-btn-secondary,
body.dark-mode .tour-btn-secondary {
    border-color: var(--tour-border);
}

.dark-mode .tour-btn-secondary:hover,
body.dark-mode .tour-btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ========== Responsive ========== */
@media (max-width: 480px) {
    .tour-tooltip {
        min-width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        left: 16px !important;
        right: 16px;
    }

    .tour-tooltip-center {
        left: 50% !important;
        transform: translate(-50%, -50%);
    }

    .tour-tooltip-footer {
        flex-direction: column;
        gap: 12px;
    }

    .tour-tooltip-progress {
        width: 100%;
    }

    .tour-tooltip-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ========== Tour Launcher Button ========== */
.tour-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99980;
    background: var(--accent-color, #4AAEDC);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(74, 174, 220, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.tour-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(74, 174, 220, 0.5);
}

.tour-launcher:active {
    transform: scale(0.95);
}

.tour-launcher i {
    font-size: 22px;
}

/* Launcher positions */
.tour-launcher-bottom-right {
    bottom: 20px;
    right: 20px;
}

.tour-launcher-bottom-left {
    bottom: 20px;
    left: 20px;
    right: auto;
}

.tour-launcher-top-right {
    top: 20px;
    bottom: auto;
    right: 20px;
}

.tour-launcher-top-left {
    top: 20px;
    bottom: auto;
    left: 20px;
    right: auto;
}

/* ========== Tour Menu ========== */
.tour-menu {
    position: fixed;
    z-index: 99981;
    background: var(--tour-bg, #1a1a2e);
    border: 1px solid var(--tour-border, #2a2a4a);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    width: 320px;
    max-height: 70vh;
    overflow: hidden;
    display: none;
}

.tour-menu.show {
    display: flex;
    flex-direction: column;
    animation: tourMenuSlideIn 0.25s ease;
}

/* Menu positions */
.tour-menu-bottom-right {
    bottom: 82px;
    right: 20px;
}

.tour-menu-bottom-left {
    bottom: 82px;
    left: 20px;
    right: auto;
}

.tour-menu-top-right {
    top: 82px;
    bottom: auto;
    right: 20px;
}

.tour-menu-top-left {
    top: 82px;
    bottom: auto;
    left: 20px;
    right: auto;
}

@keyframes tourMenuSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tour-menu-header {
    padding: 16px;
    border-bottom: 1px solid var(--tour-border, #2a2a4a);
    font-weight: 600;
    font-size: 16px;
    color: var(--tour-title, #fff);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.tour-menu-close {
    background: none;
    border: none;
    color: var(--tour-text-secondary, #888);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tour-menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--tour-text, #fff);
}

.tour-menu-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}

.tour-menu-item {
    padding: 12px 16px;
    color: var(--tour-text, #e0e0e0);
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tour-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tour-menu-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(74, 174, 220, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tour-menu-item-icon i {
    font-size: 14px;
    color: var(--accent-color, #4AAEDC);
}

.tour-menu-item.completed .tour-menu-item-icon {
    background: rgba(76, 175, 80, 0.1);
}

.tour-menu-item.completed .tour-menu-item-icon i {
    color: #4CAF50;
}

.tour-menu-item-content {
    flex: 1;
    min-width: 0;
}

.tour-menu-item-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--tour-title, #fff);
    margin-bottom: 2px;
}

.tour-menu-item-desc {
    font-size: 12px;
    color: var(--tour-text-secondary, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tour-menu-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.tour-menu-start-btn,
.tour-menu-restart-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.tour-menu-start-btn {
    color: var(--accent-color, #4AAEDC);
    background: rgba(74, 174, 220, 0.1);
}

.tour-menu-start-btn:hover {
    background: rgba(74, 174, 220, 0.2);
}

.tour-menu-restart-btn {
    color: var(--tour-text-secondary, #888);
}

.tour-menu-restart-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--tour-text, #fff);
}

/* Resume Section */
.tour-menu-resume {
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(74, 174, 220, 0.15), rgba(74, 174, 220, 0.05));
    border-bottom: 1px solid var(--accent-color, #4AAEDC);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tour-menu-resume-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tour-menu-resume-info > i {
    font-size: 24px;
    color: var(--accent-color, #4AAEDC);
}

.tour-menu-resume-info > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tour-menu-resume-info strong {
    color: var(--tour-title, #fff);
    font-size: 14px;
}

.tour-menu-resume-info span {
    color: var(--tour-text-secondary, #888);
    font-size: 12px;
}

.tour-menu-resume-actions {
    display: flex;
    gap: 8px;
}

.tour-menu-resume-btn {
    flex: 1;
    padding: 8px 16px;
    background: var(--accent-color, #4AAEDC);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tour-menu-resume-btn:hover {
    background: var(--accent-hover, #3a9ecc);
    transform: translateY(-1px);
}

.tour-menu-dismiss-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--tour-border, #2a2a4a);
    border-radius: 6px;
    color: var(--tour-text-secondary, #888);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tour-menu-dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--tour-text, #fff);
}

/* Paused state for tour items */
.tour-menu-item.paused {
    border-left: 3px solid var(--accent-color, #4AAEDC);
    padding-left: 13px;
}

.tour-menu-item.paused .tour-menu-item-icon {
    color: var(--accent-color, #4AAEDC);
}

.tour-menu-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--tour-border, #2a2a4a);
    flex-shrink: 0;
}

.tour-menu-reset-all {
    width: 100%;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--tour-border, #2a2a4a);
    border-radius: 6px;
    color: var(--tour-text-secondary, #888);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tour-menu-reset-all:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--tour-text, #e0e0e0);
}

.tour-menu-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--tour-text-secondary, #888);
}

/* ========== Embeddable Tour List ========== */
.tour-list-embed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tour-list-item {
    background: var(--tour-bg, #1a1a2e);
    border: 1px solid var(--tour-border, #2a2a4a);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.tour-list-item.completed {
    opacity: 0.8;
}

.tour-list-item-info {
    flex: 1;
    min-width: 0;
}

.tour-list-item-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--tour-title, #fff);
    margin: 0 0 4px 0;
}

.tour-list-item-desc {
    font-size: 14px;
    color: var(--tour-text-secondary, #888);
    margin: 0 0 8px 0;
}

.tour-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--tour-text-secondary, #888);
}

.tour-status-badge.completed {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
}

.tour-list-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.tour-list-empty {
    text-align: center;
    padding: 32px;
    color: var(--tour-text-secondary, #888);
}

/* ========== Dark Mode Overrides ========== */
.dark-mode .tour-launcher,
body.dark-mode .tour-launcher {
    box-shadow: 0 4px 16px rgba(74, 174, 220, 0.3);
}

.dark-mode .tour-menu,
body.dark-mode .tour-menu,
.dark-mode .tour-list-item,
body.dark-mode .tour-list-item {
    --tour-bg: #ffffff;
    --tour-border: #e0e0e0;
    --tour-title: #1a1a1a;
    --tour-text: #333333;
    --tour-text-secondary: #666666;
    background: var(--tour-bg);
    border-color: var(--tour-border);
}

.dark-mode .tour-menu-item:hover,
body.dark-mode .tour-menu-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.dark-mode .tour-menu-reset-all,
body.dark-mode .tour-menu-reset-all {
    background: rgba(0, 0, 0, 0.03);
}

.dark-mode .tour-menu-reset-all:hover,
body.dark-mode .tour-menu-reset-all:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ========== Responsive ========== */
@media (max-width: 480px) {
    .tour-menu {
        width: calc(100vw - 32px);
        left: 16px !important;
        right: 16px !important;
        bottom: 82px !important;
        max-height: 60vh;
    }

    .tour-launcher {
        width: 48px;
        height: 48px;
    }

    .tour-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .tour-list-item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
