/* ==========================================
   SportShop - Giao diện kiểu Shopee
   Mobile First
   ========================================== */

:root {
    --orange: #ee4d2d;
    --orange-dark: #d63e22;
    --orange-light: #fff1ed;
    --yellow: #f5a623;
    --text: #222;
    --text-sub: #666;
    --text-light: #999;
    --border: #e5e5e5;
    --bg: #f5f5f5;
    --white: #fff;
    --green: #00aa5b;
    --rating: #ff8a00;
    --radius: 8px;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: env(safe-area-inset-bottom);
}

img {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
}

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

.site-header {
    background: var(--orange);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--white);
    text-decoration: none;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 22px;
}

.logo-text {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.search-area {
    flex: 1;
    min-width: 0;
}

.search-box {
    position: relative;
    display: flex;
    background: var(--white);
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: #ffc700;
}

.search-box input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: transparent;
}

.search-btn {
    background: var(--white);
    color: var(--orange);
    border: none;
    padding: 0 14px;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.search-btn:hover {
    background: #ffe9e4;
}

.cart-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: var(--white);
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}

.cart-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.cart-badge {
    position: absolute;
    top: -2px;
    right: 0;
    background: var(--yellow);
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
}

/* Nav - ẩn trên mobile */
.main-nav {
    display: none;
    background: var(--orange-dark);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 12px;
    display: flex;
    gap: 4px;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
    border-bottom: 2px solid transparent;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(0, 0, 0, 0.12);
    border-bottom-color: var(--yellow);
}

.flash-link {
    color: var(--yellow);
    font-weight: 700;
}

/* ============ CONTAINER ============ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px;
}

/* ============ FLASH SALE ============ */

.flash-sale {
    background: linear-gradient(135deg, #ff6b3d 0%, #ee4d2d 100%);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.flash-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

.flash-title {
    color: var(--white);
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.flash-timer {
    display: flex;
    align-items: center;
    gap: 2px;
}

.tbox {
    background: #2b2b2b;
    color: var(--white);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 5px;
    border-radius: 4px;
    min-width: 22px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.tsep {
    color: var(--white);
    font-weight: 700;
    font-size: 12px;
}

.flash-more {
    margin-left: auto;
    color: var(--white);
    font-size: 12px;
    text-decoration: none;
    font-weight: 500;
    opacity: 0.9;
    white-space: nowrap;
}

.flash-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 14px 14px;
    scrollbar-width: none;
}

.flash-list::-webkit-scrollbar {
    display: none;
}

.flash-item {
    flex-shrink: 0;
    width: 104px;
    background: var(--white);
    border-radius: 6px;
    overflow: hidden;
    text-align: center;
    padding-bottom: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.flash-item:active {
    transform: scale(0.96);
}

.flash-item img {
    width: 100%;
    height: 104px;
    object-fit: cover;
    background: #f0f0f0;
}

.flash-item .fi-price {
    color: var(--orange);
    font-size: 13px;
    font-weight: 700;
    margin-top: 6px;
    padding: 0 6px;
}

.flash-item .fi-old {
    color: var(--text-light);
    font-size: 11px;
    text-decoration: line-through;
}

.flash-item .fi-discount {
    display: inline-block;
    background: var(--orange);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
}

/* ============ BANNER ============ */

.banner {
    background: linear-gradient(120deg, #2c3e50 0%, #34495e 60%, #3d566e 100%);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 20px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow);
}

.banner-content {
    position: relative;
    z-index: 1;
}

.banner h2 {
    color: var(--white);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.banner p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    margin-bottom: 12px;
}

.banner-btn {
    background: var(--orange);
    color: var(--white);
    border: none;
    padding: 9px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s, transform 0.2s;
}

.banner-btn:hover {
    background: var(--orange-dark);
    transform: translateY(-1px);
}

.banner-deco {
    font-size: 56px;
    opacity: 0.85;
    flex-shrink: 0;
}

/* ============ FILTER BAR ============ */

.filter-bar {
    background: var(--white);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow);
}

.filter-cats {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.filter-cats::-webkit-scrollbar {
    display: none;
}

.cat-chip {
    background: var(--bg);
    color: var(--text-sub);
    border: 1px solid transparent;
    padding: 7px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
}

.cat-chip:hover {
    color: var(--orange);
    border-color: var(--orange);
}

.cat-chip.active {
    background: var(--orange);
    color: var(--white);
    border-color: var(--orange);
}

.sort-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.sort-bar label {
    font-size: 13px;
    color: var(--text-sub);
    white-space: nowrap;
}

.sort-bar select {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    outline: none;
}

.sort-bar select:focus {
    border-color: var(--orange);
}

/* ============ SECTION TITLE ============ */

.section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    padding-left: 10px;
    border-left: 3px solid var(--orange);
    line-height: 1.2;
}

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

.products {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.product-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s;
    box-shadow: var(--shadow);
    position: relative;
}

.product-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.product-thumb {
    position: relative;
    display: block;
    background: #f5f5f5;
}

.product-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: #f0f0f0;
}

.discount-badge {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--orange);
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 0 0 6px 0;
    z-index: 2;
}

.sold-out {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: 13px;
    z-index: 3;
}

.product-info {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-name {
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
    line-height: 1.4;
}

.product-price-row {
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-wrap: wrap;
}

.product-price {
    color: var(--orange);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.product-original {
    color: var(--text-light);
    font-size: 11px;
    text-decoration: line-through;
}

.product-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-light);
    flex-wrap: wrap;
}

.rating {
    color: var(--rating);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.rating svg {
    width: 11px;
    height: 11px;
}

.sold-count {
    color: var(--text-light);
}

.ship-tag {
    color: var(--green);
    font-weight: 500;
}

.product-shop {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-to-cart {
    margin-top: 8px;
    background: var(--orange);
    color: var(--white);
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s;
    min-height: 34px;
}

.add-to-cart:hover {
    background: var(--orange-dark);
}

.add-to-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.empty-result {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-light);
    font-size: 14px;
}

/* ============ MODAL ============ */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
}

/* Chỉ hiện modal khi được bật (class .open do JS thêm/xoá) */
.modal.open {
    display: flex;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
    animation: slideUp 0.25s ease;
    overflow: hidden;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    background: var(--orange);
    color: var(--white);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.close-btn {
    background: transparent;
    color: var(--white);
    border: none;
    font-size: 26px;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.close-btn:hover {
    opacity: 1;
}

.cart-items {
    padding: 12px 16px;
    overflow-y: auto;
    max-height: 55vh;
}

.cart-item {
    display: flex;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.cart-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.cart-item img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    background: #f0f0f0;
    flex-shrink: 0;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-price {
    color: var(--orange);
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 7px;
}

.cart-item-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.qty-btn {
    background: var(--white);
    border: none;
    width: 28px;
    height: 26px;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    transition: background 0.15s;
}

.qty-btn:hover {
    background: var(--bg);
}

.qty-value {
    width: 32px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    line-height: 26px;
}

.remove-btn {
    background: transparent;
    color: var(--text-light);
    border: none;
    font-size: 11px;
    margin-left: 10px;
    padding: 4px;
    transition: color 0.2s;
}

.remove-btn:hover {
    color: var(--orange);
}

.cart-footer {
    padding: 14px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    background: var(--white);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    font-size: 14px;
}

.cart-total {
    color: var(--orange);
    font-size: 20px;
    font-weight: 700;
}

.checkout-btn {
    width: 100%;
    background: var(--orange);
    color: var(--white);
    border: none;
    padding: 13px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.2s, transform 0.15s;
    min-height: 48px;
}

.checkout-btn:hover:not(:disabled) {
    background: var(--orange-dark);
}

.checkout-btn:active:not(:disabled) {
    transform: scale(0.99);
}

.checkout-btn:disabled {
    background: #bbb;
    cursor: not-allowed;
}

/* Form thanh toán */
.checkout-modal-content {
    max-height: 94vh;
}

.checkout-form {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.checkout-form label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
    margin-bottom: 5px;
}

.checkout-form label:not(:first-child) {
    margin-top: 12px;
}

.checkout-form .req {
    color: var(--orange);
}

.checkout-form input,
.checkout-form textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--text);
    outline: none;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.checkout-form input:focus,
.checkout-form textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 2px rgba(238, 77, 45, 0.1);
}

.form-error {
    color: #d63031;
    font-size: 12px;
    margin-top: 12px;
    padding: 9px 11px;
    background: #fff0f0;
    border-radius: 6px;
}

.checkout-form .checkout-btn {
    margin-top: 16px;
}

/* ============ ĐĂNG NHẬP / ĐĂNG KÝ ============ */

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--white);
}

.auth-tab {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-sub);
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.auth-tab:hover {
    color: var(--orange);
}

.auth-tab.active {
    color: var(--orange);
    border-bottom-color: var(--orange);
}

.account-btn {
    max-width: 130px;
}

.account-btn #accountText {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============ TOAST ============ */

.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    background: rgba(0, 0, 0, 0.85);
    color: var(--white);
    padding: 11px 18px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
    max-width: calc(100% - 32px);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--green);
}

.toast.error {
    background: #d63031;
}

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

.site-footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    margin-top: 24px;
    padding: 20px 12px 16px;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.footer-col h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.footer-col p {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.7;
}

.copyright {
    max-width: 1200px;
    margin: 16px auto 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
}

/* ==========================================
   BREAKPOINT: TABLET (768px)
   ========================================== */
@media (min-width: 768px) {
    .header-inner {
        padding: 12px 16px;
        gap: 20px;
    }

    .logo-text {
        font-size: 22px;
    }

    .search-box input {
        padding: 10px 14px;
        font-size: 15px;
    }

    .main-nav {
        display: block;
    }

    .cart-text {
        display: inline;
    }

    .container {
        padding: 16px;
    }

    .flash-header {
        padding: 14px 18px;
    }

    .flash-title {
        font-size: 20px;
    }

    .flash-item {
        width: 130px;
    }

    .flash-item img {
        height: 130px;
    }

    .banner {
        padding: 30px 28px;
    }

    .banner h2 {
        font-size: 26px;
    }

    .banner p {
        font-size: 14px;
    }

    .banner-deco {
        font-size: 80px;
    }

    .filter-bar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        gap: 16px;
    }

    .sort-bar {
        border-top: none;
        padding-top: 0;
        flex-shrink: 0;
    }

    .sort-bar select {
        flex: none;
        width: 170px;
    }

    .products {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .product-info {
        padding: 10px 12px 12px;
    }

    .product-name {
        font-size: 14px;
        min-height: 40px;
    }

    .product-price {
        font-size: 17px;
    }

    .section-title {
        font-size: 18px;
    }

    .modal.open {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .modal-content {
        position: relative;
        bottom: auto;
        width: 500px;
        max-width: 100%;
        max-height: 88vh;
        border-radius: 10px;
        animation: none;
    }

    .cart-items {
        max-height: 52vh;
    }

    .footer-inner {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
}

/* ==========================================
   BREAKPOINT: DESKTOP (1024px)
   ========================================== */
@media (min-width: 1024px) {
    .header-inner {
        padding: 14px 20px;
    }

    .search-area {
        max-width: 640px;
    }

    .container {
        padding: 20px;
    }

    .products {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }

    .flash-item {
        width: 150px;
    }

    .flash-item img {
        height: 150px;
    }

    .flash-list {
        gap: 12px;
    }

    .banner {
        padding: 40px 36px;
    }

    .banner h2 {
        font-size: 30px;
    }

    .banner-deco {
        font-size: 110px;
    }
}

/* ==========================================
   BREAKPOINT: LARGE (1280px)
   ========================================== */
@media (min-width: 1280px) {
    .products {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Màn hình nhỏ */
@media (max-width: 360px) {
    .logo-text {
        display: none;
    }

    .products {
        gap: 6px;
    }

    .product-info {
        padding: 7px 8px 9px;
    }

    .banner-deco {
        font-size: 42px;
    }
}
