/* --- MERCADO EDIT MODAL FIXES (Extracted from functions.php) --- */

/* 1. Global Reset for Broken Plugin Styles */
/* Force clean visual state */
.rtwmer_product_container {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
}

.rtwmer_mercado_main_body {
    margin: 0 !important;
}

.rtwmer_modal .rtwmer-modal-content,
.rtwmer_card {
    background-color: #fff !important;
}

/* 2. Hide Unwanted Table Columns */
/* 1=Check, 6=Stock, 9=Type */
#table_id thead th:nth-child(1),
#table_id tbody td:nth-child(1),
#table_id thead th:nth-child(6),
#table_id tbody td:nth-child(6),
#table_id thead th:nth-child(9),
#table_id tbody td:nth-child(9) {
    display: none !important;
}

/* 3. NUCLEAR MODAL FIXES (Z-Index, Overlay, Centering) */
.rtwmer_modal {
    z-index: 9999 !important;
    /* Lower safe value */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 20px !important;

    /* Flexbox Layout Engine for Centering */
    display: none;
    justify-content: center !important;
    align-items: center !important;
    overflow: hidden !important;
}

/* When forced visible */
.rtwmer_modal[style*="display: block"],
.rtwmer_modal.rtwmer-modal-open {
    display: flex !important;
}

.rtwmer_modal .rtwmer-modal-dialog {
    position: relative !important;
    margin: auto !important;
    width: 90% !important;
    max-width: 900px !important;

    /* FIX: Ensure it doesn't look like a full page */
    height: auto !important;
    max-height: 85vh !important;
    /* Cap height to look like popup */
    overflow-y: auto !important;

    background: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5) !important;

    /* Reset offsets */
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
}

/* 4. Remove "Blue Background of Death" */
.rtwmer_product_container,
.rtwmer_form_group,
.rtwmer_modal,
.rtwmer-modal-body,
.rtwmer_order_process,
.rtwmer_cards {
    background: transparent !important;
}

/* 5. Flexbox Layout for Form Columns */
.rtwmer-modal-body .rtwmer-row,
.rtwmer-add-product-div .rtwmer-row {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    justify-content: space-between !important;
}

.rtwmer-image-add-wrapper {
    width: 30% !important;
    min-width: 200px;
    margin-bottom: 20px;
    margin-right: 0 !important;
}

.rtwmer-upper-input-fields {
    width: 65% !important;
    min-width: 320px;
    flex-grow: 1;
    float: none !important;
    margin: 0 !important;
}

/* 6. Margins & Spacing */
.rtwmer_card_body {
    padding: 20px !important;
}

.rtwmer_card {
    margin-bottom: 20px !important;
    background-color: #fff !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

/* 7. Label Visibility Fixes & Text Colors */
.mdc-floating-label,
.rtwmer_form_field_label {
    color: #444 !important;
    z-index: 10 !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

/* FIX: Ensure prefixes, suffixes, and dollar signs are visible (not white) */
.rtwmer-doller-box,
.input-group-text,
.rtwmer_card_body span,
.rtwmer_card_header,
.rtwmer_card h3,
.rtwmer_card h4,
.rtwmer_card_body div:not(.rtwmer_form_field_label):not(.mdc-floating-label):not(.mdc-notched-outline__notch) {
    color: #333 !important;
}

/* FIX: Close Button Visibility */
.rtwmer_close_product_modal,
.rtwmer-modal-close {
    color: #333 !important;
    /* Force text/icon color */
    z-index: 2147483647 !important;
    /* Above everything */
    opacity: 1 !important;
    display: block !important;
    position: absolute !important;
    /* Ensure it stays in corner if flex fails */
    right: 15px !important;
    top: 15px !important;
    cursor: pointer !important;
    font-size: 24px !important;
    /* Ensure icon is big enough */
}

/* --- NEW FIXES (Layout, Table, Upload) --- */

/* 1. HIDE Unwanted .mdl-grid (Filters/Search) SAFE MODE */
/* Using display:none broke the JS. Switching to visibility:hidden */
#table_id_length,
#table_id_filter,
.rtwmer-body .mdl-grid:has(#table_id_length),
.rtwmer-body .mdl-grid .mdl-cell:has(#table_id_length) {
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    position: absolute !important;
    z-index: -10 !important;
    opacity: 0 !important;
}

/* Fallback */
.dataTables_length,
.dataTables_filter {
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
}

/* 2. Fix Container Margins/Paddings & WIDTH */
/* Force 100% width on all parents */
html body .ihc-ap-wrap,
html body .ihc-ap-theme-1 .ihc-ap-wrap,
html body .ihc-ap-theme-2 .ihc-ap-wrap,
html body .ihc-ap-theme-4 .ihc-ap-wrap,
.rtwmer-body,
.rtwmer_product_container,
.rtwmer_table,
.rtwmer-table,
#table_id_wrapper {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* 3. Force Table Width */
#table_id {
    width: 100% !important;
    min-width: 100% !important;
    /* Force expansion */
    table-layout: fixed;
    /* Optional: helps with responsiveness */
}

/* 4. FIX UPLOAD BUTTON Z-INDEX */
/* Modal is 9999. Media Modal needs to be 10000+ */
.media-modal,
.media-modal-backdrop,
.image-editor-modal,
.image-editor-modal-backdrop {
    z-index: 100000 !important;
}

/* Also fix specific select2 dropdowns if they pop under */
.select2-container {
    z-index: 10001 !important;
}


/* 5. LOADING STATE & RED BOX FIX */
/* Hide the red error box that appears on load if empty */
.alert-error,
.rtwmer-alert-error,
div.alert-error {
    display: none !important;
}

/* Better Loading Spinner */
.dataTables_processing {
    display: none !important;
    /* Move to custom loader */
}

/* Custom Loader Container */
#rtwmer-custom-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    /* Fallback height */
    width: 100%;
    background: #fff;
    z-index: 50;
    position: relative;
    color: #666;
    flex-direction: column;
    gap: 15px;
}

/* Spinner Animation */
.rtwmer-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    /* Blue spin */
    border-radius: 50%;
    animation: rtwmer-spin 1s linear infinite;
}

@keyframes rtwmer-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Hide table initially BY DEFAULT to prevent flash */
.rtwmer-table,
#table_id_wrapper,
.rtwmer_table {
    opacity: 0;
    visibility: hidden;
    height: 0;
    overflow: hidden;
    transition: opacity 0.5s ease;
}

/* Helper class to show it via JS */
.rtwmer-table-visible,
#table_id_wrapper.rtwmer-table-visible {
    opacity: 1 !important;
    visibility: visible !important;
    height: auto !important;
    overflow: visible !important;
    display: block !important;
}

/* Custom Loader Container */
#rtwmer-custom-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    width: 100%;
    background: #fff;
    z-index: 50;
    position: relative;
    color: #666;
    flex-direction: column;
    gap: 15px;
}

/* Recorrect specific inputs that might need it */
.rtwmer-doller-box {
    color: #555 !important;
    font-weight: 500;
}

.mdc-notched-outline__notch {
    /* border-top: none !important; */
    /* Comentado pois pode ser necessario para o estilo do input funcionar */
}

/* 8. HIDE PRODUCT GALLERY (CSS Backup) */
.rtwmer_add_gallerty_wrapper,
.rtwmer_gallery_box,
.rtwmer-product-gallery {
    display: none !important;
}

/* 9. Z-Index for Select2 */
.select2-container {
    z-index: 2147483647 !important;
}

/* 10. Responsive Breakpoint */
@media (max-width: 1024px) {

    .rtwmer-modal-body .rtwmer-row,
    .rtwmer-add-product-div .rtwmer-row {
        display: block !important;
    }

    .rtwmer-image-add-wrapper,
    .rtwmer-upper-input-fields {
        width: 100% !important;
        margin-bottom: 20px !important;
    }
}

/* 11. PRICE DISPLAY FIX: Force Strikethrough Visibility */
/* Solves issue where regular price is hidden/missing on frontend */
.woocommerce-Price-amount del,
.price del,
del .woocommerce-Price-amount,
p.price del,
span.price del {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    text-decoration: line-through !important;
    color: #ACACAC !important; /* Muted gray for contrast */
    margin-right: 8px !important;
    font-size: 0.9em !important;
}

/* Ensure the INS (Sale Price) is distinct */
.woocommerce-Price-amount ins,
.price ins,
p.price ins,
span.price ins {
    text-decoration: none !important;
    font-weight: bold !important;
    color: #2ea3f2 !important; /* Keep blueish theme color */
}

/* --- ADDED BY ANTIGRAVITY: HIDE SPECIFIC PRODUCT EDIT FIELDS (USER REQUEST) --- */
.rtwmer-short_description,
.rtwmer_inventory_box,
.rtwmer_downloadable_box,
.rtwmer_other_options_fields,
#rtwmer_schedule_button,
.rtwmer-product_buttons.Schedule {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}