/* ========================================
   Help Tour – FAB & Driver.js Styling
   ========================================
   Floating action button for launching
   interactive help tours via Driver.js.
   Matches the Styleguide6 / PLIQ palette.
   ======================================== */

/* ============================================
   1. CSS Custom Properties
   ============================================ */
:root {
    /* Help Tour colors – inherit from active theme */
    --ht-primary:        var(--sg-primary, #feafe4);
    --ht-primary-dark:   var(--sg-primary-dark, #c97f8e);
    --ht-primary-light:  var(--sg-primary-light, #f8c8e8);
    --ht-accent:         var(--sg-accent, #FFD700);
    --ht-text:           var(--sg-text, #333333);
    --ht-text-light:     var(--sg-text-light, #666666);
    --ht-text-muted:     var(--sg-text-muted, #999999);
    --ht-bg:             var(--sg-background, #FFFFFF);

    /* Fallback for PLIQ theme */
    --ht-fallback-primary:    var(--pliq-primary, #C6519F);
    --ht-fallback-primary-lt: var(--pliq-primary-light, #E8A8CC);

    /* FAB sizing */
    --ht-fab-size: 56px;
    --ht-fab-offset: 24px;

    /* Menu sizing */
    --ht-menu-width: 280px;
    --ht-menu-max-height: 320px;
    --ht-menu-border-radius: 12px;

    /* Shadows */
    --ht-fab-shadow: 0 4px 14px rgba(198, 81, 159, 0.25);
    --ht-fab-shadow-hover: 0 6px 20px rgba(198, 81, 159, 0.35);
    --ht-menu-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);

    /* Transitions */
    --ht-transition: all 0.3s ease;
    --ht-transition-fast: all 0.2s ease-in-out;

    /* z-index: below Driver.js overlay (9999+) */
    --ht-z-fab: 9998;
    --ht-z-menu: 9997;
}

/* ============================================
   2. FAB Button
   ============================================ */
.ht-fab {
    position: fixed;
    bottom: var(--ht-fab-offset);
    right: var(--ht-fab-offset);
    z-index: var(--ht-z-fab);
    width: var(--ht-fab-size);
    height: var(--ht-fab-size);
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ht-primary) 0%, var(--ht-primary-dark) 100%);
    color: var(--ht-bg);
    font-size: 22px;
    cursor: pointer;
    box-shadow: var(--ht-fab-shadow);
    transition: var(--ht-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    animation: ht-pulse 3s ease-in-out infinite;
}

.ht-fab:hover {
    transform: scale(1.08);
    box-shadow: var(--ht-fab-shadow-hover);
    animation: none;
}

.ht-fab:active {
    transform: scale(0.96);
}

.ht-fab:focus-visible {
    outline: 3px solid var(--ht-accent);
    outline-offset: 3px;
}

.ht-fab .fab-icon {
    line-height: 1;
    pointer-events: none;
}

/* Pulse animation – subtle attention grabber */
@keyframes ht-pulse {
    0%, 100% {
        box-shadow: var(--ht-fab-shadow);
    }
    50% {
        box-shadow: 0 4px 14px rgba(198, 81, 159, 0.45),
                    0 0 0 8px rgba(254, 175, 228, 0.15);
    }
}

/* Stop pulse after first interaction */
.ht-fab.ht-interacted {
    animation: none;
}

/* ============================================
   3. FAB Menu (dropdown)
   ============================================ */
.ht-fab-menu {
    position: fixed;
    bottom: calc(var(--ht-fab-offset) + var(--ht-fab-size) + 12px);
    right: var(--ht-fab-offset);
    z-index: var(--ht-z-menu);
    width: var(--ht-menu-width);
    max-height: var(--ht-menu-max-height);
    background: var(--ht-bg);
    border-radius: var(--ht-menu-border-radius);
    box-shadow: var(--ht-menu-shadow);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.96);
    transition: var(--ht-transition);
}

.ht-fab-menu.ht-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Menu header */
.ht-menu-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--ht-primary-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ht-menu-header h3 {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--ht-text);
    line-height: 1.3;
}

.ht-menu-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--ht-text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--ht-transition-fast);
    line-height: 1;
}

.ht-menu-close:hover {
    color: var(--ht-text);
    background: var(--ht-primary-light);
}

/* Tour list */
.ht-tour-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    max-height: calc(var(--ht-menu-max-height) - 52px);
    overflow-y: auto;
    overflow-x: hidden;
}

.ht-tour-list::-webkit-scrollbar {
    width: 6px;
}

.ht-tour-list::-webkit-scrollbar-track {
    background: transparent;
}

.ht-tour-list::-webkit-scrollbar-thumb {
    background: var(--ht-primary-light);
    border-radius: 3px;
}

.ht-tour-list::-webkit-scrollbar-thumb:hover {
    background: var(--ht-primary);
}

/* Tour item */
.ht-tour-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--ht-transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    color: var(--ht-text);
}

.ht-tour-item:hover {
    background: var(--ht-primary-light);
}

.ht-tour-item:focus-visible {
    outline: 2px solid var(--ht-primary);
    outline-offset: -2px;
}

/* Completed tour item */
.ht-tour-item.ht-completed {
    background: rgba(40, 167, 69, 0.06);
}

.ht-tour-item.ht-completed:hover {
    background: rgba(40, 167, 69, 0.12);
}

.ht-tour-icon.ht-completed {
    color: #28a745 !important;
}

/* Tour item icon area */
.ht-tour-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 14px;
    color: var(--ht-primary-dark);
}

.ht-tour-icon.ht-completed {
    color: #5cb85c;
}

/* Tour item text */
.ht-tour-text {
    flex: 1;
    min-width: 0;
}

.ht-tour-title {
    font-weight: 600;
    line-height: 1.3;
}

.ht-tour-desc {
    font-size: 12px;
    color: var(--ht-text-muted);
    line-height: 1.3;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Completed badge */
.ht-tour-badge {
    flex-shrink: 0;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(92, 184, 92, 0.12);
    color: #5cb85c;
    font-weight: 600;
}

/* Empty state */
.ht-tour-empty {
    padding: 20px 16px;
    text-align: center;
    color: var(--ht-text-muted);
    font-size: 13px;
    font-style: italic;
}

/* ============================================
   4. Driver.js Overlay Customizations
   ============================================ */

/* Main overlay background */
.driver-overlay {
    background: rgba(47, 48, 52, 0.55) !important;
}

/* Popover container */
.driver-popover {
    background: var(--ht-bg) !important;
    border-radius: var(--ht-menu-border-radius) !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18) !important;
    padding: 0 !important;
    max-width: 480px !important;
    font-family: 'Open Sans', sans-serif !important;
}

/* Popover header */
.driver-popover .driver-popover-title {
    font-family: 'Montserrat', sans-serif !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--ht-text) !important;
    padding: 28px 32px 0 32px !important;
    margin-bottom: 0 !important;
    line-height: 1.3 !important;
}

/* Popover description */
.driver-popover .driver-popover-description {
    font-size: 14px !important;
    color: var(--ht-text-light) !important;
    line-height: 1.6 !important;
    padding: 8px 32px 0 32px !important;
    margin-bottom: 0 !important;
}

/* Popover footer (button bar) */
.driver-popover .driver-popover-footer {
    margin-top: 20px !important;
    padding: 16px 32px 20px 32px !important;
    border-top: 1px solid var(--ht-primary-light) !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between !important;
    gap: 8px;
}

/* Step indicator */
.driver-popover .driver-popover-footer .driver-popover-progress {
    font-size: 13px !important;
    color: var(--ht-text-muted) !important;
    font-weight: 500 !important;
}

/* Navigation buttons container */
.driver-popover .driver-popover-footer .driver-popover-btn-wrapper {
    display: flex !important;
    gap: 8px !important;
}

/* Prev / Next buttons */
.driver-popover .driver-popover-footer button {
    font-family: 'Montserrat', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 8px 18px !important;
    border-radius: 8px !important;
    border: none !important;
    cursor: pointer !important;
    transition: var(--ht-transition-fast) !important;
    outline: none !important;
    line-height: 1.2 !important;
}

/* Previous button – ghost style */
.driver-popover .driver-popover-footer button.driver-prev-btn {
    background: transparent !important;
    color: var(--ht-primary-dark) !important;
    border: 1.5px solid var(--ht-primary-dark) !important;
}

.driver-popover .driver-popover-footer button.driver-prev-btn:hover {
    background: var(--ht-primary-light) !important;
}

/* Next button – filled primary */
.driver-popover .driver-popover-footer button.driver-next-btn {
    background: linear-gradient(135deg, var(--ht-primary) 0%, var(--ht-primary-dark) 100%) !important;
    color: var(--ht-bg) !important;
}

.driver-popover .driver-popover-footer button.driver-next-btn:hover {
    opacity: 0.9 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(198, 81, 159, 0.25) !important;
}

/* Last step "done" button */
.driver-popover .driver-popover-footer button.driver-last-btn {
    background: linear-gradient(135deg, #5cb85c 0%, #449d44 100%) !important;
    color: var(--ht-bg) !important;
}

.driver-popover .driver-popover-footer button.driver-last-btn:hover {
    opacity: 0.92 !important;
    transform: translateY(-1px);
}

/* Close (X) button */
.driver-popover .driver-close-btn {
    position: absolute !important;
    top: 10px !important;
    right: 12px !important;
    width: 28px !important;
    height: 28px !important;
    font-size: 20px !important;
    color: var(--ht-text-muted) !important;
    background: transparent !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    transition: var(--ht-transition-fast) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 10 !important;
    line-height: 1 !important;
}

.driver-popover .driver-close-btn:hover {
    color: var(--ht-text) !important;
    background: var(--ht-primary-light) !important;
}

.driver-popover .driver-close-btn:focus-visible {
    outline: 2px solid var(--ht-primary) !important;
    outline-offset: 2px !important;
}

/* Highlighted element border */
.driver-popover + .driver-highlighted-element,
.driver-highlighted-element {
    border-radius: 8px !important;
}

/* ============================================
   5. Responsive Adjustments
   ============================================ */
@media (max-width: 576px) {
    .ht-fab {
        --ht-fab-size: 48px;
        --ht-fab-offset: 16px;
        font-size: 18px;
    }

    .ht-fab-menu {
        --ht-menu-width: calc(100vw - 32px);
        --ht-menu-max-height: 260px;
        right: 16px;
        bottom: calc(16px + 48px + 10px);
    }

    .driver-popover {
        max-width: calc(100vw - 32px) !important;
    }

    .driver-popover .driver-popover-footer {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .driver-popover .driver-popover-footer .driver-popover-btn-wrapper {
        justify-content: stretch !important;
    }

    .driver-popover .driver-popover-footer button {
        flex: 1 !important;
        text-align: center !important;
    }
}

/* ============================================
   6. Accessibility – Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .ht-fab {
        animation: none;
    }

    .ht-fab,
    .ht-fab-menu,
    .ht-tour-item,
    .driver-popover .driver-popover-footer button {
        transition: none;
    }
}

/* ============================================
   7. Print – hide FAB
   ============================================ */
@media print {
    .ht-fab,
    .ht-fab-menu {
        display: none !important;
    }
}
