/* Tutorial Overlay Styles */

/* Overlay Container */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent; /* Transparent, dimming handled by highlight shadow */
    /* Keep the overlay under the page content so the target element is not dimmed */
    z-index: 199990;
    display: none; /* Hidden by default */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Allow clicks to pass through */
    overflow: visible;
}

.tutorial-overlay.active {
    display: block;
    opacity: 1;
}

/* Lock body scroll during tutorial - handled by JS now, but good fallback */
/* Removed empty ruleset for body.tutorial-active */

/* The highlight hole element */
.tutorial-target-highlight {
    position: absolute;
    /* keep highlight under page content; overlay creates mask via large box-shadow */
    z-index: 199995;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); /* Dark overlay */
    border-radius: 6px;
    pointer-events: none;
    display: none;
    transition: all 0.2s ease;
}

/* Active Target Element (The element being highlighted) */
.tutorial-active-target {
    position: relative; /* Default to relative so z-index works (JS may override) */
    /* Ensure the active target sits above the overlay and highlight */
    z-index: 200020 !important;
    outline: 4px solid #FC8ED6 !important;
    outline-offset: 2px !important;
    border-radius: 8px !important;
    filter: drop-shadow(0 0 20px rgba(252, 142, 214, 1))
            drop-shadow(0 0 35px rgba(252, 142, 214, 0.8)) !important;
    animation: tutorial-pulse 2s ease-in-out infinite;
    pointer-events: auto !important; /* Ensure clickable */
}

@keyframes tutorial-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(252, 142, 214, 1))
                drop-shadow(0 0 35px rgba(252, 142, 214, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(252, 142, 214, 1))
                drop-shadow(0 0 50px rgba(252, 142, 214, 0.9));
    }
}

/* Tutorial Card/Popover */
.tutorial-card {
    position: absolute;
    background: rgba(255, 255, 255, 0.98);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    width: 320px;
    max-width: 90vw;
    z-index: 200030; /* Above the highlighted target */
    transition: top 0.1s linear, left 0.1s linear; /* Smooth follow */
    border-left: 5px solid #33A7B5;
    display: none; /* Hidden by default, shown when tutorial active */
}

/* Show card when tutorial is active */
body.tutorial-active .tutorial-card {
    display: block;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .tutorial-card {
        position: fixed !important;
        bottom: 10px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 20px) !important;
        max-width: 380px !important;
        top: auto !important;
        z-index: 200020 !important;
        padding: 12px !important;
    }

    .tutorial-toggle-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
        bottom: 15px;
        left: 15px;
    }
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.tutorial-title {
    font-weight: 700;
    font-size: 16px;
    color: #1f2937;
    margin: 0;
    line-height: 1.3;
}

.tutorial-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    line-height: 1;
}

.tutorial-close:hover {
    color: #4b5563;
}

.tutorial-content {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.45;
    margin-bottom: 12px;
    margin-top: 8px;
}

.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.tutorial-steps {
    font-size: 12px;
    color: #9ca3af;
}

.tutorial-nav {
    display: flex;
    gap: 10px;
}

.tutorial-btn {
    padding: 6px 14px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.2s;
}

.tutorial-btn-prev {
    background-color: white;
    border-color: #d1d5db;
    color: #374151;
}

.tutorial-btn-prev:hover {
    background-color: #f3f4f6;
}

.tutorial-btn-next {
    background-color: #33A7B5;
    color: white;
}

.tutorial-btn-next:hover {
    background-color: #2a8c96;
}

/* Tutorial Toggle Button (Fixed) */
.tutorial-toggle-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: rgba(51, 167, 181, 0.8);
    color: #33A7B5;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid #33A7B5;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform 0.2s, background-color 0.2s;
}

.tutorial-toggle-btn:hover {
    transform: scale(1.1);
    background-color: rgba(51, 167, 181, 0.4);
}

.tutorial-card {
    pointer-events: auto;
}

.tutorial-toggle-btn {
    pointer-events: auto;
}

/* Notification Badge */
.tutorial-toggle-btn.has-notification::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background-color: #ff6600;
    border-radius: 50%;
    border: 2px solid white;
}

.tutorial-toggle-tooltip {
    position: absolute;
    left: 60px;
    background: #1f2937;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.tutorial-toggle-btn:hover .tutorial-toggle-tooltip {
    opacity: 1;
}

@media (max-width: 768px) {
    .tutorial-toggle-tooltip {
        left: auto;
        right: auto;
        bottom: 55px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Field Tooltips */
.field-tooltip-wrapper {
    position: relative;
    display: inline-block;
}

label.has-tooltip {
    display: flex;
    align-items: center;
    gap: 6px;
}

label.has-tooltip .field-tooltip-wrapper {
    margin-left: 0;
}

.field-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background-color: #6b7280;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    cursor: help;
    margin-left: 5px;
    vertical-align: middle;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.field-tooltip-icon:hover {
    background-color: #33A7B5;
}

.field-tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.3;
    white-space: normal;
    width: 220px;
    max-width: calc(100vw - 40px);
    z-index: 200003;
    transition: opacity 0.2s, visibility 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.field-tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

.field-tooltip-icon:hover .field-tooltip-text,
.field-tooltip-icon:focus .field-tooltip-text,
.field-tooltip-icon.active .field-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Ensure tooltip doesn't overflow viewport on the right */
.field-tooltip-text {
    right: auto;
}

/* If tooltip would go off left edge */
.field-tooltip-wrapper:first-child .field-tooltip-text,
label:first-child .field-tooltip-text {
    left: 0;
    transform: translateX(0);
}

.field-tooltip-wrapper:first-child .field-tooltip-text::after,
label:first-child .field-tooltip-text::after {
    left: 20px;
    transform: translateX(0);
}

/* Mobile Tooltip Adjustments */
@media (max-width: 768px) {
    .field-tooltip-icon {
        width: 15px;
        height: 15px;
        font-size: 10px;
        margin-left: 4px;
    }

    .field-tooltip-text {
        position: fixed;
        bottom: auto;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: calc(100vw - 40px);
        max-width: 280px;
        padding: 8px 12px;
        font-size: 13px;
        line-height: 1.4;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }

    .field-tooltip-text::after {
        display: none;
    }

    /* Add touch support for mobile */
    .field-tooltip-icon {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .field-tooltip-text {
        width: 200px;
        font-size: 12px;
        padding: 6px 10px;
    }
}