/**
 * Paidia Quest Progress Modal Styles
 * 
 * Modal components:
 * - Overlay and container
 * - Header with cover image, icon, title
 * - Progress section with slider
 * - Timeline of steps (completed vs incomplete)
 * - Expandable step guidance
 * - Deep-link highlighting animation
 */

/* ===== MODAL OVERLAY ===== */
.paidia-quest-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 0;
    overflow-y: auto;
}

/* Prevent body scroll when modal is open */
body.paidia-quest-modal-open {
    overflow: hidden;
}

/* ===== MODAL CONTAINER ===== */
.paidia-quest-modal-container {
    position: relative;
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    margin: 0;
    overflow-y: auto;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3), 0 8px 16px rgba(0, 0, 0, 0.2);
    animation: paidiaQuestModalFadeIn 0.3s ease-out;
}

@keyframes paidiaQuestModalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===== CLOSE BUTTON ===== */
.paidia-quest-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50% !important;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.paidia-quest-modal-close:hover {
    background: #fff;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.paidia-quest-modal-close i {
    font-size: 18px;
    color: #333;
}

/* ===== HEADER SECTION ===== */
.paidia-quest-modal-header {
    position: relative;
    min-height: 200px;
    height: auto;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border-radius: 0;
    overflow: hidden;
}

.paidia-quest-modal-cover {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.3;
}

.paidia-quest-modal-header-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
    color: #fff;
}

.paidia-quest-modal-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    backdrop-filter: blur(10px);
}

.paidia-quest-modal-icon i {
    font-size: 28px;
    color: #fff;
}

.paidia-quest-modal-title {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.paidia-quest-modal-subtitle {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

/* ===== PROGRESS SECTION ===== */
.paidia-quest-modal-progress-section {
    padding: 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.paidia-quest-modal-progress-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.paidia-quest-modal-progress-percentage {
    font-size: 36px;
    font-weight: 700;
    color: #8b5cf6;
    line-height: 1;
}

.progress-percent-value {
    font-size: 42px;
}

.paidia-quest-modal-progress-steps {
    font-size: 16px;
    color: #666;
    font-weight: 500;
}

.progress-completed-steps {
    color: #8b5cf6;
    font-weight: 700;
    font-size: 18px;
}

/* Progress Bar */
.paidia-quest-modal-progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 20px;
}

.paidia-quest-modal-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6 0%, #7c3aed 100%);
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.paidia-quest-modal-promo {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #666;
    text-align: center;
}

/* ===== STEPS SECTION ===== */
.paidia-quest-modal-steps-section {
    padding: 30px;
}

.paidia-quest-modal-section-title {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 700;
    color: #1C2E3D;
}

/* Timeline Container - Scrollable with smooth behavior */
.paidia-quest-modal-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* ===== STEP ITEM ===== */
.paidia-quest-step-item {
    background: #fff;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
    overflow: hidden;
    transition: all 0.3s ease;
    min-height: 74px; /* Ensure minimum height for header (44px icon + 30px padding) */
    flex-shrink: 0; /* CRITICAL: Prevent flex container from collapsing items */
}

.paidia-quest-step-item.step-expandable {
    cursor: pointer;
}

.paidia-quest-step-item.step-expandable:hover {
    border-color: #8b5cf6;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

/* Completed Step Styling */
.paidia-quest-step-item.step-completed {
    background: #f0fdf4;
    border-color: #86efac;
}

.paidia-quest-step-item.step-completed:hover {
    border-color: #4ade80;
}

/* Locked Step Styling (for sequential quests - future steps after next step) */
.paidia-quest-step-item.step-locked {
    position: relative;
    background: #f5f5f5;
    border-color: #d0d0d0;
    cursor: not-allowed;
    pointer-events: none;
}

.paidia-quest-step-item.step-locked .paidia-quest-step-header {
    filter: blur(4px);
    opacity: 0.6;
}

.paidia-quest-step-item.step-locked .paidia-quest-step-icon {
    background: #e0e0e0;
}

.paidia-quest-step-item.step-locked .paidia-quest-step-icon i {
    color: #999;
}

.paidia-quest-step-item.step-locked .paidia-quest-step-title,
.paidia-quest-step-item.step-locked .paidia-quest-step-number {
    color: #999;
}

.paidia-quest-step-item.step-locked .paidia-quest-step-xp {
    background: #e8e8e8;
    color: #999;
}

/* Locked step overlay with centered padlock icon */
.paidia-quest-step-item.step-locked::before {
    content: '\f023'; /* Font Awesome lock icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    color: #999;
    z-index: 10;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Highlighted Step (for deep-linking) */
.paidia-quest-step-item.step-highlighted {
    animation: paidiaStepHighlight 2s ease-out;
}

@keyframes paidiaStepHighlight {
    0%, 100% { box-shadow: 0 0 0 rgba(139, 92, 246, 0); }
    50% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0.3); }
}

/* Step Header */
.paidia-quest-step-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 0;
    position: relative;
    min-height: 74px; /* Ensure header doesn't collapse: 44px icon + 15px top/bottom padding */
}

/* Image Container (Left Side) */
.paidia-quest-step-image-container {
    flex-shrink: 0;
    width: 84px !important;
    height: 84px !important;
    min-width: 84px !important;
    min-height: 84px !important;
    position: relative;
}

.paidia-quest-step-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
}

.paidia-quest-step-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Icon fallback when no image (centered in container) */
.paidia-quest-step-image-container .paidia-quest-step-icon {
    width: 100%;
    height: 84px;
    min-width: unset;
    background: linear-gradient(135deg, #f0f0f0 0%, #e5e5e5 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.paidia-quest-step-image-container .paidia-quest-step-icon i {
    font-size: 48px;
    color: #8b5cf6;
}

.step-completed .paidia-quest-step-image-container .paidia-quest-step-icon {
    background: linear-gradient(135deg, #86efac 0%, #4ade80 100%);
}

.step-completed .paidia-quest-step-image-container .paidia-quest-step-icon i {
    color: #fff;
}

/* Content Container (Right Side) */
.paidia-quest-step-content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 12px 12px 0;
    min-width: 0; /* Allow text to wrap */
}

/* Step Icon (old - kept for backwards compatibility) */
.paidia-quest-step-header > .paidia-quest-step-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.step-completed .paidia-quest-step-header > .paidia-quest-step-icon {
    background: #86efac;
}

.paidia-quest-step-header > .paidia-quest-step-icon i {
    font-size: 20px;
    color: #666;
}

.step-completed .paidia-quest-step-header > .paidia-quest-step-icon i {
    color: #16a34a;
}

/* Step Info */
.paidia-quest-step-info {
    flex: 1;
    min-width: 0; /* Allow text truncation if needed */
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.paidia-quest-step-title {
    font-size: 18px;
    font-weight: 600;
    color: #222222;
    line-height: 1.5rem;
    letter-spacing: -0.01125rem;
}

.paidia-quest-step-title i {
    font-size: 14px;
    color: #222222;
    margin-right: 6px;
}

.step-completed .paidia-quest-step-title {
    color: #16a34a;
}

.step-completed .paidia-quest-step-title i {
    color: #16a34a;
}

/* Step XP Badge */
.paidia-quest-step-xp {
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    white-space: nowrap;
}

.step-completed .paidia-quest-step-xp {
    background: #dcfce7;
    color: #16a34a;
}

.paidia-quest-step-xp i {
    margin-right: 4px;
    font-size: 12px;
}

/* Expand Icon */
.paidia-quest-step-expand {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.step-expanded .paidia-quest-step-expand {
    transform: rotate(180deg);
}

.paidia-quest-step-expand i {
    font-size: 14px;
    color: #999;
}

/* ===== STEP GUIDANCE (EXPANDABLE CONTENT) ===== */
.paidia-quest-step-guidance {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    padding: 0;
    margin-left: 140px; /* Align with content container (120px image + 20px gap) */
    margin-right: 12px;
}

.step-expanded .paidia-quest-step-guidance {
    max-height: 1000px;
    opacity: 1;
    padding: 0 0 20px 0;
}

.paidia-quest-step-guidance p {
    margin: 0 0 12px 0;
    font-size: 16px;
    line-height: 1.5rem;
    color: #222222;
}

.paidia-quest-step-guidance ul,
.paidia-quest-step-guidance ol {
    margin: 0 0 12px 0;
    padding-left: 20px;
}

.paidia-quest-step-guidance li {
    margin-bottom: 8px;
    font-size: 16px;
    line-height: 1.5rem;
    color: #222222;
}

.paidia-quest-step-guidance strong {
    color: #8b5cf6;
    font-weight: 600;
}

.paidia-quest-step-guidance a {
    color: #8b5cf6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.paidia-quest-step-guidance a:hover {
    color: #7c3aed;
    text-decoration: underline;
}

/* ===== LOADING STATE ===== */
.paidia-quest-modal-loading {
    padding: 60px 30px;
    text-align: center;
    color: #999;
}

.paidia-quest-modal-loading i {
    font-size: 40px;
    margin-bottom: 15px;
    color: #8b5cf6;
}

.paidia-quest-modal-loading p {
    margin: 0;
    font-size: 16px;
}

/* ===== ERROR STATE ===== */
.paidia-quest-error {
    padding: 40px 20px;
    text-align: center;
    color: #ef4444;
}

.paidia-quest-error i {
    font-size: 36px;
    margin-bottom: 12px;
}

.paidia-quest-error p {
    margin: 0;
    font-size: 15px;
}

/* ===== NO STEPS STATE ===== */
.paidia-quest-no-steps {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 15px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .paidia-quest-modal-overlay {
        padding: 0;
        display: block;
    }
    
    .paidia-quest-modal-container {
        width: 100%;
        height: 100vh;
        min-height: 100vh;
        max-height: none;
        max-width: none;
        border-radius: 0;
        margin: 0;
        box-shadow: none;
    }
    
    .paidia-quest-modal-header {
        min-height: 160px;
        height: auto;
    }
    
    .paidia-quest-modal-icon {
        width: 50px;
        height: 50px;
    }
    
    .paidia-quest-modal-icon i {
        font-size: 24px;
    }
    
    .paidia-quest-modal-title {
        font-size: 22px;
    }
    
    .paidia-quest-modal-subtitle {
        font-size: 13px;
    }
    
    .paidia-quest-modal-progress-section,
    .paidia-quest-modal-steps-section {
        padding: 20px;
    }
    
    .paidia-quest-modal-progress-percentage {
        font-size: 28px;
    }
    
    .progress-percent-value {
        font-size: 34px;
    }
    
    .paidia-quest-modal-progress-steps {
        font-size: 14px;
    }
    
    .progress-completed-steps {
        font-size: 16px;
    }
    
    .paidia-quest-step-header {
        gap: 12px;
        padding: 12px;
    }
    
    .paidia-quest-step-icon {
        width: 38px;
        height: 38px;
        min-width: 38px;
    }
    
    .paidia-quest-step-icon i {
        font-size: 18px;
    }
    
    .paidia-quest-step-title {
        font-size: 14px;
    }
    
    .paidia-quest-step-xp {
        font-size: 12px;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    .paidia-quest-modal-overlay {
        padding: 0;
        display: block;
    }
    
    .paidia-quest-modal-container {
        height: 100vh;
        min-height: 100vh;
        max-height: none;
        max-width: none;
        border-radius: 0;
        margin: 0;
    }
    
    .paidia-quest-modal-close {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        top: 10px;
        right: 10px;
    }
    
    .paidia-quest-modal-close i {
        font-size: 16px;
    }
    
    .paidia-quest-modal-header {
        min-height: 140px;
        height: auto;
    }
    
    .paidia-quest-modal-title {
        font-size: 20px;
    }
    
    .paidia-quest-step-number {
        font-size: 10px;
    }
    
    .paidia-quest-step-title {
        font-size: 13px;
    }
}
