/* Global Overrides */
body,
body.masterstudy-theme,
body .stm-lms-wrapper,
.elementor-page body {
    background: var(--color-background) !important;
    background-attachment: fixed !important;
    /* Ensures gradient stays in place */
    color: var(--color-text) !important;
    font-family: var(--font-body) !important;
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6,
.stm-lms-course__title,
.stm_lms_courses__single--title h5,
.ms_lms_courses_archive__title h2,
.ms_lms_courses_card_item_info_title h3,
body .elementor-heading-title,
body .elementor-widget-heading .elementor-heading-title {
    font-family: var(--font-heading) !important;
    color: var(--color-text) !important;
}

/* Link colors are now handled in FINAL POLISH section with scoping */

/* MasterStudy LMS specific overrides */

/* Buttons */
.stm-lms-btn,
.btn.btn-default,
.stm_lms_load_more_courses,
.ms_lms_courses_archive__filter_actions input[type="submit"],
body .stm-lms-wrapper .btn.btn-default,
body .elementor-button {
    background-color: var(--color-primary) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: var(--shadow-glow);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    transition: var(--transition-fast);
    border-radius: 0 !important;
    padding: 12px 24px !important;
}

.stm-lms-btn:hover,
.btn.btn-default:hover,
.stm_lms_load_more_courses:hover,
.ms_lms_courses_archive__filter_actions input[type="submit"]:hover,
body .stm-lms-wrapper .btn.btn-default:hover,
body .elementor-button:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
    background-color: var(--color-primary) !important;
}

/* Classic Course Cards (Non-Elementor) */
.stm_lms_courses__single,
.stm_lms_courses__grid .stm_lms_courses__single__inner {
    background-color: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    transition: var(--transition-fast);
}

.stm_lms_courses__single:hover,
.stm_lms_courses__grid .stm_lms_courses__single__inner:hover {
    border-color: rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-5px);
}

/* Sidebar */
.stm-lms-course__sidebar {
    background-color: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    padding: var(--space-md);
}

.stm-lms-course__sidebar .widget-title {
    color: var(--color-text) !important;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-md);
}

/* Tabs */
.nav.nav-tabs {
    border-bottom: 1px solid var(--color-border) !important;
}

.nav.nav-tabs>li>a {
    color: var(--color-muted) !important;
    background-color: transparent !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
}

.nav.nav-tabs>li.active>a,
.nav.nav-tabs>li>a:hover {
    color: var(--color-primary) !important;
    background-color: transparent !important;
    border-bottom: 2px solid var(--color-primary) !important;
}

/* Inputs & Form Elements */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select,
.form-control,
.select2-container--default .select2-selection--single,
.select2-dropdown,
body .stm_lms_courses_archive__filter_options .stm-lms-styled-checkbox span {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text) !important;
}

input:focus,
textarea:focus,
select:focus,
.form-control:focus {
    border-color: var(--color-primary) !important;
    outline: none;
}

.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-results__option {
    color: var(--color-text) !important;
}

.select2-results__option--highlighted {
    background-color: var(--color-primary) !important;
    color: white !important;
}

/* Breadcrumbs */
.stm_lms_breadcrumbs {
    color: var(--color-muted) !important;
}

.stm_lms_breadcrumbs a {
    color: var(--color-muted) !important;
}

.stm_lms_breadcrumbs a:hover {
    color: var(--color-text) !important;
}

/* Pagination */
.page-numbers li a.page-numbers,
.page-numbers li span.page-numbers {
    background-color: var(--color-surface) !important;
    border-color: var(--color-border) !important;
    color: var(--color-text) !important;
}

.page-numbers li span.page-numbers.current,
.page-numbers li a.page-numbers:hover {
    background-color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: #fff !important;
}

/* Loader */
.loading:before,
.loading_v2:after {
    border-color: var(--color-primary) transparent transparent transparent !important;
}

/* =========================================
   ELEMENTOR COURSES ARCHIVE WIDGET
   ========================================= */

/* Force Transparent Backgrounds on Elementor Wrappers to avoid White Flash */
body .elementor-widget-stm-lms-courses-archive,
body .elementor-widget-stm-lms-courses-archive .elementor-widget-container,
body .elementor-widget-stm-lms-courses-archive .elementor-column-wrap,
body .elementor-widget-stm-lms-courses-archive .elementor-widget-wrap {
    background-color: transparent !important;
    background: transparent !important;
}

/* Wrapper Specificity */
body .elementor-widget-stm-lms-courses-archive .ms_lms_courses_archive {
    background-color: transparent !important;
}

/* Filter Sidebar */
body .ms_lms_courses_archive__filter {
    background-color: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    padding: var(--space-lg);
    border-radius: 0;
}

body .ms_lms_courses_archive__filter_toggle {
    color: var(--color-text) !important;
    font-family: var(--font-heading) !important;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--color-border);
    display: block;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
}

body .ms_lms_courses_archive__filter_options {
    margin-bottom: var(--space-lg);
}

/* Checkboxes & Radios in Filter */
body .ms_lms_courses_archive__filter_options label {
    color: var(--color-muted) !important;
    transition: var(--transition-fast);
}

body .ms_lms_courses_archive__filter_options label:hover {
    color: var(--color-text) !important;
}

body .ms_lms_courses_archive__filter_options .stm-lms-styled-checkbox input:checked+span:after {
    background-color: var(--color-primary) !important;
}

/* Filter Reset */
body .ms_lms_courses_archive__filter_actions_reset {
    color: var(--color-muted) !important;
    font-size: 0.9rem;
    margin-left: 10px;
    text-decoration: underline;
}

body .ms_lms_courses_archive__filter_actions_reset:hover {
    color: var(--color-primary) !important;
}

/* Elementor Course Cards */
body .ms_lms_courses_card_item_wrapper {
    background-color: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    transition: var(--transition-fast);
    padding: var(--space-lg);
}

body .ms_lms_courses_card_item:hover .ms_lms_courses_card_item_wrapper {
    background-color: var(--color-surface) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-5px);
    z-index: 2;
    position: relative;
}

body .ms_lms_courses_card_item_info_title h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    line-height: 1.3;
}

body .ms_lms_courses_card_item_info_category a {
    color: var(--color-primary) !important;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    font-weight: 600;
}

body .ms_lms_courses_card_item_info_meta {
    color: var(--color-muted) !important;
    font-size: 0.9rem;
    margin-top: var(--space-md);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-md);
}

body .ms_lms_courses_card_item_status {
    background-color: var(--color-primary) !important;
    color: white !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 0;
}

/* Price */
.ms_lms_courses_card_item_info_bottom_wrapper {
    margin-top: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ms_lms_courses_card_item_price {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text) !important;
}

/* =========================================
   AGGRESSIVE DEFAULT OVERRIDES (Blue/White Fixes)
   ========================================= */

/* Fix Blue Buttons & Links (#385bce -> Primary/Accent) */
body .stm_lms_load_more_courses,
body .stm_lms_recent_courses .stm_lms_recent_courses__all a.btn.btn-default,
body .wc-block-cart__submit-button,
body .masterstudy-theme .stm_lms_account_dropdown .dropdown button,
body .stm_product_list_widget.widget_woo_stm_style_2 li a .meta .stm_featured_product_price .price.price-free,
body .btn.btn-default.btn-icon,
body .stm-lms-logout-button:hover,
body .stm_lms_courses_grid .showing a.btn.btn-default.stm_lms_load_more_courses,
body .wc-block-checkout__actions_row .wc-block-components-checkout-place-order-button,
body .masterstudy-theme .stm-lms-wrapper .stm-load-more-courses-btn {
    background-color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: #fff !important;
}

/* Hover States for above */
body .stm_lms_load_more_courses:hover,
body .stm_lms_recent_courses .stm_lms_recent_courses__all a.btn.btn-default:hover,
body .wc-block-cart__submit-button:hover,
body .masterstudy-theme .stm_lms_account_dropdown .dropdown button:hover,
body .stm_lms_courses_grid .showing a.btn.btn-default.stm_lms_load_more_courses:hover,
body .wc-block-checkout__actions_row .wc-block-components-checkout-place-order-button:hover,
body .masterstudy-theme .stm-lms-wrapper .stm-load-more-courses-btn:hover {
    background-color: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
    color: var(--color-background) !important;
}

/* Fix Text Colors mapped to Blue */
body a,
body .stm_lms_courses__single--info_title a:hover h4,
body .stm_lms_instructor_courses__grid a:hover,
body .stm-lms-wrapper--group_header a,
body .stm_lms_course__notfound .stm_lms_courses__filter_reset:hover span,
body .message-notice a {
    color: var(--color-secondary) !important;
}

/* Fix White Backgrounds persisting in Tabs and Modals */
body .nav.nav-tabs>li.active a,
body .stm_lms_udemy_course .nav li.active a,
body .stm-lms-message.success,
body .wpcfto_radio__fake:before,
body .mnav.nav-tabs>li.active>a {
    background-color: transparent !important;
    color: var(--color-primary) !important;
}

body .nav.nav-tabs>li a {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--color-muted) !important;
    border: none !important;
    margin-right: 2px;
}

/* Fix Pagination Blue */
body .page-numbers li span.page-numbers.current,
body .page-numbers li a.page-numbers:hover,
body .elementor-container .page-numbers.stm_lms_my_course_bundles__pagination li span.page-numbers.current,
body .stm-lms-wrapper .asignments_grid__pagination .page-numbers li span.page-numbers.current {
    background-color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: white !important;
}

/* Fix Loader Colors */
body .ms_lms_loader_ {
    border-color: var(--color-primary) var(--color-primary) transparent transparent !important;
}

body .ms_lms_loader_::after,
body .ms_lms_loader_::before {
    border-color: transparent transparent var(--color-accent) var(--color-accent) !important;
}

/* =========================================
   CHECKOUT & CART PAGE FIXES
   ========================================= */

body.woocommerce-checkout .stm-lms-wrapper,
body.woocommerce-cart .stm-lms-wrapper,
body.woocommerce-page .stm-lms-wrapper {
    background-color: transparent !important;
}

/* Empty Cart Message */
body .cart-empty.woocommerce-info {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--color-text) !important;
    border-top: 3px solid var(--color-primary) !important;
}

body .cart-empty.woocommerce-info:before {
    color: var(--color-primary) !important;
}

/* Return to Shop Button */
body .woocommerce-page .return-to-shop .button {
    background-color: var(--color-primary) !important;
    color: #fff !important;
    padding: 12px 24px !important;
    border-radius: 0 !important;
}

body .woocommerce-page .return-to-shop .button:hover {
    background-color: var(--color-accent) !important;
    color: var(--color-background) !important;
}

/* =========================================
   VC MODULES SPECIFIC OVERRIDES
   ========================================= */

/* Recent Courses Filter Terms */
body .stm_lms_recent_courses__term {
    color: var(--color-muted) !important;
}

body .stm_lms_recent_courses__term.active,
body .stm_lms_recent_courses__term:hover {
    background-color: var(--color-primary) !important;
    color: #fff !important;
}

/* Courses Carousel Buttons */
body .stm_lms_courses_carousel__button:hover {
    background-color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: #fff !important;
}

body .stm_lms_courses_carousel__top a:hover {
    color: var(--color-primary) !important;
}

/* Course Categories */
body .stm_lms_courses_categories.style_1 .stm_lms_courses_category__info h4:hover {
    color: var(--color-primary) !important;
}

/* =========================================
   AGGRESSIVE FILTER & LISTING FIXES
   ========================================= */

/* Filter Sidebar - Force Transparent/Surface */
body .ms_lms_courses_archive__filter,
body .elementor-widget-stm-lms-courses-archive .ms_lms_courses_archive__filter {
    background-color: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    box-shadow: none !important;
}

/* Filter Toggle Title */
body .ms_lms_courses_archive__filter_toggle {
    background-color: transparent !important;
    color: var(--color-text) !important;
}

/* Course Listing Container */
body .ms_lms_courses_archive__content,
body .stm_lms_courses_grid {
    background-color: transparent !important;
}

/* Individual Course Cards in Listing */
body .stm_lms_courses__single,
body .stm_lms_courses__single__inner {
    background-color: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
}

body .stm_lms_courses__single:hover,
body .stm_lms_courses__single__inner:hover {
    background-color: var(--color-surface) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* Pagination Text Color */
body .page-numbers li a.page-numbers,
body .page-numbers li span.page-numbers {
    color: var(--color-text) !important;
    background-color: var(--color-surface) !important;
}

/* =========================================
   CHECKOUT & CART - DEEP FIXES
   ========================================= */

/* WooCommerce Checkout Wrapper */
body .woocommerce {
    background-color: transparent !important;
}

/* Checkout Form Fields */
body .woocommerce form .form-row input.input-text,
body .woocommerce form .form-row textarea {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--color-text) !important;
    border: 1px solid var(--color-border) !important;
}

/* Order Review / Payment Box */
body .woocommerce-checkout #order_review,
body .woocommerce-checkout #payment {
    background-color: var(--color-surface) !important;
    color: var(--color-text) !important;
    border: 1px solid var(--color-border) !important;
}

/* Payment Methods */
body #payment .payment_methods li,
body #payment .place-order {
    background-color: transparent !important;
}

body #payment .payment_box {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--color-muted) !important;
}

/* =========================================
   FINAL INSPECTION OVERRIDES
   ========================================= */

/* Filter Form - Force Transparent */
body .ms_lms_courses_archive__filter_form {
    background-color: transparent !important;
}

/* Course Card Info - Force Transparent/Surface */
body .ms_lms_courses_card_item_info,
body .ms_lms_courses_card.card-style-1 .ms_lms_courses_card_item_info {
    background-color: var(--color-surface) !important;
    border: none !important;
}

/* Sorting Label - Fix Blue Background */
body .ms_lms_courses_archive__sorting_select_label,
body .ms_lms_courses_archive__sorting.style_3 .ms_lms_courses_archive__sorting_select_label {
    background-color: transparent !important;
    color: var(--color-text) !important;
    font-weight: 600;
}

/* Ensure Sorting Dropdown matches */
body .ms_lms_courses_archive__sorting_select select {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--color-text) !important;
    border: 1px solid var(--color-border) !important;
}

/* =========================================
   FINAL POLISH: HEADER & CONTENT SCOPING
   ========================================= */

/* 1. HEADER & MENU - FORCE WHITE */
.header,
.header a,
.navigation a,
.header .logo,
.header_default a,
.stm_lms_account_dropdown a {
    color: #fff !important;
}

.header a:hover,
.navigation a:hover,
.header_default a:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* 2. CONTENT LINKS - Scoped to Main Wrapper */
/* This prevents header links from being affected */
body .stm-lms-wrapper a,
body .elementor-page a,
body .entry-content a {
    color: var(--color-text);
    /* Default text color */
    transition: var(--transition-fast);
}

body .stm-lms-wrapper a:hover,
body .elementor-page a:hover,
body .entry-content a:hover {
    color: var(--color-primary);
}

/* 3. FIX "BLUEISH TEXT" (Breadcrumbs, Meta, Widgets) */
body .stm_lms_breadcrumbs a,
body .stm_lms_breadcrumbs,
body .meta-unit,
body .meta-unit a,
body .stm_lms_course__meta,
body .stm_lms_course__meta i,
body .stm_lms_course__meta span {
    color: var(--color-muted) !important;
}

body .stm_lms_breadcrumbs a:hover,
body .meta-unit a:hover {
    color: var(--color-text) !important;
}

/* Active Breadcrumb */
body .stm_lms_breadcrumbs span.current {
    color: var(--color-text) !important;
}

/* 4. WOOCOMMERCE NOTICES & ALERTS (Fix Blue Text) */
body .woocommerce-info,
body .woocommerce-message,
body .woocommerce-error {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--color-text) !important;
    border-top-color: var(--color-primary) !important;
}

body .woocommerce-info::before,
body .woocommerce-message::before {
    color: var(--color-primary) !important;
}

body .woocommerce-info a,
body .woocommerce-message a {
    color: var(--color-text) !important;
    text-decoration: underline;
}

/* 3. CHECKOUT TOTALS & TABLE HEADERS */
body .woocommerce-checkout .shop_table thead th,
body .woocommerce-checkout .shop_table .order-total th,
body .woocommerce-checkout .shop_table .order-total td {
    color: var(--color-text) !important;
    font-weight: 600;
}

/* 4. REMOVE REMAINING BLUE FROM 'HAVE A COUPON?' */
body .woocommerce-form-coupon-toggle .showcoupon {
    color: var(--color-primary) !important;
}

/* 5. FORCE SUB-LOGO / TAGLINE VISIBILITY ON MOBILE */
@media (max-width: 768px) {

    /* Correct Selector from navbar.php */
    body .masters-sublogo {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        width: auto !important;
        position: static !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        margin-top: 5px !important;
        color: var(--color-text) !important;
        max-width: none !important;
        white-space: normal !important;
        /* Allow wrapping */
    }
}