﻿/* ================== MARKET LAYOUT ================== */

.page-market .page-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Người đăng trên thẻ tool (fix avatar bị to) */
.page-market .tool-card-seller {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-soft);
}
.page-market .seller-avatar-xs {
    width: 22px;
    height: 22px;
    object-fit: cover;
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.market-main {
    flex: 1;
    padding: 20px 0 80px;
    background: #18191a;
}

.market-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 22px;
}


/* Search trong header */

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #242526;
    border: 1px solid rgba(30, 64, 175, 0.6);
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.9);
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.9rem;
}

.search-input::placeholder {
    color: var(--text-soft);
}

/* Gợi ý tìm kiếm */

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #242526;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    margin-top: 6px;
    padding: 6px 0;
    box-shadow: var(--shadow-soft);
    display: none;
    z-index: 40;
}

.search-suggestions.visible {
    display: block;
}

.search-suggestions button {
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-soft);
    background: transparent;
    border-radius: 10px;
}

.search-suggestions button:hover {
    background: rgba(30, 64, 175, 0.35);
    color: #e5f2ff;
}

/* Icon wishlist + cart */

.nav-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: var(--text-soft);
    transition: var(--transition-normal);
}

.nav-icon-btn:hover {
    background: rgba(30, 64, 175, 0.65);
    color: #e5f2ff;
}

.nav-icon-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #f97316;
    color: #fff;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ================== FILTER PANEL ================== */

.filters-panel {
    background: #242526;
    border-radius: 20px;
    border: 1px solid rgba(30, 64, 175, 0.7);
    padding: 16px 16px 18px;
    box-shadow: var(--shadow-soft);
    position: relative;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.filters-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.filters-reset {
    font-size: 0.8rem;
    color: var(--accent-alt);
    background: transparent;
}

.filters-section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(15, 23, 42, 1);
}

.filters-section:first-of-type {
    border-top: none;
    padding-top: 4px;
}

.filters-section h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    margin-bottom: 6px;
}

/* ----- Category tree ----- */

.category-tree ul {
    margin-left: 4px;
}

.category-item {
    margin-bottom: 4px;
}

.category-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-soft);
    cursor: pointer;
    padding: 4px 4px;
    border-radius: 8px;
}

.category-label:hover {
    background: rgba(15, 23, 42, 0.9);
}

.category-label input {
    accent-color: var(--accent);
}

.category-children {
    margin-left: 18px;
    margin-top: 2px;
}

/* ----- Price range ----- */

.price-range-inputs {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 8px;
}

.price-range-inputs input {
    width: 50%;
    padding: 5px 8px;
    font-size: 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: #242526;
    color: var(--text-main);
}

.range-slider {
    position: relative;
    height: 32px;
}

.range-track {
    position: absolute;
    top: 50%;
    left: 4px;
    right: 4px;
    height: 4px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: #242526;
    border: 1px solid #1e293b;
    overflow: hidden;
}

.range-track-fill {
    position: absolute;
    top: -1px;
    bottom: -1px;
    background: linear-gradient(90deg, var(--accent), var(--accent-alt));
}

.range-input {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
}

.range-input input[type="range"] {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 100%;
    height: 32px;
    background: none;
}

.range-input input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #eff6ff;
    border: 2px solid var(--accent);
    box-shadow: var(--shadow-soft);
}

.range-input input::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
}

/* ----- Rating filter ----- */

.rating-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rating-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-soft);
    cursor: pointer;
}

.rating-option input {
    accent-color: var(--accent);
}

.stars {
    color: #facc15;
    font-size: 0.78rem;
}

/* ----- Checkbox lists ----- */

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-soft);
    cursor: pointer;
}

.checkbox-item input {
    accent-color: var(--accent);
}

/* ----- Compatibility pills ----- */

.compat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.compat-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    color: var(--text-soft);
    cursor: pointer;
    background: #242526;
}

.compat-pill input {
    accent-color: var(--accent);
}

/* ================== TOOLBAR & META ================== */

.product-area {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 18px;
    background: #242526;
    border: 1px solid rgba(30, 64, 175, 0.7);
    box-shadow: var(--shadow-soft);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-select {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: #242526;
    color: var(--text-soft);
    font-size: 0.8rem;
}

.view-toggle {
    display: flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.view-toggle button {
    padding: 6px 10px;
    font-size: 0.8rem;
    color: var(--text-soft);
    background: #242526;
    min-width: 46px;
    text-align: center;
}

.view-toggle button.active {
    background: rgba(37, 99, 235, 0.16);
    color: #e5f2ff;
}

.items-meta {
    font-size: 0.8rem;
    color: var(--text-soft);
}

/* Bộ lọc cho mobile */

.filters-toggle-btn {
    display: none;
    /* sẽ hiện trong @media */
}

/* ================== PRODUCT GRID ================== */

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.products-grid.list-view {
    grid-template-columns: 1fr;
}

.product-card {
    position: relative;
    background: #242526;
    border-radius: 18px;
    border: 1px solid #1e293b;
    padding: 10px 10px 12px;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.75);
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
    transition: var(--transition-normal);
}

.product-thumb-wrap {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: radial-gradient(circle at 15% 15%, rgba(37, 99, 235, 0.4), rgba(15, 23, 42, 1));
}

.product-thumb {
    height: 150px;
    width: 100%;
    object-fit: cover;
    transform: scale(1.02);
    transition: transform 0.25s ease-out;
}

.product-card:hover .product-thumb {
    transform: scale(1.06);
}

.badge-row {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.badge {
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: rgba(15, 23, 42, 0.9);
    color: #e5e7eb;
    border: 1px solid rgba(148, 163, 184, 0.5);
}

.badge.bestseller {
    background: #f97316;
    color: #111827;
    border: none;
}

.badge.new {
    background: #22c55e;
    color: #052e16;
    border: none;
}

.badge.sale {
    background: #ef4444;
    color: #111827;
    border: none;
}

.badge.free {
    background: #22d3ee;
    color: #022c22;
    border: none;
}

/* Compare checkbox */

.compare-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(15, 23, 42, 0.95);
    border-radius: 999px;
    padding: 4px 7px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-soft);
    border: 1px solid rgba(148, 163, 184, 0.45);
}

.compare-checkbox input {
    accent-color: var(--accent);
}

/* Nội dung card */

.product-body {
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.products-grid.list-view .product-thumb-wrap {
    flex: 0 0 180px;
    height: 120px;
}

.products-grid.list-view .product-card {
    flex-direction: row;
    align-items: flex-start;
}

.products-grid.list-view .product-body {
    padding-left: 10px;
    flex: 1;
}

.product-name {
    font-size: 0.98rem;
    font-weight: 600;
}

.product-vendor {
    font-size: 0.8rem;
    color: var(--text-soft);
}

.product-desc {
    font-size: 0.85rem;
    color: var(--text-soft);
    margin-top: 2px;
}

/* Rating row */

.rating-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-soft);
}

.rating-stars {
    color: #facc15;
    font-size: 0.78rem;
}

.rating-count {
    font-size: 0.78rem;
}

.rating-row span[title] {
    cursor: help;
}

/* Price row */

.price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.price-current {
    font-size: 1rem;
    font-weight: 600;
}

.price-old {
    font-size: 0.78rem;
    color: var(--text-soft);
    text-decoration: line-through;
}

.price-tag {
    font-size: 0.75rem;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent-alt);
}

/* Feature icons */

.feature-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.75rem;
}

.feature-pill {
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(30, 64, 175, 0.6);
    color: var(--text-soft);
}

/* Progress bar */

.progress-row {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-soft);
}

.progress-bar {
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: #242526;
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    margin-top: 3px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #facc15, #ef4444);
    width: 40%;
}

/* Actions */

.card-actions {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-actions-left {
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border-subtle);
    color: var(--text-soft);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition-normal);
}

.btn-sm.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-alt));
    border: none;
    color: #e5f2ff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.9);
}

.btn-sm.primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn-sm:hover {
    border-color: var(--accent);
    color: #e2e8f0;
}

.wishlist-btn {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: #242526;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    transition: var(--transition-normal);
}

.wishlist-btn.active {
    background: rgba(248, 113, 113, 0.12);
    border-color: #fb7185;
    color: #fb7185;
    transform: scale(1.05);
}

/* ================== PERSONALIZATION ================== */

.personalization {
    margin-top: 26px;
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.personal-card {
    background: #242526;
    border-radius: 18px;
    border: 1px solid var(--border-subtle);
    padding: 14px 14px 12px;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.75);
}

.personal-card h3 {
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.personal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-soft);
}

.personal-item {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.personal-item span:first-child {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ================== PAGINATION ================== */

.pagination {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    gap: 6px;
    font-size: 0.8rem;
}

.page-btn {
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #242526;
    color: var(--text-soft);
    transition: var(--transition-normal);
}

.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #e5f2ff;
}

.page-btn:hover {
    border-color: var(--accent);
    color: #e5f2ff;
}

/* ================== COMPARE BAR ================== */

.compare-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    transform: translateY(100%);
    background: rgba(15, 23, 42, 0.97);
    border-top: 1px solid rgba(30, 64, 175, 0.7);
    box-shadow: 0 -20px 45px rgba(15, 23, 42, 0.9);
    transition: var(--transition-normal);
}

.compare-bar.visible {
    transform: translateY(0);
}

.compare-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.8rem;
}

.compare-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.compare-pill {
    padding: 4px 8px;
    border-radius: 999px;
    background: #242526;
    border: 1px solid var(--border-subtle);
}

/* ================== QUICK VIEW MODAL ================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 60;
}

.modal-backdrop.visible {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 860px;
    background: #242526;
    border-radius: 22px;
    border: 1px solid rgba(30, 64, 175, 0.8);
    box-shadow: 0 28px 70px rgba(15, 23, 42, 1);
    padding: 16px 18px 12px;
    display: grid;
    grid-template-columns: 1.1fr 1.2fr;
    gap: 16px;
    max-height: 80vh;
    overflow: hidden;
    position: relative;
}

.modal-left {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-main-img {
    border-radius: 16px;
    overflow: hidden;
    background: radial-gradient(circle at 15% 15%, rgba(37, 99, 235, 0.5), rgba(15, 23, 42, 1));
}

.modal-main-img img {
    height: 220px;
    width: 100%;
    object-fit: cover;
}

.modal-thumbs {
    display: flex;
    gap: 8px;
}

.modal-thumbs img {
    flex: 1;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    opacity: 0.8;
    cursor: pointer;
    border: 1px solid transparent;
}

.modal-thumbs img.active {
    opacity: 1;
    border-color: var(--accent);
}

.modal-right {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    border: 1px solid var(--border-subtle);
}

.modal-close:hover {
    color: #e5e7eb;
    border-color: var(--accent);
}

.modal-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-soft);
}

.modal-specs {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-soft);
}

.modal-specs ul {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-reviews {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-soft);
}

.modal-actions {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

.modal-actions-left {
    display: flex;
    gap: 8px;
}

.modal-price {
    font-size: 1rem;
    font-weight: 600;
}

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

.cart-dropdown {
    position: absolute;
    right: 0;
    top: 120%;
    width: 260px;
    background: #242526;
    border-radius: 18px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    padding: 10px;
    display: none;
    z-index: 40;
    font-size: 0.8rem;
}

.cart-dropdown.visible {
    display: block;
}

.cart-items {
    max-height: 230px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
}

.cart-empty {
    color: var(--text-soft);
    font-size: 0.8rem;
}

.cart-item-row {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.cart-item-row span:first-child {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-summary {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-weight: 500;
}

.cart-dropdown .btn-primary {
    width: 100%;
    justify-content: center;
    font-size: 0.8rem;
    padding: 7px 0;
}

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

@media (max-width: 900px) {
    .market-layout {
        grid-template-columns: 1fr;
    }

    .filters-panel {
        order: 2;
    }

    .toolbar {
        order: 1;
    }
}

@media (max-width: 768px) {
    .market-layout {
        margin-top: 10px;
    }

    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters-toggle-btn {
        display: inline-flex;
        margin-left: auto;
        padding: 6px 12px;
        border-radius: 999px;
        border: 1px solid var(--border-subtle);
        background: #242526;
        font-size: 0.8rem;
        color: var(--text-soft);
    }

    .filters-panel {
        position: fixed;
        inset: auto 0 0 0;
        max-height: 80vh;
        overflow-y: auto;
        transform: translateY(100%);
        transition: var(--transition-normal);
        border-radius: 20px 20px 0 0;
        z-index: 55;
    }

    .filters-panel.visible {
        transform: translateY(0);
    }

    .personalization {
        grid-template-columns: 1fr;
    }

    .modal {
        grid-template-columns: 1fr;
        max-height: 90vh;
        overflow-y: auto;
        margin: 0 12px;
        border-radius: 18px;
    }

    .modal-right {
        overflow-y: auto;
        max-height: 45vh;
    }

    .modal-actions {
        position: sticky;
        bottom: 0;
        background: #242526;
    }
}

@media (max-width: 640px) {
    /* List view: thu nhỏ ảnh để body text còn chỗ */
    .products-grid.list-view .product-thumb-wrap {
        flex: 0 0 110px;
        height: 80px;
    }

    .products-grid.list-view .product-body {
        padding-left: 8px;
    }

    /* Toolbar compact */
    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    /* Ảnh list-view còn nhỏ hơn nữa */
    .products-grid.list-view .product-thumb-wrap {
        flex: 0 0 80px;
        height: 70px;
    }

    /* Modal full màn hình */
    .modal {
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        min-height: 100vh;
    }
}