@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #fff;
    color: #111;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; }

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

/* Header */
.header { padding: 16px 0 0; position: sticky; top: 0; background: #fff; z-index: 100; }

.header-top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px 24px;
    margin-bottom: 12px;
}

.logo { font-size: clamp(22px, 4vw, 28px); font-weight: 800; letter-spacing: -0.5px; line-height: 1; }
.logo-mega { color: #2563eb; }

.search-form { width: 100%; max-width: 520px; margin: 0 auto; }

.search-bar {
    width: 100%;
    padding: 12px 20px;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    font-size: 14px;
    color: #111;
    background: #fff;
    outline: none;
}

.search-bar:focus { border-color: #2563eb; }
.search-bar::placeholder { color: #9ca3af; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    font-weight: 500;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-actions a:hover, .header-actions .link-btn:hover { color: #2563eb; }
.header-actions a.active { text-decoration: underline; text-underline-offset: 4px; }

.admin-link {
    background: #2563eb;
    color: #fff !important;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
}

.admin-link:hover { background: #1d4ed8; color: #fff !important; }

.logout-form { display: inline; }
.link-btn { background: none; border: none; cursor: pointer; font-size: 14px; font-weight: 500; color: inherit; padding: 0; }
.link-btn.danger { color: #dc2626; }

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
}

.nav-toggle span { display: block; width: 22px; height: 2px; background: #111; border-radius: 2px; }

.nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 24px;
    padding: 12px 0 16px;
    border-bottom: 1px solid #f3f4f6;
}

.nav a { font-size: 14px; font-weight: 500; color: #374151; white-space: nowrap; }
.nav a:hover, .nav a.active { color: #2563eb; }

/* Alerts */
.alert { margin: 16px auto; padding: 12px 16px; border-radius: 8px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert p + p { margin-top: 4px; }

/* Hero */
.hero { margin: 24px 0 40px; }

.hero-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 24px;
    background: #e5e5e5;
    border-radius: 16px;
    padding: clamp(24px, 5vw, 48px) clamp(24px, 5vw, 56px);
    min-height: 240px;
}

.hero-title {
    font-size: clamp(24px, 4vw, 42px);
    font-weight: 800;
    line-height: 1.15;
    text-transform: uppercase;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}

.hero-subtitle { font-size: 15px; color: #374151; max-width: 360px; }
.hero-image { display: flex; justify-content: center; align-items: center; }
.hero-image img { max-width: 100%; max-height: 200px; object-fit: contain; }

/* Sections */
.section { margin-bottom: 40px; }
.page-section { margin: 32px 0 48px; }
.section-title, .page-title { font-size: clamp(20px, 4vw, 28px); font-weight: 700; margin-bottom: 24px; }

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

/* Product card */
.product-card {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.product-card:hover {
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
    transform: translateY(-2px);
}

.product-card-image {
    display: block;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
}

.product-card-media {
    position: relative;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    overflow: hidden;
}

.product-card-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.25s ease;
}

.product-card:hover .product-card-img {
    transform: scale(1.04);
}

.product-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #eef2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: #94a3b8;
}

.product-card-body {
    background: #f3f4f6;
    padding: 14px 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card-name { font-size: 14px; font-weight: 600; margin-bottom: 8px; line-height: 1.3; }

.product-card-rating {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 12px;
    color: #374151;
    margin-bottom: 8px;
}

.stars { color: #facc15; letter-spacing: -1px; }
.product-card-price { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

.btn-cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    border: 1px solid #111;
    border-radius: 999px;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    align-self: flex-start;
}

.btn-cart:hover { background: #111; color: #fff; }

/* Empty state / Cart */
.empty-box {
    background: #e5e5e5;
    border-radius: 16px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}

.empty-text { font-size: clamp(20px, 4vw, 28px); font-weight: 700; }

.cart-layout, .checkout-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 32px;
    align-items: start;
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #e5e7eb;
}

.cart-item-info h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.cart-item-price { font-size: 14px; color: #6b7280; }

.cart-item-actions { display: flex; align-items: center; gap: 8px; }

.qty-form { display: flex; gap: 6px; align-items: center; }
.qty-input { width: 56px; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 8px; text-align: center; }

.btn-small {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}

.btn-remove {
    width: 32px;
    height: 32px;
    border: 1px solid #fca5a5;
    border-radius: 50%;
    background: #fff;
    color: #dc2626;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

.cart-item-subtotal { font-weight: 700; white-space: nowrap; }

.cart-summary {
    background: #f3f4f6;
    border-radius: 16px;
    padding: 24px;
    position: sticky;
    top: 100px;
}

.cart-summary h2 { font-size: 18px; margin-bottom: 12px; }
.cart-total { font-size: 24px; font-weight: 800; margin: 12px 0 20px; }

.cart-checkout { display: block; text-align: center; width: 100%; }

.checkout-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    margin-bottom: 8px;
}

.checkout-form { display: flex; flex-direction: column; gap: 12px; }
.checkout-input, .checkout-textarea { max-width: 100%; }
.checkout-textarea { min-height: 100px; resize: vertical; padding: 12px 16px; }

.success-box {
    background: #e5e5e5;
    border-radius: 16px;
    padding: 48px 32px;
    text-align: center;
    max-width: 560px;
    margin: 0 auto;
}

.success-box p { margin: 12px 0; color: #374151; }
.success-btn { display: inline-block; margin-top: 16px; }

/* Auth */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; }

.auth-back {
    position: absolute;
    top: 20px;
    left: 24px;
    font-size: 14px;
    color: #6b7280;
}

.auth-back:hover { color: #2563eb; }

.auth-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px 40px;
}

.auth-card { width: 100%; max-width: 400px; }

.auth-title {
    font-size: clamp(28px, 6vw, 36px);
    font-weight: 800;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 32px;
    letter-spacing: -0.5px;
}

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.auth-input {
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 4px;
    background: #e5e5e5;
    font-size: 15px;
    color: #111;
    outline: none;
}

.auth-input:focus { box-shadow: 0 0 0 2px #2563eb; }
.auth-input::placeholder { color: #6b7280; }

.auth-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 4px;
    background: #2563eb;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}

.auth-btn:hover { background: #1d4ed8; }

.auth-switch { text-align: center; margin-top: 20px; font-size: 14px; color: #6b7280; }
.auth-switch a { color: #2563eb; font-weight: 500; }
.auth-alert { width: 100%; max-width: 400px; margin-bottom: 16px; }

/* Admin */
.admin-body { display: flex; min-height: 100vh; background: #f9fafb; }

.admin-sidebar {
    width: 240px;
    background: #111;
    color: #fff;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.admin-logo { font-size: 22px; font-weight: 800; margin-bottom: 32px; color: #fff; }
.admin-logo span { color: #60a5fa; }

.admin-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.admin-nav a {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: #d1d5db;
}

.admin-nav a:hover, .admin-nav a.active { background: #1f2937; color: #fff; }

.admin-logout {
    margin-top: auto;
    padding: 10px 12px;
    background: none;
    border: 1px solid #374151;
    border-radius: 8px;
    color: #d1d5db;
    cursor: pointer;
    font-size: 14px;
}

.admin-main { flex: 1; padding: 32px; overflow-x: auto; }

.admin-page-title { font-size: 28px; font-weight: 700; margin-bottom: 24px; }
.admin-subtitle { font-size: 18px; font-weight: 600; margin: 32px 0 16px; }

.admin-header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.admin-header-row .admin-page-title { margin-bottom: 0; }

.admin-btn { width: auto; display: inline-block; padding: 10px 20px; font-size: 14px; }

.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }

.admin-stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
}

.admin-stat-value { display: block; font-size: 32px; font-weight: 800; }
.admin-stat-label { font-size: 14px; color: #6b7280; }

.admin-table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; border: 1px solid #e5e7eb; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f3f4f6; }
.admin-table th { background: #f9fafb; font-weight: 600; }
.admin-table a { color: #2563eb; }
.admin-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }

.admin-form { max-width: 480px; display: flex; flex-direction: column; gap: 12px; }
.admin-label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.admin-checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.admin-file-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
}
.admin-image-preview {
    width: 140px;
    height: 140px;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 10px;
    margin-top: 4px;
}
.admin-hint { font-size: 12px; color: #6b7280; font-weight: 400; }
.admin-table-thumb {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 4px;
    display: block;
}

.status-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; }
.status-form .auth-input { width: auto; min-width: 180px; }

.order-detail { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px; margin-bottom: 24px; }
.order-detail p { margin-bottom: 8px; font-size: 14px; }

.pagination-wrap { margin-top: 24px; }

/* Footer */
.footer { background: #e5e5e5; padding: 40px 0; margin-top: 24px; }
.footer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; }
.footer-col h4 { font-size: 14px; font-weight: 700; margin-bottom: 16px; text-transform: uppercase; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 10px; }
.footer-col a { font-size: 14px; color: #374151; }
.footer-col a:hover { color: #2563eb; }

/* Responsive */
@media (max-width: 1024px) {
    .products-grid { grid-template-columns: repeat(3, 1fr); }
    .hero-inner { grid-template-columns: 1fr; text-align: center; }
    .hero-subtitle { margin: 0 auto; }
    .cart-layout, .checkout-layout { grid-template-columns: 1fr; }
    .cart-summary { position: static; }
}

@media (max-width: 768px) {
    .header-top {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
    }

    .logo { grid-column: 1; grid-row: 1; }
    .nav-toggle { display: flex; grid-column: 2; grid-row: 1; }
    .search-form { grid-column: 1 / -1; grid-row: 2; max-width: 100%; }
    .header-actions {
        grid-column: 1 / -1;
        grid-row: 3;
        justify-content: center;
        gap: 12px;
        font-size: 13px;
        flex-wrap: wrap;
    }

    .search-bar { font-size: 16px; }

    .nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
        border-bottom: none;
    }

    .nav.open {
        display: flex;
        border-bottom: 1px solid #f3f4f6;
        padding-bottom: 12px;
    }

    .nav a { padding: 10px 0; border-bottom: 1px solid #f3f4f6; }

    .hero { margin: 16px 0 32px; }
    .hero-inner { padding: 24px 20px; min-height: auto; }
    .section { margin-bottom: 32px; }
    .page-section { margin: 24px 0 36px; }

    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .product-card-media { padding: 14px; }
    .product-card-body { padding: 12px 10px 14px; }
    .product-card-name { font-size: 13px; }
    .product-card-price { font-size: 15px; }
    .btn-cart { min-height: 36px; padding: 8px 14px; }

    .footer-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
    .footer { padding: 32px 0; }

    .admin-body { flex-direction: column; }
    .admin-sidebar { width: 100%; padding: 16px; }
    .admin-nav { flex-direction: row; flex-wrap: wrap; gap: 8px; }
    .admin-nav a { padding: 8px 12px; }
    .admin-logout { margin-top: 12px; width: 100%; }
    .admin-main { padding: 20px 16px; }
    .admin-page-title { font-size: 22px; }
    .admin-form { max-width: 100%; }
    .admin-stats { grid-template-columns: 1fr; }
    .admin-table { font-size: 13px; }
    .admin-table th, .admin-table td { padding: 10px 12px; }

    .cart-item { grid-template-columns: 1fr; gap: 8px; }
    .cart-item-actions { justify-content: flex-start; }
    .cart-item-subtotal { font-size: 18px; }
    .qty-input { font-size: 16px; min-height: 40px; }
    .auth-btn { min-height: 48px; }
}

@media (max-width: 480px) {
    .products-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .container { padding: 0 16px; }
    .header-actions { font-size: 12px; gap: 10px; }
    .admin-header-row { flex-direction: column; align-items: stretch; }
    .admin-header-row .auth-btn { width: 100%; text-align: center; }
    .product-card-rating { font-size: 11px; }
    .btn-cart { width: 100%; justify-content: center; }
    .success-box { padding: 32px 20px; }
}
