/* Tutorial Wizard Styles */

/* Full-screen overlay - blocks all interaction except target */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: transparent; /* Spotlight's box-shadow provides dimming */
    z-index: 10000;
    pointer-events: auto; /* Block clicks - target will be elevated above */
    transition: opacity 0.3s ease-in-out;
}

/* Spotlight cutout - positioned dynamically via JS */
.tutorial-spotlight {
    position: fixed;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
    border-radius: 8px;
    z-index: 10001;
    pointer-events: none;
    transition: all 0.4s ease-in-out;
}

/* When clickable, allow pointer events through the spotlight */
.tutorial-spotlight.clickable {
    pointer-events: auto;
    cursor: pointer;
}

/* Add glow effect to spotlight */
.tutorial-spotlight::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid #70C059;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(112, 192, 89, 0.5);
    animation: tutorial-pulse-glow 2s infinite;
}

/* Stronger pulse for clickable elements */
.tutorial-spotlight.clickable::before {
    border-width: 3px;
    animation: tutorial-pulse-glow-strong 1.5s infinite;
}

@keyframes tutorial-pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(112, 192, 89, 0.5);
    }
    50% {
        box-shadow: 0 0 35px rgba(112, 192, 89, 0.8);
    }
}

@keyframes tutorial-pulse-glow-strong {
    0%, 100% {
        box-shadow: 0 0 25px rgba(112, 192, 89, 0.6);
        border-color: #70C059;
    }
    50% {
        box-shadow: 0 0 45px rgba(112, 192, 89, 1);
        border-color: #8ED67A;
    }
}

/* Tutorial tooltip/bubble */
.tutorial-bubble {
    position: fixed;
    z-index: 10002;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 420px;
    min-width: 300px;
    padding: 0;
    animation: tutorial-fadeIn 0.3s ease-in-out;
}

@keyframes tutorial-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Observe mode - bubble on the right, no overlay */
.tutorial-bubble-observe {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(112, 192, 89, 0.3);
    border: 2px solid rgba(112, 192, 89, 0.5);
}

.tutorial-bubble-header {
    background: linear-gradient(105.23deg, #70C059 0%, #72CAC8 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-bubble-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.tutorial-bubble-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.tutorial-bubble-close:hover {
    opacity: 1;
}

.tutorial-bubble-content {
    padding: 20px;
}

.tutorial-bubble-content p {
    margin: 0 0 8px 0;
    color: #455a64;
    line-height: 1.6;
    font-size: 14px;
}

/* Action hint - instruction for user interaction */
.tutorial-action-hint {
    margin-top: 12px;
    padding: 10px 14px;
    background: linear-gradient(105.23deg, rgba(112, 192, 89, 0.1) 0%, rgba(114, 202, 200, 0.1) 100%);
    border-left: 3px solid #70C059;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    font-weight: 500;
    color: #2e7d32;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tutorial-action-hint::before {
    content: '\f0a4'; /* Font Awesome hand pointer */
    font-family: 'Font Awesome 5 Free', 'FontAwesome', sans-serif;
    font-weight: 900;
    font-size: 14px;
}

/* Waiting indicator when expecting user action */
.tutorial-waiting-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #70C059;
    margin-left: auto;
}

.tutorial-waiting-indicator .dot {
    width: 6px;
    height: 6px;
    background-color: #70C059;
    border-radius: 50%;
    animation: tutorial-waiting-pulse 1.4s infinite ease-in-out both;
}

.tutorial-waiting-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.tutorial-waiting-indicator .dot:nth-child(2) { animation-delay: -0.16s; }
.tutorial-waiting-indicator .dot:nth-child(3) { animation-delay: 0s; }

@keyframes tutorial-waiting-pulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.tutorial-bubble-footer {
    padding: 16px 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Step indicators */
.tutorial-step-indicators {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tutorial-step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #e9ecef;
    transition: all 0.2s;
}

.tutorial-step-dot.active {
    background: linear-gradient(105.23deg, #70C059 0%, #72CAC8 100%);
    transform: scale(1.3);
}

.tutorial-step-dot.completed {
    background-color: #70C059;
}

/* Navigation buttons */
.tutorial-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tutorial-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tutorial-btn-primary {
    background: linear-gradient(105.23deg, #70C059 0%, #72CAC8 100%);
    color: white;
    border: none;
}

.tutorial-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(112, 192, 89, 0.4);
}

.tutorial-btn-secondary {
    background: transparent;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.tutorial-btn-secondary:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
}

.tutorial-btn-link {
    background: transparent;
    border: none;
    color: #6c757d;
    text-decoration: underline;
    padding: 8px 12px;
}

.tutorial-btn-link:hover {
    color: #495057;
}

/* Skip this feature button */
.tutorial-btn-skip-feature {
    background: transparent;
    color: #e67e22;
    border: 1px solid #e67e22;
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.tutorial-btn-skip-feature:hover {
    background-color: #e67e22;
    color: white;
}

/* Arrow pointing to target */
.tutorial-arrow {
    position: absolute;
    width: 0;
    height: 0;
}

.tutorial-arrow.top {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 12px solid white;
}

.tutorial-arrow.bottom {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid white;
}

.tutorial-arrow.left {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 12px solid white;
}

.tutorial-arrow.right {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 12px solid white;
}

/* Step counter */
.tutorial-step-counter {
    font-size: 12px;
    color: #6c757d;
    margin-left: 8px;
}

/* Mobile responsiveness */
@media (max-width: 576px) {
    .tutorial-bubble {
        max-width: calc(100vw - 40px);
        min-width: auto;
        margin: 0 20px;
    }

    .tutorial-bubble-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .tutorial-step-indicators {
        justify-content: center;
        margin-bottom: 10px;
    }

    .tutorial-actions {
        justify-content: center;
    }
}

/* Hidden state */
.tutorial-hidden {
    display: none !important;
    box-shadow: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* =====================================================
   TUTORIAL ACTIVE STATE - Raise sidebar and targets
   ===================================================== */

/* When tutorial is active, raise sidebar above overlay but keep it in normal document flow.
   Using position:relative instead of fixed preserves the flex layout. */
body.tutorial-active #sidebar {
    position: relative;
    z-index: 10004 !important;
}

/* Ensure sidebar menu items are clickable during tutorial */
body.tutorial-active #sidebar ul li {
    position: relative;
    z-index: 10005;
}

body.tutorial-active #sidebar ul li a {
    position: relative;
    z-index: 10005;
}

/* Highlighted tutorial target - appears above overlay */
.tutorial-target-highlight {
    position: relative !important;
    z-index: 10006 !important;
    pointer-events: auto !important;
    box-shadow: 0 0 0 4px rgba(112, 192, 89, 0.8), 0 0 20px rgba(112, 192, 89, 0.5) !important;
    border-radius: 4px;
    animation: tutorial-target-pulse 1.5s infinite;
    background-color: inherit;
}

/* Floating clone - exact copy of target positioned above overlay */
.tutorial-floating-clone {
    box-shadow: 0 0 0 4px rgba(112, 192, 89, 0.8), 0 0 30px rgba(112, 192, 89, 0.6) !important;
    animation: tutorial-target-pulse 1.5s infinite;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    z-index: 99999 !important; /* Ensure it's above everything */
    pointer-events: auto !important;
    cursor: pointer !important;
    user-select: none;
}

/* Prevent children from stealing clicks */
.tutorial-floating-clone * {
    pointer-events: none !important;
}

.tutorial-floating-clone:hover {
    transform: scale(1.02);
    box-shadow: 0 0 0 5px rgba(112, 192, 89, 1), 0 0 40px rgba(112, 192, 89, 0.8) !important;
}

.tutorial-floating-clone:active {
    transform: scale(0.98) !important;
    box-shadow: 0 0 0 6px rgba(112, 192, 89, 1), 0 0 50px rgba(112, 192, 89, 1) !important;
}

@keyframes tutorial-target-pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(112, 192, 89, 0.8), 0 0 20px rgba(112, 192, 89, 0.5);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(112, 192, 89, 1), 0 0 35px rgba(112, 192, 89, 0.8);
    }
}

/* Make sure buttons and links in the content area are accessible */
body.tutorial-active #content {
    position: relative;
    z-index: 1;
}

/* Establish stacking context for wrapper */
body.tutorial-active #wrapper {
    position: relative;
    z-index: 1;
}

body.tutorial-active #content .btn,
body.tutorial-active #content #Add,
body.tutorial-active .header-notification {
    position: relative;
}

/* =====================================================
   TUTORIAL HELP FAB (Floating Action Button)
   ===================================================== */

.tutorial-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #70C059 0%, #72CAC8 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(112, 192, 89, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tutorial-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(112, 192, 89, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tutorial-fab:active {
    transform: scale(0.95);
}

.tutorial-fab-icon {
    color: white;
    font-size: 24px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.tutorial-fab.active .tutorial-fab-icon {
    transform: rotate(45deg);
}

/* =====================================================
   TUTORIAL CHAPTER MENU
   ===================================================== */

.tutorial-chapter-menu {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 320px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 9998;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.tutorial-chapter-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.tutorial-chapter-header {
    background: linear-gradient(135deg, #70C059 0%, #72CAC8 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tutorial-chapter-header-icon {
    font-size: 20px;
}

.tutorial-chapter-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.tutorial-chapter-list {
    max-height: calc(100vh - 240px);
    overflow-y: auto;
    padding: 8px 0;
}

/* =====================================================
   TUTORIAL CHAPTER ITEMS
   ===================================================== */

.tutorial-chapter-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 20px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f0f0f0;
}

.tutorial-chapter-item:last-child {
    border-bottom: none;
}

.tutorial-chapter-item:hover {
    background-color: rgba(112, 192, 89, 0.08);
}

.tutorial-chapter-item:active {
    background-color: rgba(112, 192, 89, 0.15);
}

.tutorial-chapter-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(112, 192, 89, 0.15) 0%, rgba(114, 202, 200, 0.15) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #70C059;
    font-size: 18px;
}

.tutorial-chapter-content {
    flex: 1;
    min-width: 0;
}

.tutorial-chapter-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tutorial-chapter-description {
    font-size: 12px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.tutorial-chapter-checkmark {
    color: #70C059;
    font-size: 14px;
}

.tutorial-chapter-item.completed .tutorial-chapter-icon {
    background: linear-gradient(135deg, #70C059 0%, #72CAC8 100%);
    color: white;
}

/* Start full tutorial link at bottom */
.tutorial-chapter-footer {
    padding: 12px 20px;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.tutorial-start-full {
    color: #70C059;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s ease;
}

.tutorial-start-full:hover {
    color: #5aa347;
    text-decoration: underline;
}

/* =====================================================
   MOBILE RESPONSIVE - FAB & CHAPTER MENU
   ===================================================== */

@media (max-width: 576px) {
    .tutorial-fab {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .tutorial-fab-icon {
        font-size: 20px;
    }

    .tutorial-chapter-menu {
        bottom: 76px;
        right: 16px;
        left: 16px;
        width: auto;
        max-height: calc(100vh - 120px);
    }

    .tutorial-chapter-item {
        padding: 12px 16px;
    }

    .tutorial-chapter-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}
