/* =========================================================
   MarketplaceOS -- E-commerce theme
   ========================================================= */

/* ---- CSS Variables / Theme ---- */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #f59e0b;
    --secondary-dark: #d97706;
    --accent: #10b981;
    --accent-dark: #059669;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: all 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }

/* ---- Navbar ---- */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.nav-container {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}
.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.brand-icon { font-size: 1.5rem; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}
.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: rgba(99,102,241,0.08);
}
.nav-actions { display: flex; align-items: center; gap: 1rem; }
.search-box { position: relative; }
.search-input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.875rem;
    width: 220px;
    outline: none;
    transition: var(--transition);
    font-family: var(--font);
}
.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
    width: 280px;
}
.cart-btn {
    position: relative;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1.25rem;
    transition: var(--transition);
}
.cart-btn:hover { border-color: var(--primary); }
.cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ---- Cart Sidebar ---- */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.cart-overlay.open { opacity: 1; pointer-events: auto; }
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-sidebar);
    z-index: 210;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transition: right 0.3s ease;
}
.cart-sidebar.open { right: 0; }
.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.cart-header h3 { font-size: 1.1rem; font-weight: 600; }
.cart-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.25rem;
}
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}
.cart-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 0;
}
.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-light);
    align-items: center;
}
.cart-item-img {
    width: 60px;
    height: 60px;
    background: var(--border-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 500; font-size: 0.9rem; margin-bottom: 0.25rem; }
.cart-item-price { color: var(--primary); font-weight: 600; font-size: 0.875rem; }
.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.375rem;
}
.qty-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.cart-item-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
    transition: var(--transition);
}
.cart-item-remove:hover { opacity: 0.7; }
.cart-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
}
.cart-total {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    font-family: var(--font);
    gap: 0.5rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: var(--secondary-dark); color: white; }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); color: white; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; margin-bottom: 0.5rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: 1.25rem; }
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

/* ---- Product Grid ---- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}
.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}
.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.product-img {
    height: 200px;
    background: linear-gradient(135deg, var(--border-light), var(--border));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    position: relative;
}
.product-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: var(--secondary);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.product-info { padding: 1rem 1.25rem; }
.product-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.375rem;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-seller {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.product-price-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.product-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}
.product-compare-price {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: line-through;
}
.product-rating {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.85rem;
    color: var(--secondary);
}
.product-rating .count { color: var(--text-muted); }
.product-actions { padding: 0 1.25rem 1rem; }

/* ---- Product Detail ---- */
.product-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    margin-bottom: 2rem;
}
.product-detail-img {
    background: linear-gradient(135deg, var(--border-light), var(--border));
    border-radius: var(--radius-lg);
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
}
.product-detail-info h1 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}
.product-detail-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}
.product-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
}
.add-to-cart-section {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}
.qty-input {
    width: 70px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    text-align: center;
    font-family: var(--font);
}

/* ---- Reviews ---- */
.reviews-section { margin-top: 2rem; }
.review-card {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-light);
}
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.review-author { font-weight: 600; font-size: 0.9rem; }
.review-date { font-size: 0.8rem; color: var(--text-muted); }
.review-stars { color: var(--secondary); margin-bottom: 0.375rem; font-size: 0.9rem; }
.review-title { font-weight: 600; margin-bottom: 0.25rem; }
.review-body { font-size: 0.9rem; color: var(--text-light); line-height: 1.6; }
.verified-badge {
    display: inline-block;
    background: rgba(16,185,129,0.1);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

/* ---- Seller Cards ---- */
.seller-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.seller-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
    cursor: pointer;
}
.seller-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.seller-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.seller-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
}
.seller-name { font-weight: 600; font-size: 1.05rem; }
.seller-meta { font-size: 0.8rem; color: var(--text-muted); }
.seller-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    text-align: center;
}
.seller-stat-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}
.seller-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ---- Category Pills ---- */
.category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.category-pill {
    padding: 0.375rem 1rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
    color: var(--text-light);
}
.category-pill:hover, .category-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ---- Filters Panel ---- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.filter-group { display: flex; align-items: center; gap: 0.5rem; }
.filter-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-light); }
.filter-select, .filter-input {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    outline: none;
    font-family: var(--font);
}
.filter-select:focus, .filter-input:focus { border-color: var(--primary); }
.filter-input { width: 90px; }

/* ---- Stats Dashboard ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Order Cards ---- */
.order-list { display: flex; flex-direction: column; gap: 1rem; }
.order-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}
.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.order-number { font-weight: 600; color: var(--primary); }
.order-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-paid { background: #dbeafe; color: #1e40af; }
.status-shipped { background: #e0e7ff; color: #3730a3; }
.status-delivered { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.order-meta {
    display: flex;
    gap: 2rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ---- Checkout Form ---- */
.checkout-form {
    max-width: 600px;
    margin: 0 auto;
}
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
    font-family: var(--font);
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
textarea.form-control { resize: vertical; min-height: 80px; }

/* ---- Hero / Homepage ---- */
.hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 3.5rem 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2.5rem;
    text-align: center;
}
.hero h1 { font-size: 2.25rem; font-weight: 700; margin-bottom: 0.75rem; }
.hero p { font-size: 1.1rem; opacity: 0.9; max-width: 600px; margin: 0 auto 1.5rem; }
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---- Loading / Empty States ---- */
.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 4rem;
    font-size: 1.1rem;
    color: var(--text-muted);
}
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state h3 { font-size: 1.25rem; margin-bottom: 0.5rem; color: var(--text-light); }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 2rem;
}
.page-btn {
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    font-family: var(--font);
}
.page-btn:hover, .page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Star Rating Input ---- */
.star-rating { display: flex; gap: 0.25rem; cursor: pointer; }
.star-rating .star {
    font-size: 1.5rem;
    color: var(--border);
    transition: var(--transition);
}
.star-rating .star.filled { color: var(--secondary); }
.star-rating .star:hover { color: var(--secondary-dark); }

/* ---- Toast / Notifications ---- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.toast {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    max-width: 350px;
}
.toast-success { background: var(--accent); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---- Footer ---- */
.footer {
    background: var(--text);
    color: rgba(255,255,255,0.8);
    margin-top: auto;
    padding: 2.5rem 1.5rem 1rem;
}
.footer-container {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}
.footer-section h4 {
    color: white;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}
.footer-section a {
    display: block;
    color: rgba(255,255,255,0.6);
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
}
.footer-section a:hover { color: white; }
.footer-bottom {
    grid-column: 1 / -1;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1rem;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .search-input { width: 150px; }
    .search-input:focus { width: 180px; }
    .product-detail { grid-template-columns: 1fr; }
    .product-detail-img { height: 250px; }
    .hero h1 { font-size: 1.5rem; }
    .hero p { font-size: 0.95rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .order-meta { flex-direction: column; gap: 0.5rem; }
}
@media (max-width: 480px) {
    .product-grid { grid-template-columns: 1fr; }
    .seller-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
}
