/**
 * PinkCode LearnDash Beautifier - Profile Grid Layout
 * Transforms course list into a 4-column grid with visible progress
 * Author: Pink Code Queen - Nariman Jafari
 */

/* ========================================
   Hide Elements (Requested by User)
   ======================================== */
/* Hide Expand/Collapse Elements */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list .ld-item-list-item .ld-expand-button,
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list .ld-item-list-item .ld-expand-button-wrapper,
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list .ld-item-list-item .ld-item-details,
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list .ld-item-list-item .ld-item-components,
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list .ld-item-list-item-preview .ld-expand-button {
    display: none !important;
}

/* Hide Expanded Content Section - critical for grid layout */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item-expanded {
    display: none !important;
}

/* Hide Status Icon */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-status-icon {
    display: none !important;
}

/* Hide List Actions (Search/Expand All) */
body.pinkcode-profile-grid .learndash-wrapper .ld-section-heading .ld-item-list-actions {
    display: none !important;
}

/* ========================================
   Course Grid Container
   ======================================== */
/* Reset parent container to block so title stays on top */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list.ld-course-list,
.learndash-wrapper .ld-item-list.ld-course-list {
    display: block !important;
}

/* Apply grid only to the items container - support both class names */
/* Works with OR without body class for maximum compatibility */
body.pinkcode-profile-grid .learndash-wrapper .ld-course-list-items,
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-items,
body.pinkcode-profile-grid .learndash-wrapper #ld-main-course-list,
.learndash-wrapper .ld-item-list-items.pinkcode-grid-active,
.learndash-wrapper #ld-main-course-list.pinkcode-grid-active,
.learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-items,
.learndash-wrapper .ld-item-list.ld-course-list #ld-main-course-list {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 20px;
    padding: 10px 0;
}

/* ========================================
   Course Card Styling
   ======================================== */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item,
.learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-item.pinkcode-transformed {
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 16px;
    padding: 0;
    margin: 0 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(102, 126, 234, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item:hover,
.learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-item.pinkcode-transformed:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.3);
}

/* ========================================
   Hide Expanded Content - Works without body class
   ======================================== */
.learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-item.pinkcode-transformed .ld-item-list-item-expanded {
    display: none !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

/* ========================================
   Course Card Inner Content
   ======================================== */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-item-list-item-preview {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

/* Course Status Icon */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-status-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-status-icon.ld-status-complete {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-status-icon.ld-status-in-progress {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-status-icon svg {
    width: 14px;
    height: 14px;
    fill: #ffffff;
}

/* Course Title */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-item-name {
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
    line-height: 1.35;
    margin-bottom: 12px;
    padding: 0 12px;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-item-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-course-title {
    display: block;
    text-align: center;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item:hover .ld-item-name a {
    color: #667eea;
}

/* ========================================
   Progress Bar on Card (Visible by default)
   ======================================== */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-card-progress {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-card-progress .ld-progress {
    margin: 0;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-progress-label,
.learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-item.pinkcode-transformed .pinkcode-progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: #718096;
    gap: 10px;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-progress-status,
.learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-item.pinkcode-transformed .pinkcode-progress-status {
    flex: 1;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-progress-percentage,
.learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-item.pinkcode-transformed .pinkcode-progress-percentage {
    font-weight: 700;
    color: #667eea;
    font-size: 14px;
    flex-shrink: 0;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-progress-bar-wrapper {
    background: #e2e8f0;
    border-radius: 8px;
    height: 8px;
    overflow: hidden;
    position: relative;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-progress-bar-fill {
    height: 100%;
    border-radius: 8px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
    position: relative;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Progress Complete State */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item.course-complete .pinkcode-progress-bar-fill {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item.course-complete .pinkcode-progress-percentage {
    color: #10b981;
}

/* ========================================
   Card Footer - Course Meta
   ======================================== */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
    font-size: 11px;
    color: #a0aec0;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-card-meta .pinkcode-steps-count {
    display: flex;
    align-items: center;
    gap: 4px;
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-card-meta svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* ========================================
   Continue Button
   ======================================== */
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-continue-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px 16px;
    margin-top: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item.course-complete .pinkcode-continue-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item.course-complete .pinkcode-continue-btn:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* ========================================
   Responsive Grid - 3 Columns on Tablet
   ======================================== */
@media screen and (max-width: 1200px) {
    body.pinkcode-profile-grid .learndash-wrapper .ld-course-list-items,
    body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-items,
    body.pinkcode-profile-grid .learndash-wrapper #ld-main-course-list,
    .learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-items,
    .learndash-wrapper .ld-item-list.ld-course-list #ld-main-course-list {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 18px;
    }
}

/* ========================================
   Responsive Grid - 2 Columns on Small Tablet
   ======================================== */
@media screen and (max-width: 900px) {
    body.pinkcode-profile-grid .learndash-wrapper .ld-course-list-items,
    body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-items,
    body.pinkcode-profile-grid .learndash-wrapper #ld-main-course-list,
    .learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-items,
    .learndash-wrapper .ld-item-list.ld-course-list #ld-main-course-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }
    
    body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-item-list-item-preview {
        padding: 16px;
    }
    
    body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-item-name {
        font-size: 14px;
        line-height: 1.3;
    }
}

/* ========================================
   Responsive Grid - 1 Column on Mobile
   ======================================== */
@media screen and (max-width: 600px) {
    body.pinkcode-profile-grid .learndash-wrapper .ld-course-list-items,
    body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-items,
    body.pinkcode-profile-grid .learndash-wrapper #ld-main-course-list,
    .learndash-wrapper .ld-item-list.ld-course-list .ld-item-list-items,
    .learndash-wrapper .ld-item-list.ld-course-list #ld-main-course-list {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    
    body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-item-list-item-preview {
        padding: 15px;
    }
    
    body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .ld-item-name {
        font-size: 13px;
        line-height: 1.3;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-item .pinkcode-continue-btn {
        padding: 10px 14px;
        font-size: 12px;
    }
}

/* ========================================
   Empty State
   ======================================== */
body.pinkcode-profile-grid .learndash-wrapper .ld-course-list-items:empty::after,
body.pinkcode-profile-grid .learndash-wrapper .ld-item-list-items:empty::after,
body.pinkcode-profile-grid .learndash-wrapper #ld-main-course-list:empty::after {
    content: 'No courses enrolled yet';
    display: block;
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
    font-size: 16px;
    grid-column: 1 / -1;
    background: #f8fafc;
    border-radius: 12px;
    border: 2px dashed #e2e8f0;
}
