/**
 * PinkCode LearnDash Beautifier - Navigation Buttons Module
 *
 * Professional, modern styling for LearnDash navigation buttons:
 * - Mark Complete Button (green gradient)
 * - Previous Lesson Button (blue gradient)
 * - Next Lesson Button (blue gradient)
 *
 * All three buttons are styled consistently with same size, modern gradients,
 * smooth animations, and aligned in a single responsive row.
 *
 * @package PinkCodeLearnDashBeautifier
 * @version 1.2.0
 * @author Pink Code Queen - Nariman Jafari
 */

/* ==========================================================================
   NAVIGATION BUTTONS CONTAINER - COMPACT SINGLE ROW
   ========================================================================== */

/**
 * Main container - single row with centered buttons
 * Minimal padding to prevent border clipping
 */
body .learndash-wrapper .ld-content-actions,
body div.learndash-wrapper div.ld-content-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 20px 0 !important;
    padding: 2px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/**
 * Individual button wrapper - compact inline with NO padding
 * Remove wrapper padding to prevent border clipping
 */
body .learndash-wrapper .ld-content-action,
body div.learndash-wrapper div.ld-content-action {
    display: inline-flex !important;
    flex-direction: row !important;
    gap: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: initial !important;
    flex: 0 0 auto !important;
    padding: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force all button elements to exact same size - 160px × 38px */
body .learndash-wrapper .ld-content-action > a.ld-button,
body .learndash-wrapper .ld-content-action > form.sfwd-mark-complete,
body .learndash-wrapper .ld-content-action > a.ld-course-step-back {
    width: 160px !important;
    max-width: 160px !important;
    min-width: 160px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Mark Complete form styling - exact size */
body .learndash-wrapper .ld-content-action form.sfwd-mark-complete,
body div.learndash-wrapper div.ld-content-action form.sfwd-mark-complete {
    display: inline-flex !important;
    flex-direction: row !important;
    gap: 0 !important;
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

body .learndash-wrapper .ld-content-action form.sfwd-mark-complete .learndash_mark_complete_button {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Back to Course link - exact size */
body .learndash-wrapper .ld-content-action > a.ld-course-step-back {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 !important;
}

/* Empty content actions (for consistent spacing) */
.learndash-wrapper .ld-content-action.ld-empty {
    display: none !important;
}

/* ==========================================================================
   BUTTON BASE STYLES - MODERN & PROFESSIONAL
   ========================================================================== */

/**
 * Base button styling - Previous/Next Lesson buttons
 * Blue gradient with white text - PROFESSIONAL & COMPACT
 */
body .learndash-wrapper .ld-button,
body div.learndash-wrapper a.ld-button,
body.learndash-wrapper .ld-button,
body .learndash-wrapper a.ld-button {
    /* Layout & Sizing - FIXED WIDTH */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 8px 10px !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    height: 38px !important;
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    box-sizing: border-box !important;
    flex: 0 0 160px !important;
    overflow: hidden !important;
    
    /* Visual Design - Blue Gradient */
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.25) !important;
    
    /* Typography - White text on dark background */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    letter-spacing: 0.3px !important;
    text-decoration: none !important;
    color: #ffffff !important;
    white-space: nowrap !important;
    
    /* Interaction */
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Ensure text and icons are white */
body .learndash-wrapper .ld-button .ld-text,
body .learndash-wrapper .ld-button span,
body .learndash-wrapper .ld-button .ld-icon {
    color: #ffffff !important;
    font-size: 13px !important;
}

/* Previous/Next button hover state */
body .learndash-wrapper .ld-button:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35) !important;
    background: linear-gradient(135deg, #0891b2 0%, #06829e 100%) !important;
}

/* Active/pressed state */
body .learndash-wrapper .ld-button:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 6px rgba(6, 182, 212, 0.3) !important;
}

/* Focus state for accessibility */
body .learndash-wrapper .ld-button:focus,
body .learndash-wrapper .ld-button:focus-visible {
    outline: 3px solid rgba(6, 182, 212, 0.5) !important;
    outline-offset: 3px !important;
}

/* ==========================================================================
   MARK COMPLETE BUTTON - GREEN GRADIENT - COMPACT
   ========================================================================== */

/**
 * Mark Complete button - ACTIVE STATE (not yet completed)
 * Light blue with white text - clickable and inviting
 * IMPORTANT: Override disabled attribute styling unless truly completed
 */
body .learndash-wrapper .learndash_mark_complete_button,
body .learndash-wrapper #learndash_mark_complete_button,
body .learndash-wrapper .sfwd-mark-complete .learndash_mark_complete_button,
body div.learndash-wrapper input.learndash_mark_complete_button {
    /* Layout & Sizing - FIXED WIDTH */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 8px 10px !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    box-sizing: border-box !important;
    flex: 0 0 160px !important;
    overflow: hidden !important;
    
    /* Visual Design - Light Blue for Active State */
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%) !important;
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.25) !important;
    
    /* Typography - White text on blue background */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    letter-spacing: 0.3px !important;
    text-transform: none !important;
    text-decoration: none !important;
    color: #ffffff !important;
    white-space: nowrap !important;
    
    /* Interaction */
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/**
 * CRITICAL FIX: Override disabled styling for buttons that aren't truly completed
 * If button has disabled attribute but NOT the ld-status-complete class,
 * it should still be clickable (LearnDash adds disabled incorrectly sometimes)
 */
body .learndash-wrapper .learndash_mark_complete_button[disabled]:not(.ld-status-complete),
body .learndash-wrapper #learndash_mark_complete_button[disabled]:not(.ld-status-complete) {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%) !important;
    border: none !important;
    color: #ffffff !important;
    cursor: pointer !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.25) !important;
}

body .learndash-wrapper .learndash_mark_complete_button[disabled]:not(.ld-status-complete):hover,
body .learndash-wrapper #learndash_mark_complete_button[disabled]:not(.ld-status-complete):hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35) !important;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%) !important;
}

/* Mark Complete hover state - Active */
body .learndash-wrapper .learndash_mark_complete_button:hover,
body .learndash-wrapper #learndash_mark_complete_button:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35) !important;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%) !important;
}

/* Mark Complete active/pressed state */
body .learndash-wrapper .learndash_mark_complete_button:active,
body .learndash-wrapper #learndash_mark_complete_button:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.3) !important;
}

/* Mark Complete focus state */
body .learndash-wrapper .learndash_mark_complete_button:focus,
body .learndash-wrapper #learndash_mark_complete_button:focus,
body .learndash-wrapper .learndash_mark_complete_button:focus-visible,
body .learndash-wrapper #learndash_mark_complete_button:focus-visible {
    outline: 3px solid rgba(14, 165, 233, 0.5) !important;
    outline-offset: 3px !important;
}

/**
 * Mark Complete button - COMPLETED STATE
 * Green gradient with white text - shows lesson is done
 */
body .learndash-wrapper .learndash_mark_complete_button.ld-status-complete,
body .learndash-wrapper .learndash_mark_complete_button[disabled],
body .learndash-wrapper #learndash_mark_complete_button[disabled] {
    /* Green Success Gradient for completed */
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border: none !important;
    color: #ffffff !important;
    cursor: default !important;
    opacity: 1 !important;
    pointer-events: none !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25) !important;
}

/* No hover effect for completed state */
body .learndash-wrapper .learndash_mark_complete_button.ld-status-complete:hover,
body .learndash-wrapper .learndash_mark_complete_button[disabled]:hover,
body .learndash-wrapper #learndash_mark_complete_button[disabled]:hover {
    transform: none !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25) !important;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
}

/* ==========================================================================
   BACK TO COURSE LINK - OUTLINE STYLE (Secondary Button)
   ========================================================================== */

/**
 * Back to Course link - Outline style with blue border and text
 * White background with dark text for contrast
 * ULTRA-SPECIFIC: Ensures all borders (including bottom) are blue
 */
body .learndash-wrapper .ld-course-step-back,
body .learndash-wrapper a.ld-course-step-back,
body .learndash-wrapper a.ld-primary-color.ld-course-step-back {
    /* Layout & Sizing - FIXED WIDTH */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 8px 10px !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    height: 38px !important;
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    box-sizing: border-box !important;
    flex: 0 0 160px !important;
    overflow: hidden !important;
    
    /* Visual Design - Outline Style (White bg, blue border ALL SIDES) */
    background: #ffffff !important;
    border: 2px solid #0891b2 !important;
    border-top: 2px solid #0891b2 !important;
    border-right: 2px solid #0891b2 !important;
    border-bottom: 2px solid #0891b2 !important;
    border-left: 2px solid #0891b2 !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 6px rgba(8, 145, 178, 0.1) !important;
    
    /* Typography - Dark text on light background */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    letter-spacing: 0.3px !important;
    text-decoration: none !important;
    color: #0891b2 !important;
    white-space: nowrap !important;
    
    /* Interaction */
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

body .learndash-wrapper .ld-course-step-back:hover,
body .learndash-wrapper a.ld-course-step-back:hover,
body .learndash-wrapper a.ld-primary-color.ld-course-step-back:hover {
    background: #f0f9ff !important;
    border: 2px solid #06829e !important;
    border-top: 2px solid #06829e !important;
    border-right: 2px solid #06829e !important;
    border-bottom: 2px solid #06829e !important;
    border-left: 2px solid #06829e !important;
    color: #06829e !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.15) !important;
}

body .learndash-wrapper .ld-course-step-back:active,
body .learndash-wrapper a.ld-course-step-back:active,
body .learndash-wrapper a.ld-primary-color.ld-course-step-back:active {
    transform: translateY(0) !important;
    background: #e0f2fe !important;
    border: 2px solid #06829e !important;
    border-top: 2px solid #06829e !important;
    border-right: 2px solid #06829e !important;
    border-bottom: 2px solid #06829e !important;
    border-left: 2px solid #06829e !important;
}

body .learndash-wrapper .ld-course-step-back:focus,
body .learndash-wrapper .ld-course-step-back:focus-visible,
body .learndash-wrapper a.ld-course-step-back:focus,
body .learndash-wrapper a.ld-course-step-back:focus-visible {
    outline: 3px solid rgba(6, 182, 212, 0.5) !important;
    outline-offset: 3px !important;
}

/* ==========================================================================
   BUTTON ICONS & TEXT
   ========================================================================== */

/**
 * Icon styling within buttons - compact size with animations
 */
body .learndash-wrapper .ld-icon,
body .learndash-wrapper .ld-button .ld-icon,
body .learndash-wrapper a.ld-button .ld-icon {
    font-size: 14px !important;
    line-height: 1 !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: inherit !important;
    flex-shrink: 0 !important;
    width: 14px !important;
    min-width: 14px !important;
    max-width: 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Animate Previous arrow on hover */
body .learndash-wrapper .ld-button:hover .ld-icon-arrow-left {
    transform: translateX(-3px) !important;
}

/* Animate Next arrow on hover */
body .learndash-wrapper .ld-button:hover .ld-icon-arrow-right {
    transform: translateX(3px) !important;
}

/* Button text styling - Fixed to remove margins and allow proper sizing */
body .learndash-wrapper .ld-button .ld-text,
body .learndash-wrapper .learndash_mark_complete_button .ld-text,
body .learndash-wrapper span.ld-text,
body .learndash-wrapper .ld-button span.ld-text,
body .learndash-wrapper a.ld-button span.ld-text {
    display: inline-flex !important;
    align-items: center !important;
    line-height: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
    gap: 0 !important;
    flex-shrink: 1 !important;
}

/* ==========================================================================
   RESPONSIVE DESIGN - MOBILE & TABLET
   ========================================================================== */

/**
 * Tablet Layout (768px - 1024px)
 * Keep row layout but reduce spacing
 */
@media (max-width: 1024px) {
    .learndash-wrapper .ld-content-actions {
        gap: 16px !important;
    }
    
    .learndash-wrapper .ld-button,
    .learndash-wrapper .learndash_mark_complete_button {
        padding: 14px 24px !important;
        font-size: 14px !important;
        min-width: 140px !important;
    }
}

/**
 * Mobile Layout (max-width: 768px)
 * 2x2 grid with equal-sized buttons
 */
@media (max-width: 768px) {
    body .learndash-wrapper .ld-content-actions,
    body div.learndash-wrapper div.ld-content-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
        margin: 20px 0 !important;
    }

    body .learndash-wrapper .ld-content-action,
    body div.learndash-wrapper div.ld-content-action {
        width: 100% !important;
        flex: 1 1 auto !important;
    }

    body .learndash-wrapper .ld-button,
    body .learndash-wrapper .ld-course-step-back,
    body .learndash-wrapper .learndash_mark_complete_button {
        width: 100% !important;
        min-width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
        height: 40px !important;
        padding: 8px 12px !important;
        font-size: 13px !important;
        flex: 1 1 auto !important;
    }
}

/**
 * Small Mobile (max-width: 480px)
 * Keep 2x2 grid, allow text wrapping if needed
 */
@media (max-width: 480px) {
    body .learndash-wrapper .ld-content-actions,
    body div.learndash-wrapper div.ld-content-actions {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        margin: 16px 0 !important;
    }

    body .learndash-wrapper .ld-button,
    body .learndash-wrapper .ld-course-step-back,
    body .learndash-wrapper .learndash_mark_complete_button {
        white-space: normal !important;
        min-height: 40px !important;
        height: auto !important;
        padding: 10px 12px !important;
        font-size: 12px !important;
        line-height: 1.4 !important;
        width: 100% !important;
        min-width: 100% !important;
    }
    
    /* Allow text wrapping on mobile */
    body .learndash-wrapper .ld-button .ld-text,
    body .learndash-wrapper .learndash_mark_complete_button .ld-text,
    body .learndash-wrapper span.ld-text {
        white-space: normal !important;
    }
}

/* ==========================================================================
   ACCESSIBILITY & MOTION PREFERENCES
   ========================================================================== */

/**
 * Respect user's motion preferences
 * Remove animations for users who prefer reduced motion
 */
@media (prefers-reduced-motion: reduce) {
    .learndash-wrapper .ld-button,
    .learndash-wrapper .ld-course-step-back,
    .learndash-wrapper .learndash_mark_complete_button,
    .learndash-wrapper .ld-icon {
        transition: none !important;
        transform: none !important;
    }
    
    .learndash-wrapper .ld-button:hover,
    .learndash-wrapper .learndash_mark_complete_button:hover,
    .learndash-wrapper .ld-course-step-back:hover {
        transform: none !important;
    }
    
    .learndash-wrapper .ld-button:hover .ld-icon-arrow-left,
    .learndash-wrapper .ld-button:hover .ld-icon-arrow-right {
        transform: none !important;
    }
}

/**
 * High contrast mode support
 * Ensure buttons are visible in high contrast themes
 */
@media (prefers-contrast: high) {
    .learndash-wrapper .ld-button,
    .learndash-wrapper .learndash_mark_complete_button {
        border: 2px solid #ffffff !important;
    }
    
    .learndash-wrapper .ld-course-step-back {
        border-width: 3px !important;
    }
}
