/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:    #2563eb;
    --primary-dk: #1d4ed8;
    --danger:     #dc2626;
    --success:    #16a34a;
    --bg:         #f8fafc;
    --surface:    #ffffff;
    --border:     #e2e8f0;
    --text:       #1e293b;
    --muted:      #64748b;
    --radius:     8px;
    --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; border-radius: var(--radius); }

/* ── Navbar ─────────────────────────────────────────────────────────────── */
#navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    align-items: center;
}

.nav-links a {
    color: var(--text);
    font-weight: 500;
    transition: color .2s;
}

.nav-links a:hover { color: var(--primary); text-decoration: none; }

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--primary);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    border-radius: 999px;
}

/* ── Main Content ───────────────────────────────────────────────────────── */
#app {
    width: 100%;
    max-width: none;
    margin: auto;
    padding: 0;
    min-height: calc(100vh - 120px);
}

/* ── Loading ────────────────────────────────────────────────────────────── */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: var(--muted);
    font-size: 1rem;
}

/* ── Flash Messages ─────────────────────────────────────────────────────── */
.flash {
    position: fixed;
    top: 110px;
    right: 1.5rem;
    padding: .75rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    box-shadow: var(--shadow-md);
    z-index: 2200;
    transition: opacity .3s;
    max-width: min(92vw, 420px);
}

.flash.success { background: var(--success); color: #fff; }
.flash.error   { background: var(--danger);  color: #fff; }
.flash.hidden  { display: none; }

@media (max-width: 991px) {
    .flash {
        top: 84px;
        right: .75rem;
        left: .75rem;
        max-width: none;
    }
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}

.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-dk); }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-outline   { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-sm        { padding: .35rem .85rem; font-size: .85rem; }
.btn:disabled  { opacity: .55; cursor: not-allowed; }

/* ── Product Grid ───────────────────────────────────────────────────────── */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow .2s, transform .2s;
    cursor: pointer;
}

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

.product-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 0;
}

.product-card .card-body { padding: 1rem; }

.product-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .price {
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.product-card .stock-badge {
    font-size: .8rem;
    color: var(--muted);
}

.out-of-stock { color: var(--danger) !important; }

/* ── Product Detail ─────────────────────────────────────────────────────── */
.product-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.product-detail img { width: 100%; max-height: 400px; object-fit: cover; }

.product-detail h1 { font-size: 1.75rem; margin-bottom: .5rem; }
.product-detail .price { font-size: 1.5rem; color: var(--primary); font-weight: 700; margin: .75rem 0; }
.product-detail .description { color: var(--muted); margin-bottom: 1rem; }

.qty-control {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
}

.qty-control input[type=number] {
    width: 70px;
    padding: .4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    font-size: 1rem;
}

/* ── Cart ───────────────────────────────────────────────────────────────── */
.cart-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.cart-table th,
.cart-table td {
    padding: .85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.cart-table th { background: var(--bg); font-weight: 700; color: var(--muted); font-size: .85rem; }
.cart-table tr:last-child td { border-bottom: none; }

.cart-summary {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 2rem;
}

.cart-total { font-size: 1.25rem; font-weight: 700; }
.cart-qty-input {
    width: 68px;
    padding: .35rem .4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
}
.cart-empty-row {
    text-align: center;
    color: var(--muted);
    padding: 2rem !important;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-card {
    max-width: 460px;
    margin: 2rem auto;
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-card h2 { margin-bottom: 1.5rem; }

/* Checkout layout */
.checkout-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.checkout-section .form-card,
.checkout-section .order-summary {
    max-width: none;
    margin: 0;
    background: var(--surface);
    padding: 1.2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.checkout-section .form-header,
.checkout-section .summary-header {
    margin-bottom: .9rem;
}

.checkout-section .form-header h3,
.checkout-section .summary-header h3 {
    margin: 0;
    font-size: 1.05rem;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.summary-table th,
.summary-table td {
    padding: .65rem .55rem;
    border-bottom: 1px solid var(--border);
    font-size: .92rem;
}

.summary-table thead th {
    color: var(--muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.summary-table tfoot td {
    font-weight: 700;
    border-bottom: 0;
}

.summary-table .summary-col-item,
.summary-table .summary-item-cell {
    text-align: left;
}

.summary-table .summary-col-qty,
.summary-table .summary-qty-cell {
    width: 72px;
    text-align: center;
    white-space: nowrap;
}

.summary-table .summary-col-price,
.summary-table .summary-price-cell {
    width: 132px;
    text-align: right;
    white-space: nowrap;
}

.summary-table .summary-item-cell {
    word-break: break-word;
}

.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: .35rem;
    font-size: .9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    transition: border-color .2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group .error-msg { color: var(--danger); font-size: .82rem; margin-top: .3rem; }

/* ── Section Headers ────────────────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 { font-size: 1.4rem; }

/* ── Category Filters ───────────────────────────────────────────────────── */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
}

.cat-btn {
    padding: .4rem .9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    font-size: .85rem;
    transition: background .2s, color .2s;
}

.cat-btn:hover,
.cat-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ── Order Confirmation ─────────────────────────────────────────────────── */
.order-success {
    text-align: center;
    padding: 3rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.order-success .check-icon { font-size: 4rem; }
.order-success h2 { margin: 1rem 0 .5rem; font-size: 1.75rem; color: var(--success); }
.order-success p  { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .product-detail { grid-template-columns: 1fr; }
    #navbar { padding: 0 1rem; }
    .nav-links { gap: 1rem; }
    #app { padding: 0; }

    .checkout-container {
        grid-template-columns: 1fr;
    }

    .checkout-section .form-card,
    .checkout-section .order-summary {
        padding: 1rem;
    }

    .cart-table thead {
        display: none;
    }

    .cart-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 10px;
        background: #fff;
    }

    .cart-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: .6rem .75rem;
        border-bottom: 1px solid #f0f0f0;
    }

    .cart-table tbody td:last-child {
        border-bottom: 0;
    }

    .cart-table tbody td::before {
        content: attr(data-label);
        font-size: 12px;
        font-weight: 700;
        color: var(--muted);
        text-transform: uppercase;
    }

    .cart-table tbody td[data-label="Action"]::before {
        content: '';
    }

    .cart-table tbody td[colspan] {
        display: block;
        text-align: center;
        padding: 14px 10px;
    }

    .cart-table tbody td[colspan]::before {
        content: '';
    }

    .cart-summary {
        margin-top: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: .75rem;
    }

    .cart-summary .btn {
        width: 100%;
        justify-content: center;
    }

    .cart-total {
        text-align: center;
    }
}

/* Cart header spacing fix */
.cart-section {
    padding-top: 18px;
}

.cart-section .section-header {
    margin-top: 6px;
}


/* ============================== */
/* Account Center */
/* ============================== */
.account-section {
    padding-bottom: 24px;
}

.account-header {
    margin-bottom: 14px;
}

.account-header h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.account-header p {
    color: var(--muted);
    margin: 0;
}

.account-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 14px;
}

.account-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.account-summary-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-summary-card__icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #fff6f4;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.account-summary-card__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.account-summary-card__label {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.2;
}

.account-summary-card__body strong {
    font-size: 15px;
    line-height: 1.2;
    color: var(--text);
}

.account-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: 88px;
    align-self: start;
}

.account-tab-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
}

.account-tab-btn i {
    margin-right: 7px;
    width: 16px;
}

.account-tab-btn.active,
.account-tab-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff8f7;
}

.account-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.account-pane {
    display: none;
}

.account-pane.active {
    display: block;
}

.account-pane__head {
    margin-bottom: 10px;
}

.account-pane__head h3 {
    margin: 0;
    font-size: 20px;
}

.account-table th {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
}

.account-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 78px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.account-chip.is-paid {
    background: #e9f8ef;
    color: #177a42;
}

.account-chip.is-partial {
    background: #fff4df;
    color: #9d6a00;
}

.account-chip.is-unpaid {
    background: #ffe8e8;
    color: #b02222;
}

.account-wishlist-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.account-wishlist-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    overflow: hidden;
}

.account-wishlist-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.account-wishlist-card__body {
    padding: 10px;
}

.account-wishlist-card__body h4 {
    margin: 0 0 6px;
    font-size: 14px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.account-wishlist-card__body p {
    margin: 0 0 8px;
    font-size: 15px;
    color: var(--primary);
    font-weight: 700;
}

.account-wishlist-card__actions {
    display: flex;
    gap: 8px;
}

.track-order-result {
    min-height: 50px;
}

.track-order-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    background: #fff;
}

.track-order-card h4 {
    margin: 0 0 6px;
    color: var(--primary);
}

.track-order-card p {
    margin: 0 0 10px;
    color: var(--muted);
}

.track-order-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.track-order-card ul {
    margin: 0;
    padding-left: 18px;
}

.account-processing-list {
    display: grid;
    gap: 10px;
}

.processing-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.processing-card__left h4 {
    margin: 0 0 4px;
    font-size: 15px;
}

.processing-card__left p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.processing-card__right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

@media (max-width: 767px) {
    .account-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 10px;
    }

    .account-summary-card {
        padding: 8px 9px;
        gap: 8px;
    }

    .account-summary-card__icon {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .account-summary-card__body strong {
        font-size: 13px;
    }

    .account-layout {
        grid-template-columns: 1fr;
    }

    .account-sidebar {
        position: static;
        top: auto;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px;
    }

    .account-tab-btn {
        flex: 0 0 calc((100% - 16px) / 3);
        min-width: 0;
        white-space: normal;
        text-align: center;
        font-size: 12px;
        line-height: 1.2;
        padding: 7px 6px;
    }

    .account-tab-btn i {
        margin-right: 4px;
        width: 14px;
    }

    .account-wishlist-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .track-order-meta {
        grid-template-columns: 1fr;
    }

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

    .processing-card__right {
        align-items: flex-start;
    }
}

@media (max-width: 767px) {
    .account-header h2 {
        font-size: 20px;
    }

    .account-pane__head h3 {
        font-size: 18px;
    }

    .account-table thead {
        display: none;
    }

    .account-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 8px;
        margin-bottom: 10px;
        background: #fff;
    }

    .account-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        border: 0;
        padding: 6px 4px;
    }

    .account-table tbody td::before {
        content: attr(data-label);
        font-size: 12px;
        font-weight: 700;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }

    .account-table tbody td[data-label="Action"] {
        justify-content: flex-end;
    }

    .account-table tbody td[data-label="Action"]::before {
        content: '';
    }

    .account-table tbody td[colspan] {
        display: block;
        text-align: center;
        padding: 10px 4px;
    }

    .account-table tbody td[colspan]::before {
        content: '';
    }
}

@media (max-width: 575px) {
    .account-content {
        padding: 10px;
    }

    .account-tab-btn {
        flex: 0 0 calc((100% - 16px) / 3);
        min-width: 0;
        padding: 6px 5px;
        font-size: 11px;
    }

    .account-wishlist-grid {
        grid-template-columns: 1fr;
    }
}

/* -- Info page -- */
.info-page .info-header {
    align-items: center;
    gap: 12px;
}

.info-page .info-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    box-shadow: var(--shadow);
    line-height: 1.8;
}

.info-page .info-content h3,
.info-page .info-content h4 {
    margin-top: 18px;
    margin-bottom: 10px;
}

.info-page .info-content p + p {
    margin-top: 12px;
}
