/* =====================================================
   ShopOnline - Minimal Dark UI
   Pure Black | Mobile-First | Kanit Font
   ===================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* Core Colors */
    --bg-base: #000000;
    --bg-card: #121212;
    --bg-elevated: #1a1a1a;
    --bg-input: #1a1a1a;
    --bg-hover: #2a2a2a;

    --border: #222222;
    --border-light: #333333;

    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --text-dim: #555555;

    /* Accent — Blue */
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-subtle: rgba(59,130,246,0.12);

    /* Semantic */
    --success: #10b981;
    --success-subtle: rgba(16,185,129,0.12);
    --warning: #f59e0b;
    --warning-subtle: rgba(245,158,11,0.12);
    --danger: #ef4444;
    --danger-subtle: rgba(239,68,68,0.12);
    --info: #3b82f6;
    --info-subtle: rgba(59,130,246,0.12);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 20px rgba(59,130,246,0.15);

    /* Transition */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.2s;
}

html {
    scroll-behavior: smooth;
    background: var(--bg-base);
}

body {
    font-family: 'Kanit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-weight: 400;
}

a {
    text-decoration: none;
    color: var(--accent);
    transition: color var(--duration) var(--ease);
}

a:hover {
    color: var(--accent-hover);
}

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

/* --- App Container (mobile-first centered) --- */
.app-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 100vh;
}

/* Legacy container (for older pages) */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 16px;
}

.main-content {
    padding-top: 0;
}

/* ========================================
   HEADER
   ======================================== */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 20px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    text-decoration: none;
}

.logo-icon {
    background: #ffffff;
    color: #000000;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wallet-badge {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: background var(--duration) var(--ease);
}

.wallet-badge:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.wallet-badge i {
    color: var(--accent);
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-btn {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--duration) var(--ease);
}

.auth-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* ---- Mobile Menu ---- */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 999;
    transition: right 0.3s var(--ease);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.mobile-menu-title {
    font-weight: 600;
    font-size: 1rem;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.mobile-menu-nav {
    padding: 8px 0;
    display: flex;
    flex-direction: column;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all var(--duration) var(--ease);
}

.mobile-menu-item:hover,
.mobile-menu-item:active {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.mobile-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}

.mobile-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 20px;
}

body.menu-open {
    overflow: hidden;
}

/* ========================================
   SECTION HEADERS
   ======================================== */
.section {
    margin-bottom: 30px;
}

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

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 600;
}

.section-title i {
    color: var(--accent);
    font-size: 1.1rem;
}

.view-all {
    color: var(--accent);
    font-size: 0.82rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 400;
}

.view-all:hover {
    color: var(--accent-hover);
}

/* ========================================
   CATEGORY CARDS
   ======================================== */
.categories-wrapper {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.categories-wrapper::-webkit-scrollbar {
    display: none;
}

.category-card {
    min-width: 90px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--duration) var(--ease);
    flex-shrink: 0;
}

.category-card:hover,
.category-card:active {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

.category-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-primary);
}

.category-name {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ========================================
   PRODUCT GRID & CARDS
   ======================================== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.product-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, background-color 0.2s;
    position: relative;
}

.product-card:hover {
    color: var(--text-primary);
}

.product-card:active {
    transform: scale(0.97);
    background-color: var(--bg-elevated);
}

.product-image-container {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background-color: var(--border);
}

.product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.badge-recommend {
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--success);
    color: #fff;
    padding: 4px 14px;
    border-radius: 0 0 12px 0;
    font-size: 0.72rem;
    font-weight: 500;
    z-index: 2;
}

.badge-pack {
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--warning);
    color: #fff;
    padding: 4px 14px;
    border-radius: 0 0 12px 0;
    font-size: 0.72rem;
    font-weight: 500;
    z-index: 2;
}

.badge-key {
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--info);
    color: #fff;
    padding: 4px 14px;
    border-radius: 0 0 12px 0;
    font-size: 0.72rem;
    font-weight: 500;
    z-index: 2;
}

.badge-discount {
    position: absolute;
    top: 0;
    right: 0;
    background-color: var(--danger);
    color: #fff;
    padding: 4px 10px;
    border-radius: 0 0 0 12px;
    font-size: 0.72rem;
    font-weight: 500;
    z-index: 2;
}

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

.product-category {
    color: var(--accent);
    font-size: 0.72rem;
    margin-bottom: 4px;
    font-weight: 400;
}

.product-title {
    font-size: 0.88rem;
    font-weight: 400;
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
    color: var(--text-primary);
}

.product-price {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.product-price-old {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-decoration: line-through;
    margin-left: 6px;
    font-weight: 400;
}

.product-stock {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.product-stock .in {
    color: var(--success);
}

.product-stock .out {
    color: var(--danger);
}

.btn-detail {
    background-color: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    padding: 8px;
    border-radius: 8px;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    text-decoration: none;
    font-weight: 400;
    cursor: pointer;
}

.btn-detail:hover,
.product-card:hover .btn-detail {
    background-color: var(--bg-hover);
    color: #fff;
}

/* ========================================
   FLASH MESSAGES
   ======================================== */
.flash-message {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid;
    animation: flashIn 0.3s var(--ease);
}

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.flash-success {
    background: var(--success-subtle);
    border-color: rgba(16,185,129,0.3);
    color: var(--success);
}

.flash-error {
    background: var(--danger-subtle);
    border-color: rgba(239,68,68,0.3);
    color: var(--danger);
}

.flash-warning {
    background: var(--warning-subtle);
    border-color: rgba(245,158,11,0.3);
    color: var(--warning);
}

.flash-info {
    background: var(--info-subtle);
    border-color: rgba(59,130,246,0.3);
    color: var(--info);
}

/* ========================================
   BUTTONS (generic)
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-light);
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   FORMS (for login, register, topup etc)
   ======================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: border-color var(--duration) var(--ease);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
}

.form-control::placeholder {
    color: var(--text-dim);
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ========================================
   FOOTER
   ======================================== */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    margin-top: 20px;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color var(--duration) var(--ease);
}

.footer-links a:hover {
    color: var(--text-primary);
}

.footer-copy {
    font-size: 0.72rem;
    color: var(--text-dim);
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}

.footer-social a {
    color: var(--text-dim);
    font-size: 1rem;
    transition: color var(--duration) var(--ease);
}

.footer-social a:hover {
    color: var(--accent);
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.3;
    display: block;
}

.empty-state h3 {
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-weight: 500;
}

.empty-state p {
    font-size: 0.82rem;
}

/* ========================================
   SKELETON LOADING
   ======================================== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.hidden { display: none !important; }

/* ========================================
   LEGACY COMPAT — header/footer classes
   used by old pages not yet rewritten
   ======================================== */
.header { display: none; }
.footer { display: none; }

/* Legacy page wrappers used by sub-pages (login, register, etc.)
   These pages have their own inline styles so we just provide
   a basic container wrapper. The header/footer are replaced. */

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}
