/**
 * Kamasa B2B - Search Styles (Strict V4.2)
 * Identity: Yellow #ffed00, Black #000, Fonts: Myriad Pro
 */

/* FONTS */
@font-face {
    font-family: 'Myriad Pro';
    src: url('../fonts/myriad-pro-regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Myriad Pro';
    src: url('../fonts/myriad-pro-bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Myriad Pro';
    src: url('../fonts/myriad-pro-light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
}

/* VARIABLES */
:root {
    --k-yellow: #ffed00;
    --k-black: #000000;
    --k-dark-gray: #333333;
    --k-light-gray: #f4f4f4;
    --k-border: #e2e2e2;
    --k-spacing: 20px;
    --k-font: 'Myriad Pro', sans-serif;
}

/* LAYOUT */
.k-search-page {
    padding: 40px 0 80px;
    background: #fff;
    font-family: var(--k-font);
}

.k-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* HEADER */
.k-search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--k-yellow);
    padding-bottom: 15px;
    margin-bottom: 30px;
}

.k-header-title h1 {
    font-size: 24px;
    font-weight: 800;
    text-transform: uppercase;
    margin: 0;
    color: var(--k-black);
}

.k-header-title h1 span {
    color: #666;
}

.k-result-count {
    margin: 5px 0 0;
    font-size: 13px;
    color: #888;
}

.k-sort-select {
    padding: 8px 15px;
    border: 1px solid var(--k-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: var(--k-font);
    /* Ensure font in select */
}

/* GRID */
.k-search-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 40px;
}

/* SIDEBAR */
.k-sidebar {
    position: sticky;
    top: 20px;
}

.k-filter-box {
    background: #fff;
    padding-right: 20px;
}

.k-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--k-border);
    padding-bottom: 10px;
}

.k-filter-header h3 {
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    margin: 0;
}

.k-clean-btn {
    font-size: 12px;
    color: #d00;
    text-decoration: underline;
}

.k-filter-group {
    margin-bottom: 25px;
}

.k-filter-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 12px;
    color: var(--k-black);
}

/* PRICE INPUTS */
.k-price-inputs {
    display: flex;
    gap: 5px;
}

.k-price-inputs input {
    width: 60px;
    padding: 5px;
    border: 1px solid #ccc;
    font-size: 13px;
    font-family: var(--k-font);
}

.k-price-inputs button {
    background: var(--k-black);
    color: #fff;
    border: none;
    width: 25px;
    cursor: pointer;
}

/* FILTER LIST */
.k-filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
}

.k-filter-list li {
    margin-bottom: 6px;
}

.k-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: #555;
    word-break: break-word;
}

.k-checkbox input {
    display: none;
}

.k-chk-box {
    width: 14px;
    height: 14px;
    min-width: 14px;
    border: 1px solid #999;
    margin-right: 8px;
    display: inline-block;
    position: relative;
    background: #fff;
}

.k-checkbox input:checked+.k-chk-box {
    background: var(--k-yellow);
    border-color: var(--k-black);
}

.k-count {
    font-size: 11px;
    color: #aaa;
    margin-left: 4px;
}

.k-btn-apply {
    width: 100%;
    background: var(--k-black);
    color: #fff;
    padding: 10px;
    border: none;
    text-transform: uppercase;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    font-family: var(--k-font);
}

.k-btn-apply:hover {
    background: var(--k-yellow);
    color: #000;
}

/* PRODUCTS GRID (3 Column Enforced) */
/* PRODUCTS GRID (4 Column Enforced) */
/* PRODUCTS GRID (4 Column Enforced) */
.k-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 40px;
    /* Clear vertical/horizontal separation */
    align-items: stretch;
    /* Cards stretch to same height */
    margin-bottom: 40px;
}

/* PRODUCT CARD (Updated for card.php structure) */
.k-card,
.k-catalog-card {
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
    background: #fff;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 20px;
    border-radius: 6px;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.k-card:hover,
.k-catalog-card:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    border-color: var(--k-yellow);
    transform: translateY(-4px);
}

.k-card-brand,
.k-catalog-card__brand {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 5;
    background: transparent;
    padding: 0;
}

.k-card-brand img,
.k-catalog-card__brand img {
    height: 24px;
    width: auto;
    display: block;
}

.k-card-img {
    margin: 15px 0 15px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.k-card-img img {
    max-height: 100%;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.k-card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #f9f9f9;
    padding-top: 10px;
}

.k-sku {
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.k-name {
    font-size: 14px;
    line-height: 1.3;
    font-weight: 700;
    margin: 0 0 8px;
    height: 38px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.k-name a {
    color: var(--k-black);
    text-decoration: none;
}

.k-desc {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    margin-bottom: 15px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.k-card-footer {
    margin-top: auto;
}

.k-price {
    font-size: 18px;
    font-weight: 800;
    color: var(--k-black);
    margin-bottom: 10px;
}

.k-price-empty {
    font-size: 14px;
    color: #999;
    margin-bottom: 10px;
    font-style: italic;
    min-height: 27px;
}

.k-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: 0.2s;
    border-radius: 4px;
    font-family: var(--k-font);
}

.k-btn-add {
    background: var(--k-yellow);
    color: var(--k-black);
    border-color: var(--k-yellow);
}

.k-btn-add:hover {
    background: #000;
    color: var(--k-yellow);
    border-color: #000;
}

.k-btn-quote {
    background: transparent;
    border-color: var(--k-black);
    color: var(--k-black);
    display: table;
    /* Center trick */
    margin: 10px auto 0;
    /* Center horizontally */
    min-width: 120px;
}

.k-btn-quote:hover {
    background: var(--k-black);
    color: #fff;
}

.k-btn-disabled {
    background: #eee;
    color: #aaa;
    cursor: not-allowed;
}

/* EMPTY STATE */
.k-no-results {
    text-align: center;
    padding: 60px;
    border: 1px dashed #ccc;
}

.k-btn-reset {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background: var(--k-black);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
}

/* PAGINATION (Refined) */
.k-pagination-area {
    margin-top: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.k-pagination-info {
    font-size: 13px;
    color: #666;
}

.k-pagination-nav {
    display: flex;
    gap: 5px;
}

.k-page-link,
.k-page-nav,
.k-page-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 5px;
    border: 1px solid transparent;
    color: #444;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    background: #fff;
    border-radius: 4px;
    transition: all 0.2s;
}

.k-page-link:hover,
.k-page-nav:hover {
    background: #f0f0f0;
    color: #000;
}

.k-page-link.active {
    background: var(--k-yellow);
    color: #000;
    border-color: var(--k-yellow);
}

.k-page-nav {
    color: var(--k-black);
    font-weight: 700;
}

.k-page-dots {
    border: none;
    color: #999;
}


/* RESPONSIVE */
@media(max-width: 1024px) {
    .k-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media(max-width: 900px) {
    .k-search-layout {
        grid-template-columns: 1fr;
    }

    .k-sidebar {
        margin-bottom: 30px;
        position: static;
        background: #f9f9f9;
        padding: 20px;
    }
}

@media(max-width: 600px) {
    .k-products-grid {
        grid-template-columns: 1fr;
    }

    .k-pagination-area {}
}

/* 
 * CRITICAL FIX: Stacking Context for Search Page (Scoped)
 * Fixes menu overlay issues by enforcing header Stacking Context above search content.
 */

/* =========================================
   SEARCH PAGE LAYOUT FIX - STRUCTURAL
   ========================================= */

/* 1. Main Header: Reserve Space & Ensure Priority */
.k-header {
    position: relative !important;
    z-index: 9999 !important;
    /* Top of the stack */
    /* Ensure it acts as a layout block, not overlaid */
}

/* 2. Content Separation: Push Search Content Down */
/* Using .k-search-page to apply the spacing since #content encompasses it */
.k-search-page {
    position: relative !important;
    z-index: 1 !important;
    /* Base level */
    padding-top: 40px !important;
    /* Visual separation from header */
    margin-top: 0 !important;
}

/* 3. Search Internal Header: Neutralize Displacement */
.k-search-header {
    position: relative !important;
    top: auto !important;
    transform: none !important;
    margin-top: 0 !important;
    margin-bottom: 30px !important;
    /* Space before results */
    z-index: auto !important;
    /* Do not compete */
}

/* 3. FIX: Dropdown Positioning specific for Search Page context */
/* Removed redundant overrides. Global CSS now handles absolute positioning correctly. */

/* FULL WIDTH LAYOUT WRAPPER */
.k-search-wrapper-fluid {
    width: 100%;
    max-width: 100%;
    padding: 0 40px;
    margin: 0 auto;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .k-search-wrapper-fluid {
        padding: 0 20px;
    }
}

/* =========================================
   CRITICAL LAYOUT OVERRIDE (FORCE FULL WIDTH - STRICT)
   ========================================= */

/* 
   CONTEXT: The search page uses 'page-busqueda.php' template.
   BODY CLASS: 'page-template-page-busqueda'
   TARGET: Override global theme max-width on .site and .site-content.
*/

/* 1. Unconstrain Site Wrappers & Elementor Containers */
body.page-template-page-busqueda .site,
body.page-template-page-busqueda .site-content,
body.page-template-page-busqueda #page,
body.page-template-page-busqueda #content,
body.page-template-page-busqueda #primary,
body.page-template-page-busqueda .content-area,
body.page-template-page-busqueda .site-main,
body.page-template-page-busqueda .elementor-section,
body.page-template-page-busqueda .elementor-container,
body.page-template-page-busqueda .elementor-column,
body.page-template-page-busqueda .elementor-row,
body.page-template-page-busqueda article,
body.page-template-page-busqueda .entry-content,
body.page-template-page-busqueda .kamasa-search-native {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
    flex-basis: auto !important;
    /* Stop flex shrinking */
}

/* 2. Ensure Search Page Wrapper is Full Width */
body.page-template-page-busqueda .k-search-page {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* 3. Fluid Inner Wrapper (Padding Control) */
body.page-template-page-busqueda .k-search-wrapper-fluid {
    width: 100% !important;
    max-width: 1600px !important;
    /* Wider for 4 columns */
    margin: 0 auto;
    padding: 0 40px;
    box-sizing: border-box;
}

/* 4. Grid Full Width with Minimum Card Width */
body.page-template-page-busqueda .k-products-grid {
    width: 100% !important;
    max-width: none !important;
    display: grid;
    grid-template-columns: repeat(4, minmax(280px, 1fr)) !important;
    /* Min 280px per card */
    gap: 30px 20px;
    /* Vertical gap 30px, horizontal 20px */
}

/* Mobile Adjustments */
@media (max-width: 1024px) {
    body.page-template-page-busqueda .k-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    body.page-template-page-busqueda .k-search-wrapper-fluid {
        padding: 0 20px;
    }

    body.page-template-page-busqueda .k-products-grid {
        grid-template-columns: 1fr !important;
    }
}