/* Marketplace UI Styles */

.gpm-sticky-filters {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #f5f7fa;
    padding: 10px 0;
    margin-bottom: 25px;
    border-bottom: 1px solid #e2e6ec;
    transition: box-shadow 0.3s ease;
}

.gpm-sticky-filters.gpm-sticky-active {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.gpm-filter-form {
    /* --- Phase 2: Filter Bar Layout (CSS GRID REDESIGN) --- */
}

.gpm-filter-bar {
    margin-bottom: 20px;
    position: relative;
    z-index: 50;
    /* Ensure high stacking context */
    overflow: visible;
}

/* MAIN CONTAINER STYLING */
.gpm-filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    background: #f9f9f9;
    padding: 24px;
    border-radius: 8px;
    box-sizing: border-box;
    width: 100%;
    overflow: visible;
    /* Ensure Dropdowns not clipped */
}

.gpm-dropdown-filter {
    position: relative;
    /* Anchor for absolute dropdown */
    flex: 0 0 auto;
    /* Allow sizing based on content */
    width: auto;
}

/* DROPDOWN TRIGGER */
.gpm-dropdown-trigger {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0 14px;
    /* Slightly more padding */
    height: 42px;
    /* Fixed Height */
    font-size: 14px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: auto;
    min-width: 80px;
    /* Base min width */
    max-width: 240px;
    /* Cap width for long labels */
    box-sizing: border-box;
    white-space: nowrap;
}

.gpm-dropdown-trigger .status-text {
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.gpm-dropdown-trigger:hover {
    background-color: #fff;
    border-color: #bbb;
}

/* DROPDOWN POPUP */
/* DROPDOWN POPUP - GLOBAL PREMIUM STYLE */
.gpm-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    width: 220px;
    /* Premium Width */
    min-width: 220px;
    max-width: 220px;
    z-index: 9999;
    /* Ensure visible above everything */
    margin-top: 5px;
    padding: 16px;
    /* Premium Padding */
    box-sizing: border-box;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    /* Airy shadow */
    border-radius: 8px;
    /* Softer corners */
    border: 1px solid #e0e0e0;
    white-space: normal;
}

/* Ensure it works with EITHER class to cover both JS files */
.gpm-dropdown-filter.gpm-dropdown-open .gpm-dropdown-content,
.gpm-dropdown-filter.open .gpm-dropdown-content {
    display: block !important;
    /* Force show */
    opacity: 1;
    visibility: visible;
    top: 100%;
    /* Ensure correct positioning */
    left: 0;
}

/* ACTIONS CONTAINER (Right Aligned) */
.gpm-filter-actions-full {
    display: flex;
    justify-content: flex-end;
    /* Right align */
    gap: 12px;
    margin-left: auto;
    /* Push to right in Flexbox */
    flex: 0 0 auto;
}

/* BUTTONS */
.gpm-bulk-search-btn,
.gpm-reset-filters {
    height: 42px;
    padding: 0 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    /* Remove auto margins */
}

.gpm-bulk-search-btn {
    background: #ff6b35;
    color: #fff;
}

.gpm-bulk-search-btn:hover {
    background: #e55a2b;
}

.gpm-reset-filters {
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
    padding: 0 16px;
}

.gpm-reset-filters:hover {
    border-color: #ff6b35;
    color: #ff6b35;
}

/* AS/DA/DR Specifics - Premium Airy Redesign */
.gpm-dropdown-filter[data-key="as"] .gpm-dropdown-content,
.gpm-dropdown-filter[data-key="da"] .gpm-dropdown-content,
.gpm-dropdown-filter[data-key="dr"] .gpm-dropdown-content {
    width: 220px;
    /* Comfortable Premium Width */
    min-width: 220px;
    max-width: 220px;
    padding: 16px;
    /* Generous padding */
    border-radius: 8px;
    /* Softer corners */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    /* Airy shadow */
    border: 1px solid #e0e0e0;
}

/* Specific List Reset for AS/DA/DR to remove default padding */
.gpm-dropdown-filter[data-key="as"] .gpm-presets-list,
.gpm-dropdown-filter[data-key="da"] .gpm-presets-list,
.gpm-dropdown-filter[data-key="dr"] .gpm-presets-list {
    padding: 0;
    margin: 0;
    border: none;
}

/* Radio Option Styling */
.gpm-dropdown-filter[data-key="as"] .gpm-preset-option,
.gpm-dropdown-filter[data-key="da"] .gpm-preset-option,
.gpm-dropdown-filter[data-key="dr"] .gpm-preset-option {
    display: flex;
    align-items: center;
    justify-content: flex-start !important;
    /* Force left align */
    gap: 5px;
    /* Closer radio and text */
    padding: 6px 0;
    /* Comfortable click area */
    margin: 0;
    font-size: 14px;
    /* Readable text */
    color: #444;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.4;
}

/* Reset Radio Margins for perfect alignment */
.gpm-dropdown-filter[data-key="as"] .gpm-preset-option input[type="radio"],
.gpm-dropdown-filter[data-key="da"] .gpm-preset-option input[type="radio"],
.gpm-dropdown-filter[data-key="dr"] .gpm-preset-option input[type="radio"] {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    /* Prevent 100% width stretch */
    flex: 0 0 auto !important;
    /* Prevent flex growth */
    vertical-align: middle;
    position: relative;
    top: -1px;
    transform: scale(1.1);
    /* Slightly larger radio for accessibility */
}

.gpm-dropdown-filter[data-key="as"] .gpm-preset-option:hover,
.gpm-dropdown-filter[data-key="da"] .gpm-preset-option:hover,
.gpm-dropdown-filter[data-key="dr"] .gpm-preset-option:hover {
    color: #000;
}

/* Custom Range Section - Specifics Removed (Now Global) */

/* PRESETS & INPUTS */
.gpm-presets-list {
    display: flex;
    flex-direction: column;
    max-height: 250px;
    overflow-y: auto;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* Generic Option Styling (Radio & Checkbox) */
.gpm-preset-option,
.gpm-presets-list label {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    /* Force left align */
    gap: 5px;
    /* Premium tight gap */
    margin-bottom: 0;
    padding: 6px 0;
    /* Comfortable click area */
    cursor: pointer;
    font-size: 14px;
    /* Premium font size */
    color: #444;
    line-height: 1.4;
}

/* Generic Checkbox/Radio Reset */
.gpm-preset-option input[type="checkbox"],
.gpm-preset-option input[type="radio"],
.gpm-presets-list label input[type="checkbox"],
.gpm-presets-list label input[type="radio"] {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    flex: 0 0 auto !important;
    vertical-align: middle;
    position: relative;
    top: -1px;
    transform: scale(1.1);
}

.gpm-presets-list label:last-child {
    margin-bottom: 0;
}

.gpm-custom-range {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    /* Premium spacing */
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    /* Subtle divider */
    gap: 8px;
    /* Open spacing */
    margin-left: 0;
    margin-right: 0;
    background: transparent;
    padding-left: 0;
    padding-right: 0;
}

.gpm-custom-range input {
    width: 48px;
    /* Comfortable premium width */
    height: 34px;
    /* Standard input height */
    padding: 0 4px;
    font-size: 13px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    -moz-appearance: textfield;
    box-sizing: border-box !important;
    /* CRITICAL FIX */
}

/* Ensure inline display */
.gpm-custom-range .sep {
    font-size: 12px;
    color: #888;
    margin: 0 2px;
}

.gpm-apply-filter {
    height: 34px;
    /* Match Input Height */
    padding: 0 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-sizing: border-box !important;
    margin-left: 0;
}

.gpm-apply-filter:hover {
    background: #f0f0f0;
    border-color: #bbb;
}

.gpm-bulk-search-btn {
    background: #ff5722;
    color: #fff;
    border: none;
    padding: 8px 15px;
    font-weight: bold;
    border-radius: 4px;
    margin-left: auto;
    cursor: pointer;
}

/* Search Bar */
.gpm-search-row {
    margin-top: 10px;
    padding: 0 4px;
    /* Ensure visible spacing on sides */
    width: 100%;
    box-sizing: border-box;
}

.gpm-search-wrapper {
    position: relative;
    width: 100%;
}

.gpm-search-wrapper .dashicons {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    z-index: 2;
    /* Ensure icon is above input */
}

.gpm-search-input {
    width: 100%;
    max-width: 100%;
    padding: 10px 10px 10px 35px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    /* Fixes overflow issue */
    height: 42px;
    /* Match other inputs */
}

/* Sticky Table Header & Stability */
.gpm-product-table {
    table-layout: fixed;
    width: 100%;
}

.gpm-product-table thead {
    position: sticky;
    top: 80px;
    /* Adjusted based on fitler bar height ~60-80px */
    background: #fff;
    z-index: 50;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    /* Slight separation */
}

.gpm-product-table th {
    background: #fff;
    /* Ensure opacity */
    border-bottom: 2px solid #e2e6ec;
}

/* Column Widths (12 Columns) */
.gpm-product-table th:nth-child(1) {
    width: 18%;
}

/* Website URL */
.gpm-product-table th:nth-child(2) {
    width: 5%;
}

/* AS */
.gpm-product-table th:nth-child(3) {
    width: 5%;
}

/* DA */
.gpm-product-table th:nth-child(4) {
    width: 5%;
}

/* DR */
.gpm-product-table th:nth-child(5) {
    width: 10%;
}

/* Niche */
.gpm-product-table th:nth-child(6) {
    width: 7%;
}

/* Lang */
.gpm-product-table th:nth-child(7) {
    width: 8%;
}

/* Ah Traf */
.gpm-product-table th:nth-child(8) {
    width: 8%;
}

/* Ah Kw */
.gpm-product-table th:nth-child(9) {
    width: 8%;
}

/* Sem Countries */
.gpm-product-table th:nth-child(10) {
    width: 8%;
}

/* Sem Traf */
.gpm-product-table th:nth-child(11) {
    width: 8%;
}

/* Price */
.gpm-product-table th:nth-child(12) {
    width: 10%;
}

/* Buy Now */

/* Publish Button */
.gpm-btn-publish {
    background-color: #ff6b35;
    /* Orange */
    color: #fff !important;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.2s;
    text-decoration: none !important;
}

.gpm-btn-publish:hover {
    background-color: #e55a2b;
    color: #fff !important;
}

/* Wishlist Icon */
.gpm-wishlist-icon {
    font-size: 16px;
    color: #ccc;
    cursor: pointer;
    transition: color 0.2s;
}

.gpm-wishlist-icon:hover {
    color: #ff4757 !important;
}

.gpm-wishlist-icon.active {
    color: #ff4757 !important;
}

/* Table Typography & Badges */
.gpm-product-table th {
    font-size: 11px;
    text-transform: uppercase;
    color: #444;
    font-weight: 700;
    line-height: 1.3;
    padding: 10px 8px;
    vertical-align: bottom;

    /* Align badges */
    /* Header Logos */
    .gpm-header-logo {
        display: block;
        height: 14px;
        width: auto;
        margin: 0 auto 4px auto;
        object-fit: contain;
        object-position: center bottom;
    }

    .gpm-header-logo.moz {
        height: 13px;
    }

    .gpm-header-logo.ahrefs {
        height: 10px;
    }

    .gpm-header-logo.semrush {
        height: 11px;
    }

    /* Table Cell & Header Alignment */
    .gpm-product-table th,
    .gpm-product-table td {
        text-align: center;
        vertical-align: middle;
    }

    /* Left Align specific text columns */
    .gpm-product-table th:nth-child(1),
    .gpm-product-table td:nth-child(1),
    .gpm-product-table th:nth-child(5),
    .gpm-product-table td:nth-child(5),
    .gpm-product-table th:nth-child(6),
    .gpm-product-table td:nth-child(6) {
        text-align: left;
    }

    /* Specific Header Override to align badges bottom */
    /* Specific Header Override to align badges bottom */
    .gpm-product-table th {
        font-size: 12px;
        text-transform: uppercase;
        color: #555;
        font-weight: 700;
        line-height: 1.4;
        padding: 12px 10px;
        vertical-align: bottom;
        letter-spacing: 0.5px;
        font-family: 'Inter', system-ui, -apple-system, sans-serif;
    }
}

/* Align badges */
/* Header Logos */
.gpm-header-logo {
    display: block;
    height: 14px;
    width: auto;
    margin: 0 auto 4px auto;
    object-fit: contain;
    object-position: center bottom;
}

.gpm-header-logo.moz {
    height: 13px;
}

.gpm-header-logo.ahrefs {
    height: 10px;
}

.gpm-header-logo.semrush {
    height: 11px;
}

/* Table Cell & Header Alignment */
.gpm-product-table th,
.gpm-product-table td {
    text-align: center;
    vertical-align: middle;
}

/* Left Align specific text columns */
.gpm-product-table th:nth-child(1),
.gpm-product-table td:nth-child(1),
.gpm-product-table th:nth-child(5),
.gpm-product-table td:nth-child(5),
.gpm-product-table th:nth-child(6),
.gpm-product-table td:nth-child(6) {
    text-align: left;
}

/* Specific Header Override to align badges bottom */
.gpm-product-table th {
    font-size: 11px;
    text-transform: uppercase;
    color: #444;
    font-weight: 700;
    line-height: 1.3;
    padding: 10px 8px;
    vertical-align: bottom;
}

/* Update header logo margins for left-aligned columns if any */
/* If a left-aligned column gets a logo, it needs margin: 0 0 4px 0 */


.gpm-product-table td {
    font-size: 13px;
    color: #333;
    padding: 12px 8px;
    border-bottom: 1px solid #eee;
}

.gpm-product-table td a {
    font-weight: 600;
    color: #333;
    /* Restore original link color if it was different, or keep if standard */
    text-decoration: none;
}

/* Active Filter Indicator */
.gpm-filter-active .gpm-filter-btn {
    border-color: #ff6b35;
    color: #ff6b35;
}

.gpm-filter-active .gpm-filter-btn::after {
    content: "";
    width: 6px;
    height: 6px;
    background: #ff6b35;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
    vertical-align: middle;
}

/* Reset Button */
.gpm-reset-filters {
    background: transparent;
    border: 1px solid #ddd;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 10px;
}

.gpm-reset-filters:hover {
    border-color: #ff6b35;
    color: #ff6b35;
}

/* Sorting Styles */
.gpm-sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.gpm-sortable:hover {
    background-color: #f9f9f9;
}

.gpm-sort-icon {
    margin-left: 6px;
    font-size: 10px;
    opacity: .6;
    display: inline-block;
    vertical-align: middle;
}

.gpm-sortable.active {
    color: #ff6b35;
    /* Active brand color */
}

.gpm-sortable.active .gpm-sort-icon {
    opacity: 1;
}

/* Mobile Safeguard */
@media (max-width: 768px) {

    .gpm-sticky-filters,
    .gpm-product-table thead {
        position: relative !important;
        top: auto !important;
        z-index: auto !important;
    }

    .gpm-filter-row {
        gap: 5px;
        overflow-x: auto;
        padding-bottom: 10px;
        flex-wrap: nowrap;
    }

    /* Responsive Table Wrapper constraints */
    .gpm-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 20px;
        border: 1px solid #eee;
        border-radius: 8px;
    }

    .gpm-product-table {
        min-width: 900px;
        /* Force minimum width to trigger scroll instead of squishing */
    }
}

/* Loading Overlay */
.gpm-table-wrapper {
    position: relative;
    min-height: 200px;
}

.gpm-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.gpm-loading-overlay.active {
    display: flex;
    opacity: 1;
}

.gpm-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: gpm-spin 1s linear infinite;
}

@keyframes gpm-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Table Fade Transition */
.gpm-product-table tbody {
    transition: opacity 0.2s ease-in-out;
}

.gpm-product-table tbody.fading-out {
    opacity: 0.2;
}

/* Results Bar & Pagination Info */
.gpm-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.gpm-results-summary {
    font-size: 14px;
    font-weight: 700;
    color: #333;
}

.gpm-active-filters-container {
    font-size: 13px;
    color: #666;
}

.gpm-clear-all {
    color: #ff6b35;
    cursor: pointer;
    font-weight: 500;
    margin-left: 10px;
    text-decoration: underline;
}

.gpm-clear-all:hover {
    color: #e55a2b;
}

/* Pagination Styles */
.gpm-pagination {
    margin-top: 20px;
    display: flex;
    gap: 5px;
    justify-content: flex-end;
}

.gpm-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.gpm-pagination .page-numbers.current {
    background-color: #ff6b35;
    border-color: #ff6b35;
    color: #fff;
}

.gpm-pagination .page-numbers:hover:not(.current) {
    background-color: #f5f5f5;
    border-color: #ccc;
}