/* ============================================
   Category Display Block - Isolated Styles
   Only affects .block_categories_display
   ============================================ */

/* Chỉ áp dụng cho block này */
.block_categories_display {
    /* CSS Variables - scoped to this block */
    --catdisp-primary: #4171b0;
    --catdisp-accent: #f98012;
    --catdisp-summer: #ff9900;
    --catdisp-special: #4caf50;
    --catdisp-advanced: #2196f3;
    --catdisp-gap: 20px;
    --catdisp-radius: 8px;
    --z-badge: 10;
    --z-popup-overlay: 9998;
    --z-popup-content: 10000;
}

/* Container */
.block_categories_display .catdisp-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin-bottom: 20px;
    background: #fff;
    border-radius: var(--catdisp-radius);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    padding: 20px;
}

/* Tiêu đề nhóm khóa học */
.block_categories_display .catdisp-group-title {
    color: var(--catdisp-primary);
    font-size: 24px;
    font-weight: 600;
    margin: 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--catdisp-accent);
    text-align: center;
    text-transform: uppercase;
    position: relative;
}

.block_categories_display .catdisp-group-title:after {
    content: '';
    position: absolute;
    width: 80px;
    height: 4px;
    background-color: var(--catdisp-accent);
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 2px;
}

.block_categories_display .catdisp-group-section {
    margin-bottom: 40px;
}

/* Grid cho các khóa học */
.block_categories_display .catdisp-courses-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--catdisp-gap);
}

/* Tùy chỉnh cho từng loại khóa học */
.block_categories_display .catdisp-summer-courses .catdisp-course-card {
    border-top: 4px solid var(--catdisp-summer);
}

.block_categories_display .catdisp-special-courses .catdisp-course-card {
    border-top: 4px solid var(--catdisp-special);
}

.block_categories_display .catdisp-advanced-courses .catdisp-course-card {
    border-top: 4px solid var(--catdisp-advanced);
}

/* Badge tùy chỉnh theo nhóm */
.block_categories_display .catdisp-summer-badge {
    background-color: var(--catdisp-summer) !important;
}

.block_categories_display .catdisp-special-badge {
    background-color: #ff5252 !important;
}

.block_categories_display .catdisp-advanced-badge {
    background-color: var(--catdisp-advanced) !important;
}

/* Card khóa học */
.block_categories_display .catdisp-course-card {
    background-color: #fff;
    border-radius: var(--catdisp-radius);
    overflow: hidden;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    will-change: transform;
}

/* Pseudo-element for better shadow performance */
.block_categories_display .catdisp-course-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--catdisp-radius);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.block_categories_display .catdisp-course-card:hover {
    transform: translateY(-5px);
}

.block_categories_display .catdisp-course-card:hover::after {
    opacity: 1;
}

.block_categories_display .catdisp-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: #ff5252;
    color: white;
    font-weight: bold;
    padding: 5px 15px;
    border-radius: 20px;
    z-index: var(--z-badge);
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.block_categories_display .catdisp-course-image {
    height: 160px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.block_categories_display .catdisp-course-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.block_categories_display .catdisp-course-info h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

/* Tùy chỉnh icon cho mỗi loại khóa học */
.block_categories_display .catdisp-summer-courses .catdisp-features li i {
    color: var(--catdisp-summer);
}

.block_categories_display .catdisp-special-courses .catdisp-features li i {
    color: var(--catdisp-special);
}

.block_categories_display .catdisp-advanced-courses .catdisp-features li i {
    color: var(--catdisp-advanced);
}

.block_categories_display .catdisp-features {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    flex-grow: 1;
}

.block_categories_display .catdisp-features li {
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    font-size: 12px;
    color: #444;
    line-height: 1.3;
}

.block_categories_display .catdisp-features li i {
    margin-right: 6px;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 2px;
}

.block_categories_display .catdisp-course-actions {
    display: flex;
    gap: 8px;
}

/* Tùy chỉnh nút theo từng loại khóa học */
.block_categories_display .catdisp-summer-courses .catdisp-enroll-btn {
    background-color: var(--catdisp-summer);
}

.block_categories_display .catdisp-summer-courses .catdisp-enroll-btn:hover {
    background-color: #e68a00;
}

.block_categories_display .catdisp-special-courses .catdisp-enroll-btn {
    background-color: var(--catdisp-special);
}

.block_categories_display .catdisp-special-courses .catdisp-enroll-btn:hover {
    background-color: #3d8b40;
}

.block_categories_display .catdisp-advanced-courses .catdisp-enroll-btn {
    background-color: var(--catdisp-advanced);
}

.block_categories_display .catdisp-advanced-courses .catdisp-enroll-btn:hover {
    background-color: #0b7dda;
}

.block_categories_display .catdisp-view-btn,
.block_categories_display .catdisp-enroll-btn {
    padding: 8px;
    text-align: center;
    border-radius: 4px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 12px;
    flex: 1;
    display: inline-block;
}

.block_categories_display .catdisp-view-btn {
    background-color: #f2f2f2;
    color: #333;
    border: 1px solid #ddd;
}

.block_categories_display .catdisp-view-btn:hover {
    background-color: #e0e0e0;
    text-decoration: none;
}

.block_categories_display .catdisp-enroll-btn {
    color: white !important;
    text-transform: uppercase;
    font-weight: bold;
    border: none;
}

/* Popup - KHÔNG dùng selector chung */
.block_categories_display .catdisp-popup,
.block_categories_display .enrollment-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: var(--z-popup-overlay);
    overflow: auto;
}

.block_categories_display .catdisp-popup.active,
.block_categories_display .enrollment-popup.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.block_categories_display .catdisp-popup-content,
.block_categories_display .enrollment-popup-content {
    position: relative;
    background-color: #fff;
    max-width: 500px;
    width: 90%;
    border-radius: var(--catdisp-radius);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    padding: 20px;
    margin: 20px auto;
    z-index: var(--z-popup-content);
}

.block_categories_display .catdisp-close-popup,
.block_categories_display .close-popup {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
    background: none;
    border: none;
}

.block_categories_display .catdisp-close-popup:hover,
.block_categories_display .close-popup:hover {
    color: #333;
}

.block_categories_display .catdisp-popup h3,
.block_categories_display .enrollment-popup h3 {
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    color: var(--catdisp-primary);
    font-size: 20px;
    text-align: center;
}

/* Form groups - scoped */
.block_categories_display .catdisp-form-group,
.block_categories_display .form-group {
    margin-bottom: 15px;
}

.block_categories_display .catdisp-form-group label,
.block_categories_display .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.block_categories_display .catdisp-form-group input,
.block_categories_display .catdisp-form-group select,
.block_categories_display .catdisp-form-group textarea,
.block_categories_display .form-group input,
.block_categories_display .form-group select,
.block_categories_display .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 15px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.block_categories_display .catdisp-form-group input:focus,
.block_categories_display .catdisp-form-group select:focus,
.block_categories_display .catdisp-form-group textarea:focus,
.block_categories_display .form-group input:focus,
.block_categories_display .form-group select:focus,
.block_categories_display .form-group textarea:focus {
    border-color: var(--catdisp-primary);
    outline: none;
}

.block_categories_display .catdisp-form-hint,
.block_categories_display .form-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #777;
}

.block_categories_display .catdisp-required,
.block_categories_display .required {
    color: #e74c3c;
}

.block_categories_display .catdisp-form-actions,
.block_categories_display .form-actions {
    margin-top: 20px;
    text-align: center;
}

.block_categories_display .catdisp-submit-btn,
.block_categories_display .submit-btn {
    background-color: var(--catdisp-special);
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.block_categories_display .catdisp-submit-btn:hover,
.block_categories_display .submit-btn:hover {
    background-color: #3d8b40;
}

.block_categories_display .catdisp-success-message,
.block_categories_display .success-message {
    text-align: center;
    padding: 20px;
    color: #2ecc71;
}

.block_categories_display .catdisp-success-message i,
.block_categories_display .success-message i {
    font-size: 50px;
    margin-bottom: 10px;
    display: block;
}

/* CAPTCHA - scoped */
.block_categories_display .catdisp-captcha-container,
.block_categories_display .captcha-container {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.block_categories_display .catdisp-captcha-image,
.block_categories_display #captcha-image {
    border: 1px solid #ddd;
    border-radius: 4px;
    height: 50px;
}

.block_categories_display .catdisp-reload-captcha,
.block_categories_display #reload-captcha {
    background: #f2f2f2;
    border: 1px solid #ddd;
    border-radius: 4px;
    height: 50px;
    width: 50px;
    font-size: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.block_categories_display .catdisp-reload-captcha:hover,
.block_categories_display #reload-captcha:hover {
    background-color: #e0e0e0;
}

/* Responsive - scoped to block */
@media (max-width: 1200px) {
    .block_categories_display .catdisp-courses-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .block_categories_display .catdisp-courses-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .block_categories_display .catdisp-group-title {
        font-size: 20px;
    }
    
    .block_categories_display .catdisp-courses-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 576px) {
    .block_categories_display .catdisp-group-title {
        font-size: 18px;
    }
    
    .block_categories_display .catdisp-course-info h3 {
        font-size: 14px;
        height: auto;
        max-height: 40px;
    }
    
    .block_categories_display .catdisp-courses-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .block_categories_display .catdisp-course-card {
        max-width: 100%;
        margin-bottom: 10px;
    }
    
    .block_categories_display .catdisp-course-image {
        height: 140px;
    }
    
    .block_categories_display .catdisp-course-actions {
        flex-direction: column;
        gap: 5px;
    }
    
    .block_categories_display .catdisp-popup-content,
    .block_categories_display .enrollment-popup-content {
        padding: 15px;
        width: 95%;
    }
    
    .block_categories_display .catdisp-form-group label,
    .block_categories_display .form-group label {
        font-size: 14px;
    }
    
    .block_categories_display .catdisp-form-group input,
    .block_categories_display .catdisp-form-group select,
    .block_categories_display .catdisp-form-group textarea,
    .block_categories_display .form-group input,
    .block_categories_display .form-group select,
    .block_categories_display .form-group textarea {
        padding: 8px;
        font-size: 14px;
    }
    
    .block_categories_display .catdisp-submit-btn,
    .block_categories_display .submit-btn {
        padding: 10px 15px;
        font-size: 14px;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .block_categories_display .catdisp-course-card,
    .block_categories_display .catdisp-course-card::after,
    .block_categories_display .catdisp-view-btn,
    .block_categories_display .catdisp-enroll-btn {
        transition: none;
    }
}
