/*!
 * Tìm kiếm nhanh mã nguồn - SIEUTHICODE.COM
 * PC: ô tìm kiếm inline trên navbar + panel gợi ý.
 * Điện thoại/iPad: chỉ 1 icon, bấm vào mở bảng tìm kiếm toàn màn hình.
 */

.sqs-root {
    --sqs-radius: 14px;
    --sqs-green: #16a34a;
    --sqs-green-dark: #15803d;
    --sqs-border: #e3ebe6;
    --sqs-muted: #7c8b82;
    box-sizing: border-box;
}

.sqs-root *,
.sqs-root *::before,
.sqs-root *::after {
    box-sizing: border-box;
}

/* ============================================================
   1. Ô tìm kiếm trên navbar PC
   ============================================================ */
/* Ô search nằm ngay trước nút thông báo, cùng chiều cao & bán kính bo góc
   để nhóm điều khiển bên phải navbar trông đồng bộ. */
.sqs-desktop {
    position: relative;
    z-index: 70;
    display: block;
    flex: 0 0 auto;
    width: 290px;
    max-width: 26vw;
    margin-right: 1.15rem;
    transition: width .26s cubic-bezier(.4, 0, .2, 1);
}

/* Focus thì ô nở rộng ra - hiệu ứng tinh tế, chuyên nghiệp */
.sqs-desktop.is-focused {
    width: 400px;
    max-width: 34vw;
}

@media (max-width: 1400px) {
    .sqs-desktop {
        width: 240px;
        margin-right: .9rem;
    }

    .sqs-desktop.is-focused {
        width: 340px;
    }
}

.sqs-desktop-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 42px;
    padding: 0 7px 0 13px;
    border: 1px solid rgba(255, 255, 255, .34);
    border-radius: 12px;
    background: rgba(255, 255, 255, .13);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
    cursor: text;
    transition:
        background-color .2s ease,
        border-color .2s ease,
        box-shadow .2s ease;
}

.sqs-desktop-field:hover {
    border-color: rgba(255, 255, 255, .55);
    background: rgba(255, 255, 255, .22);
}

/* Icon kính lúp */
.sqs-desktop-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, .95);
    transition: color .2s ease;
}

.sqs-desktop-icon svg {
    width: 18px;
    height: 18px;
}

/* !important để không bị style input toàn cục của theme ghi đè */
.sqs-desktop .sqs-input {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    outline: none !important;
    box-shadow: none !important;
}

.sqs-desktop .sqs-input::placeholder {
    color: rgba(255, 255, 255, .8);
    font-weight: 500;
}

/* Focus: đổi sang nền trắng + chữ xanh, giống nút thông báo khi active */
.sqs-desktop.is-focused .sqs-desktop-field {
    border-color: #bbf7d0;
    background: #fff;
    box-shadow:
        0 0 0 4px rgba(134, 239, 172, .3),
        0 12px 30px rgba(9, 61, 30, .2);
}

.sqs-desktop.is-focused .sqs-desktop-icon {
    color: var(--sqs-green);
}

.sqs-desktop.is-focused .sqs-input {
    color: #1d2e24 !important;
}

.sqs-desktop.is-focused .sqs-input::placeholder {
    color: #9aa8a0;
}

/* Chip phím tắt Ctrl K */
.sqs-kbd {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 3px;
    padding-right: 4px;
    user-select: none;
}

.sqs-kbd kbd {
    display: inline-block;
    min-width: 20px;
    padding: 2px 5px;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 6px;
    background: rgba(255, 255, 255, .16);
    color: rgba(255, 255, 255, .92);
    font-family: inherit;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.3;
    text-align: center;
}

.sqs-desktop.is-focused .sqs-kbd,
.sqs-root.has-value .sqs-kbd {
    display: none;
}

/* Nút xoá từ khoá */
.sqs-clear {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .24);
    color: #fff;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease;
}

.sqs-clear svg {
    width: 11px;
    height: 11px;
}

.sqs-desktop.is-focused .sqs-clear {
    background: #eef2f0;
    color: #5c6b62;
}

.sqs-clear:hover {
    background: rgba(22, 163, 74, .18);
    color: var(--sqs-green-dark);
}

.sqs-root.has-value .sqs-clear {
    display: inline-flex;
}



/* Panel gợi ý PC */
.sqs-desktop-panel {
    position: absolute;
    top: calc(100% + 12px);
    /* Neo về bên phải vì ô search nằm sát nhóm icon phải của navbar */
    right: 0;
    left: auto;
    /* Panel rộng hơn ô input để hiển thị đủ tiêu đề mã nguồn */
    width: max(100%, 440px);
    z-index: 9999;

    overflow: hidden;

    max-height: min(74vh, 560px);
    overflow-y: auto;
    border: 1px solid var(--sqs-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 26px 60px rgba(13, 48, 27, .22);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(.99);
    transform-origin: top right;
    pointer-events: none;

    transition:
        opacity .18s ease,
        visibility .18s ease,
        transform .18s ease;
    scrollbar-width: thin;
    scrollbar-color: #bbf7d0 transparent;
}

.sqs-desktop-panel::-webkit-scrollbar {
    width: 6px;
}

.sqs-desktop-panel::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #bbf7d0;
}

.sqs-desktop.is-open .sqs-desktop-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ============================================================
   2. Nội dung kết quả (dùng chung PC + mobile)
   ============================================================ */
.sqs-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px 9px;
    color: var(--sqs-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.sqs-section-title span:last-child {
    color: var(--sqs-green-dark);
    letter-spacing: 0;
    text-transform: none;
}

.sqs-list {
    margin: 0;
    padding: 0 8px 8px;
    list-style: none;
}

.sqs-item {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    padding: 10px;
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
    transition: background-color .16s ease, transform .16s ease;
}

.sqs-item + .sqs-item {
    margin-top: 2px;
}

.sqs-item:hover,
.sqs-item.is-active {
    background: #f2fbf5;
    text-decoration: none;
}

.sqs-item.is-active {
    box-shadow: inset 0 0 0 1px #bbf7d0;
}

.sqs-thumb {
    position: relative;
    overflow: hidden;
    width: 62px;
    height: 46px;
    border: 1px solid #eef3f0;
    border-radius: 10px;
    background: #f6f8f7;
}

.sqs-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #f8fafc;
}

.sqs-item-body {
    min-width: 0;
}

.sqs-item-title {
    margin: 0;
    overflow: hidden;
    color: #1f2f26;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.42;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sqs-item-title mark {
    padding: 0 1px;
    border-radius: 3px;
    background: #dcfce7;
    color: var(--sqs-green-dark);
    font-weight: 800;
}

.sqs-item-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 5px;
    color: var(--sqs-muted);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.3;
}

.sqs-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid #dcfce7;
    border-radius: 999px;
    background: #f0fdf4;
    color: var(--sqs-green-dark);
    font-size: 10.5px;
    font-weight: 800;
}

.sqs-price {
    color: #dc2626;
    font-size: 13px;
    font-weight: 800;
}

.sqs-price-old {
    color: #a3aead;
    font-size: 11.5px;
    font-weight: 600;
    text-decoration: line-through;
}

.sqs-footer {
    display: block;
    padding: 12px 16px;
    border-top: 1px solid #eef3f0;
    background: #fbfdfc;
    color: var(--sqs-green-dark);
    font-size: 12.5px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    transition: background-color .16s ease;
}

.sqs-footer:hover {
    background: #f0fdf4;
    text-decoration: none;
}

/* Trạng thái rỗng / lỗi / đang tải */
.sqs-state {
    padding: 34px 22px;
    text-align: center;
}

.sqs-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 11px;
    border: 1px solid #dcfce7;
    border-radius: 15px;
    background: #f0fdf4;
    color: var(--sqs-green);
}

.sqs-state-icon svg {
    width: 23px;
    height: 23px;
}

.sqs-state strong {
    display: block;
    color: #2c3b32;
    font-size: 14px;
    font-weight: 800;
}

.sqs-state span {
    margin-top: 4px;
    color: var(--sqs-muted);
    font-size: 12px;
}

/* Skeleton loading */
.sqs-skeleton {
    padding: 12px 16px 16px;
}

.sqs-skeleton-row {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    padding: 8px 0;
}

.sqs-skeleton-box,
.sqs-skeleton-line {
    border-radius: 8px;
    background: linear-gradient(90deg, #eef2f0 25%, #f7faf8 37%, #eef2f0 63%);
    background-size: 400% 100%;
    animation: sqs-shimmer 1.25s ease-in-out infinite;
}

.sqs-skeleton-box {
    height: 46px;
    border-radius: 10px;
}

.sqs-skeleton-line {
    height: 11px;
}

.sqs-skeleton-line + .sqs-skeleton-line {
    margin-top: 8px;
    width: 55%;
}

@keyframes sqs-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .sqs-skeleton-box,
    .sqs-skeleton-line {
        animation: none;
    }
}

/* ============================================================
   3. Nút icon + bảng tìm kiếm cho điện thoại / iPad
   ============================================================ */
.sqs-mobile-trigger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-right: 12px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .32);
    border-radius: 12px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .2s ease, transform .16s ease;
}

.sqs-mobile-trigger svg {
    width: 20px;
    height: 20px;
}

.sqs-mobile-trigger:active {
    transform: scale(.94);
    background: rgba(255, 255, 255, .26);
}

.sqs-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    background: #fff;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    pointer-events: none;
    transition:
        opacity .2s ease,
        visibility .2s ease,
        transform .2s ease;
}

.sqs-overlay.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

html.sqs-lock,
html.sqs-lock body {
    overflow: hidden;
}

.sqs-overlay-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    border-bottom: 1px solid #eef3f0;
    background: linear-gradient(120deg, #15803d, #22c55e);
}

.sqs-overlay-back {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sqs-overlay-back svg {
    width: 20px;
    height: 20px;
}

.sqs-overlay-field {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 9px;
    height: 42px;
    min-width: 0;
    padding: 0 13px;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(6, 41, 20, .18);
}

.sqs-overlay-field > svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--sqs-green);
}

.sqs-overlay .sqs-input {
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: #1d2e24;
    font-size: 15px;
    font-weight: 600;
    outline: none;
    box-shadow: none;
    /* iOS không tự zoom khi font >= 16px, giữ 15px + đủ lớn vẫn ổn */
}

.sqs-overlay .sqs-input::placeholder {
    color: #9aa8a0;
    font-weight: 500;
}

.sqs-overlay-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.sqs-overlay .sqs-item {
    grid-template-columns: 74px minmax(0, 1fr);
    padding: 11px 12px;
    border-radius: 14px;
}

.sqs-overlay .sqs-thumb {
    width: 74px;
    height: 55px;
}

.sqs-overlay .sqs-item-title {
    font-size: 14.5px;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* Hiện/ẩn theo breakpoint - đồng bộ với mobile-navigation.css (1180px) */
@media (max-width: 1180px) {
    .sqs-desktop {
        display: none !important;
    }

    .sqs-mobile-trigger {
        display: inline-flex;
    }
}

@media (min-width: 1181px) {
    .sqs-mobile-trigger {
        display: none !important;
    }

    .sqs-overlay {
        display: none !important;
    }
}

@media (max-width: 380px) {
    .sqs-mobile-trigger {
        width: 38px;
        height: 38px;
        margin-right: 8px;
        border-radius: 11px;
    }
}
