/* =====================================================
   public/css/search.css
   Buscador Global C4 SYSTEM
   Autocompletado elegante + responsive
===================================================== */

/* =====================================================
   CONTENEDOR GENERAL
===================================================== */

.c4-search {
    position: relative;
    width: min(100%, 520px);
    z-index: 50;
}

.c4-search-form {
    position: relative;
    width: 100%;
}

.c4-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

/* =====================================================
   INPUT
===================================================== */

.c4-search-input {
    width: 100%;
    height: 44px;
    padding: 0 46px 0 44px;
    border: 1px solid rgba(15, 23, 42, 0.16);
    border-radius: 999px;
    background: #ffffff;
    color: #0f172a;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    box-shadow: 0 6px 22px rgba(15, 23, 42, 0.08);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.c4-search-input::placeholder {
    color: #64748b;
    font-weight: 400;
}

.c4-search-input:focus {
    border-color: #f6b300;
    box-shadow: 0 8px 28px rgba(246, 179, 0, 0.22);
}

/* =====================================================
   ICONOS
===================================================== */

.c4-search-icon {
    position: absolute;
    left: 17px;
    color: #64748b;
    font-size: 16px;
    pointer-events: none;
}

.c4-search-submit {
    position: absolute;
    right: 5px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #f6b300;
    color: #111827;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 0.15s ease, background 0.15s ease;
}

.c4-search-submit:hover {
    background: #ffc400;
    transform: scale(1.04);
}

/* =====================================================
   ESTADOS
===================================================== */

.c4-search.is-loading .c4-search-submit {
    pointer-events: none;
    opacity: 0.75;
}

.c4-search.is-loading .c4-search-submit::before {
    content: "";
    width: 15px;
    height: 15px;
    border: 2px solid rgba(17, 24, 39, 0.25);
    border-top-color: #111827;
    border-radius: 50%;
    animation: c4-search-spin 0.7s linear infinite;
}

.c4-search.is-loading .c4-search-submit span {
    display: none;
}

@keyframes c4-search-spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   DROPDOWN
===================================================== */

.c4-search-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 18px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.18);
    overflow: hidden;
    display: none;
    z-index: 999;
}

.c4-search.is-open .c4-search-dropdown {
    display: block;
}

.c4-search-dropdown::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 32px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-left: 1px solid rgba(15, 23, 42, 0.12);
    border-top: 1px solid rgba(15, 23, 42, 0.12);
    transform: rotate(45deg);
}

/* =====================================================
   HEADER DROPDOWN
===================================================== */

.c4-search-head {
    position: relative;
    padding: 12px 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid #e5e7eb;
}

.c4-search-head-title {
    font-size: 13px;
    font-weight: 800;
    color: #0f172a;
}

.c4-search-head-meta {
    margin-top: 2px;
    font-size: 12px;
    color: #64748b;
}

/* =====================================================
   GRUPOS
===================================================== */

.c4-search-group {
    padding: 8px 0;
}

.c4-search-group + .c4-search-group {
    border-top: 1px solid #eef2f7;
}

.c4-search-group-title {
    padding: 6px 16px 5px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

/* =====================================================
   ITEMS
===================================================== */

.c4-search-item {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    text-decoration: none;
    color: #0f172a;
    cursor: pointer;
    transition: background 0.14s ease;
}

.c4-search-item:hover,
.c4-search-item.is-active {
    background: #fff8e1;
}

.c4-search-thumb {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #f1f5f9;
    border: 1px solid #e5e7eb;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: #64748b;
    font-size: 20px;
    font-weight: 800;
}

.c4-search-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.c4-search-info {
    min-width: 0;
}

.c4-search-title {
    font-size: 14px;
    font-weight: 800;
    color: #111827;
    line-height: 1.3;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;

    overflow: hidden;
}

.c4-search-sub {
    margin-top: 3px;
    font-size: 12px;
    color: #64748b;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.c4-search-type {
    padding: 5px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #1e3a8a;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* =====================================================
   COLORES POR TIPO
===================================================== */

.c4-search-item[data-type="producto"] .c4-search-type {
    background: #fff3c4;
    color: #7a4b00;
}

.c4-search-item[data-type="pagina"] .c4-search-type {
    background: #dbeafe;
    color: #1e40af;
}

.c4-search-item[data-type="categoria"] .c4-search-type {
    background: #dcfce7;
    color: #166534;
}

.c4-search-item[data-type="marca"] .c4-search-type {
    background: #f3e8ff;
    color: #6b21a8;
}

/* =====================================================
   FOOTER DROPDOWN
===================================================== */

.c4-search-footer {
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
}

.c4-search-view-all {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    color: #0f172a;
    text-decoration: none;
    font-size: 13px;
    font-weight: 900;
}

.c4-search-view-all:hover {
    background: #f1f5f9;
}

.c4-search-view-all span:last-child {
    color: #f6b300;
    font-size: 18px;
}

/* =====================================================
   EMPTY / ERROR
===================================================== */

.c4-search-empty,
.c4-search-error {
    padding: 22px 16px;
    text-align: center;
}

.c4-search-empty-title,
.c4-search-error-title {
    font-size: 14px;
    font-weight: 900;
    color: #111827;
}

.c4-search-empty-text,
.c4-search-error-text {
    margin-top: 5px;
    font-size: 12px;
    color: #64748b;
}

/* =====================================================
   RESPONSIVE
===================================================== */

@media (max-width: 1024px) {
    .c4-search {
        width: min(100%, 460px);
    }
}

@media (max-width: 768px) {
    .c4-search {
        width: 100%;
    }

    .c4-search-input {
        height: 42px;
        font-size: 13px;
    }

    .c4-search-dropdown {
        position: fixed;
        top: auto;
        left: 12px;
        right: 12px;
        max-height: 72vh;
        overflow-y: auto;
        border-radius: 16px;
    }

    .c4-search-dropdown::before {
        display: none;
    }

    .c4-search-item {
        grid-template-columns: 44px 1fr;
    }

    .c4-search-type {
        display: none;
    }

    .c4-search-thumb {
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 420px) {
    .c4-search-input {
        padding-left: 40px;
        padding-right: 42px;
    }

    .c4-search-title {
        font-size: 13px;
    }

    .c4-search-sub {
        font-size: 11px;
    }
}

/* =====================================================
   HEADER SEARCH ROW — BARRA GLOBAL BAJO HEADER
===================================================== */

.header-search-row {
    width: 100%;
    padding: 12px 0 18px;
    background: #ffffff;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    display: flex;
    justify-content: center;
}

.header-search-row .c4-search {
    width: 100%;
    max-width: none;
}

.header-search-row .c4-search-wide {
    width: 100%;
    max-width: none;
}

.header-search-row .c4-search-input {
    height: 48px;
    border-radius: 14px;
    font-size: 15px;
    box-shadow: 0 8px 26px rgba(15, 23, 42, 0.08);
}

.header-search-row .c4-search-dropdown {
    left: 0;
    right: 0;
}


/* =====================================================
   PRODUCTO: PRECIO / SKU / RESUMEN
===================================================== */

.c4-search-sub {
    margin-top: 4px;
}

.c4-search-price {
    display: block;
    margin-top: 4px;
    font-size: 16px;
    font-weight: 900;
    line-height: 1.15;
    color: #11863b;
}

.c4-search-sku {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.c4-search-summary {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: #64748b;
}

/* TABLET */
@media (max-width: 1024px) {
    .header-search-row {
        padding: 10px 0 14px;
    }

    .header-search-row .c4-search-input {
        height: 46px;
        font-size: 14px;
    }
}

/* MÓVIL */
@media (max-width: 768px) {
    .header-search-row {
        padding: 10px 0 12px;
    }

    .header-search-row .c4-search-input {
        height: 44px;
        border-radius: 12px;
        font-size: 12px;
    }

    .header-search-row .c4-search-dropdown {
        left: 12px;
        right: 12px;
    }
}

