/* ============================================
   KasiConnect Marketplace - Stylesheet
   ============================================ */

/* Design tokens */
:root {
    --primary: #0f766e;
    --primary-dark: #0d5d57;
    --primary-light: #14b8a6;
    --accent: #f59e0b;
    --accent-dark: #d97706;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --bg: #fafafa;
    --bg-card: #ffffff;
    --bg-subtle: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #ea580c;
    --warning-bg: #fff7ed;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #0284c7;
    --info-bg: #f0f9ff;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.06), 0 4px 8px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
    color: var(--primary-dark);
}

h1, h2, h3, h4 {
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.3;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

p {
    color: var(--text-secondary);
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    background: white;
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.nav-brand a {
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-brand a::before {
    content: "";
    display: inline-block;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 8px;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-links a:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 8px 14px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
    max-width: 1280px;
    margin: 32px auto;
    padding: 0 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    color: var(--text-primary);
}

/* ============================================
   HERO (homepage)
   ============================================ */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 60px 40px;
    border-radius: var(--radius-xl);
    margin-bottom: 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.hero::after {
    content: "";
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: 0 auto;
}

.hero h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 16px;
    font-weight: 800;
}

.hero p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    margin-bottom: 24px;
}

.hero-tagline {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 20px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

button[type="submit"] {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

button[type="submit"]:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ============================================
   FORMS
   ============================================ */
.auth-container,
.form-card {
    max-width: 480px;
    margin: 60px auto;
    padding: 40px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.form-card {
    max-width: 640px;
}

.auth-container h1,
.form-card h1 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 1.5rem;
    text-align: center;
}

label {
    display: block;
    margin-top: 18px;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    background: white;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 14px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    border: 1px solid;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #fecaca;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #bbf7d0;
}

.alert ul {
    margin-left: 20px;
}

/* ============================================
   PRODUCT CARDS
   ============================================ */
.product-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.product-card-link:hover {
    text-decoration: none;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card-link:hover .product-card,
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.product-image,
.product-image-placeholder {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--bg-subtle);
}

.product-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.product-info {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-info h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.4;
}

.product-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.product-price {
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 4px;
}

.product-stock,
.product-seller {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================
   STATUS BADGES
   ============================================ */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 8px;
}

.status-active { background: var(--success-bg); color: var(--success); }
.status-inactive { background: #f1f5f9; color: var(--text-muted); }
.status-pending_review { background: var(--warning-bg); color: var(--warning); }
.status-pending { background: var(--warning-bg); color: var(--warning); }
.status-paid { background: var(--info-bg); color: var(--info); }
.status-shipped { background: #ddd6fe; color: #6d28d9; }
.status-delivered { background: var(--success-bg); color: var(--success); }
.status-cancelled { background: var(--danger-bg); color: var(--danger); }
.status-no_pop { background: #f1f5f9; color: var(--text-muted); }
.status-confirmed { background: var(--success-bg); color: var(--success); }
.status-rejected { background: var(--danger-bg); color: var(--danger); }
.status-buyer { background: var(--info-bg); color: var(--info); }
.status-seller { background: var(--warning-bg); color: var(--warning); }
.status-admin { background: #fce7f3; color: #be185d; }
.status-open { background: var(--warning-bg); color: var(--warning); }
.status-resolved { background: var(--success-bg); color: var(--success); }
.status-dismissed { background: #f1f5f9; color: var(--text-muted); }

/* ============================================
   BROWSE LAYOUT
   ============================================ */
.browse-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 32px;
}

.filter-sidebar {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.filter-sidebar h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.category-list {
    list-style: none;
}

.category-list li {
    margin-bottom: 2px;
}

.category-list a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 12px;
    display: block;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: var(--transition);
}

.category-list a:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.category-list a.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

/* ============================================
   PRODUCT DETAIL
   ============================================ */
.product-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.product-detail-image img {
    width: 100%;
    border-radius: var(--radius);
    object-fit: cover;
    max-height: 500px;
}

.product-image-placeholder.large {
    height: 400px;
    border-radius: var(--radius);
}

.product-detail-info h1 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 1.75rem;
}

.product-price-large {
    font-size: 2rem;
    color: var(--primary);
    font-weight: 800;
    margin-bottom: 16px;
}

.product-stock-info {
    margin-bottom: 24px;
    color: var(--text-secondary);
}

.out-of-stock {
    color: var(--danger);
    font-weight: 600;
}

.seller-info,
.product-description {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.seller-info h3,
.product-description h3 {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.verified-badge {
    background: var(--success-bg);
    color: var(--success);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

.product-actions {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.product-actions form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.product-actions input[type="number"] {
    width: 90px;
}

.product-actions button {
    margin-top: 0;
    width: auto;
    padding: 14px 28px;
}

.info-note {
    padding: 14px 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid var(--border);
}

/* ============================================
   CHECKOUT / ORDER PAGES
   ============================================ */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.summary-table td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
}

.summary-table td:first-child {
    color: var(--text-secondary);
    width: 40%;
    font-size: 0.9rem;
}

.summary-table .total-row td {
    border-top: 2px solid var(--text-primary);
    border-bottom: none;
    padding-top: 16px;
    font-size: 1.15rem;
}

.order-summary {
    background: var(--bg-subtle);
    padding: 20px;
    border-radius: var(--radius);
    margin: 20px 0;
    border: 1px solid var(--border);
}

.order-summary h3 {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 12px;
}

.checkout-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-secondary {
    flex: 1;
    text-align: center;
    background: white;
    color: var(--text-primary);
    padding: 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1.5px solid var(--border);
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.checkout-actions .btn-primary {
    flex: 1;
    padding: 14px;
}

.payment-instructions {
    margin-top: 28px;
    padding: 20px;
    background: var(--warning-bg);
    border-left: 4px solid var(--warning);
    border-radius: var(--radius-sm);
}

.payment-instructions h3 {
    color: var(--warning);
    margin-bottom: 10px;
}

.payment-instructions p {
    text-align: left;
    margin-bottom: 10px;
    color: #92400e;
    font-size: 0.9rem;
}

/* ============================================
   TABLES (Orders, Sales, Admin)
   ============================================ */
.orders-table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    overflow-x: auto;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table th,
.orders-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.orders-table th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.orders-table tr:last-child td {
    border-bottom: none;
}

.orders-table tr:hover {
    background: var(--bg-subtle);
}

.link-action {
    display: inline-block;
    padding: 6px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    margin: 2px;
    transition: var(--transition);
}

.link-action:hover {
    background: var(--primary-dark);
    color: white;
    transform: translateY(-1px);
}

.btn-confirm {
    background: var(--success);
}

.btn-confirm:hover {
    background: #15803d;
}

.btn-reject {
    background: var(--danger);
}

.btn-reject:hover {
    background: #b91c1c;
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* ============================================
   ADMIN DASHBOARD
   ============================================ */
.admin-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

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

.stat-card.stat-alert {
    border-left-color: var(--accent);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    font-weight: 600;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.stat-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================
   FILTER TABS
   ============================================ */
.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

.filter-tab {
    padding: 10px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.filter-tab:hover {
    color: var(--primary);
}

.filter-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ============================================
   CARD ACTIONS
   ============================================ */
.card-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.card-actions .link-action {
    flex: 1;
    text-align: center;
}

/* ============================================
   EMPTY STATE & FOOTER
   ============================================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.footer {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 60px;
    border-top: 1px solid var(--border);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .navbar {
        padding: 14px 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .nav-links {
        width: 100%;
        flex-wrap: wrap;
    }

    .hero {
        padding: 40px 24px;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

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

    .filter-sidebar {
        position: static;
    }

    .product-detail {
        grid-template-columns: 1fr;
        padding: 24px;
    }

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

    .container {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .auth-container,
    .form-card {
        margin: 20px;
        padding: 24px;
    }

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