/**
 * NJOKI Marketplace - Modern Gamer Dark Theme Stylesheet
 * Optimized for Mobile-First, OLED Battery Saving, and Ergonomic Touch Targets
 * Strict 8pt Spacing, WCAG AA contrast, and World-Class Micro-interactions
 */

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

/* ============================================
   Design Tokens (CSS Variables)
   ============================================ */
:root {
    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Outfit', var(--font-sans);

    /* Color Palette (Premium OLED Dark Mode) */
    --bg-color: #030308;
    --surface-color: #0E0E1B;
    --surface-light: #16162E;
    --border-color: #1F1F3D;
    
    --primary-color: #6C3DE8;
    --primary-hover: #5A2ECC;
    --primary-light: #8B61F0;
    
    --secondary-color: #1AE8A0;
    --secondary-hover: #14C485;
    
    --text-primary: #F3F3F7;
    --text-secondary: #9494B8;
    --text-muted: #64648A;
    --text-disabled: #474766;
    
    /* Semantic Alert Colors */
    --danger-color: #FF4A4A;
    --danger-bg: rgba(255, 74, 74, 0.12);
    --warning-color: #FBBF24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --success-color: #10B981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --info-color: #3B82F6;
    --info-bg: rgba(59, 130, 246, 0.12);
    
    --star-color: #F59E0B;
    
    /* Spacing Scale (8-Point Grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

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

    /* Shadows & Glows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.6);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.7);
    --shadow-lg: 0 12px 28px rgba(0,0,0,0.85);
    --glow-primary: 0 0 16px rgba(108, 61, 232, 0.35);
    --glow-secondary: 0 0 16px rgba(26, 232, 160, 0.25);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-base: 250ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================
   Base CSS Overrides & Reset
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: calc(64px + env(safe-area-inset-bottom)); /* Reserve room for mobile bottom nav + Safe Area */
}

@media (min-width: 768px) {
    body {
        padding-bottom: 0; /* Remove bottom nav padding on desktop */
    }
}

/* Smooth custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Base typography hierarchy */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.2;
}

h1 { font-size: 32px; letter-spacing: -0.02em; }
h2 { font-size: 24px; letter-spacing: -0.01em; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
p { color: var(--text-secondary); line-height: 1.5; }

/* Safe Area support variables */
.safe-top {
    padding-top: env(safe-area-inset-top);
}
.safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
}

/* ============================================
   Ergonomic Custom Components
   ============================================ */

/* Primary, Secondary, Outline Button Component */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 48px; /* Safe mobile touch target */
    padding: 0 var(--space-5);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    outline: none;
}

.btn:active:not(:disabled) {
    transform: scale(0.96); /* Instant micro-interaction haptic feel */
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary-color);
    color: #FFFFFF;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--glow-primary);
}

.btn-secondary {
    background: var(--secondary-color);
    color: #030308;
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
    box-shadow: var(--glow-secondary);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--text-secondary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    box-shadow: none;
}
.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
}

/* Premium Form Inputs (Min 52px height for mobile fields) */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    min-height: 52px; /* Extra ergonomic finger room */
    padding: 0 var(--space-4);
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--surface-color);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all var(--transition-fast);
}

.form-textarea {
    padding: var(--space-3) var(--space-4);
    min-height: 120px;
    resize: vertical;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary-light);
    background: var(--surface-light);
    box-shadow: 0 0 12px rgba(108, 61, 232, 0.2);
}

.form-input.error {
    border-color: var(--danger-color);
    background: var(--danger-bg);
}

.form-error {
    font-size: 12px;
    color: var(--danger-color);
    margin-top: var(--space-1);
    font-weight: 500;
}

/* Premium Cards with Subtle Border Glows */
.card {
    background: var(--surface-color);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    overflow: hidden;
}

.card-hover:hover {
    transform: translateY(-4px);
    border-color: rgba(108, 61, 232, 0.4);
    box-shadow: var(--glow-primary);
}

/* Service Card Design */
.service-card {
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-base);
}

.service-card:hover {
    transform: translateY(-4px);
    border-color: rgba(108, 61, 232, 0.4);
    box-shadow: var(--glow-primary);
}

.service-card-img-wrapper {
    position: relative;
    aspect-ratio: 16/10;
    overflow: hidden;
    background: #000000;
}

.service-card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.service-card:hover .service-card-img-wrapper img {
    transform: scale(1.05);
}

.service-card-badge {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 10;
    background: rgba(3, 3, 8, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    padding: 4px var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    color: var(--secondary-color);
    text-transform: uppercase;
}

.service-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: var(--space-4);
}

.service-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #FFFFFF;
    margin-bottom: var(--space-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 40px;
    line-height: 1.35;
}

.service-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1.5px solid var(--border-color);
}

/* Game Card Design */
.game-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1.5px solid var(--border-color);
    transition: all var(--transition-base);
}

.game-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.game-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--glow-primary);
}

.game-card:hover img {
    transform: scale(1.06);
}

.game-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(3, 3, 8, 0.95) 0%, rgba(3, 3, 8, 0.4) 50%, transparent 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--space-3);
    transition: background var(--transition-base);
}

.game-card:hover .game-card-overlay {
    background: linear-gradient(to top, rgba(108, 61, 232, 0.6) 0%, rgba(3, 3, 8, 0.5) 60%, transparent 100%);
}

/* ============================================
   Shimmer & Skeleton Loadings
   ============================================ */
.shimmer {
    background: linear-gradient(
        90deg,
        var(--surface-color) 25%,
        var(--surface-light) 50%,
        var(--surface-color) 75%
    );
    background-size: 200% 100%;
    animation: shimmerEffect 1.5s infinite linear;
}

@keyframes shimmerEffect {
    to {
        background-position: -200% 0;
    }
}

/* Badges Component */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px var(--space-2);
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}
.badge-success { background: var(--success-bg); color: var(--secondary-color); }
.badge-warning { background: var(--warning-bg); color: var(--warning-color); }
.badge-danger { background: var(--danger-bg); color: var(--danger-color); }

/* ============================================
   Sticky Bottom Navigation
   ============================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(14, 14, 27, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1.5px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.8);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    flex: 1;
    height: 64px;
    transition: all var(--transition-fast);
}

.bottom-nav-item i {
    font-size: 22px;
    margin-bottom: 2px;
    transition: all var(--transition-fast);
}

.bottom-nav-item.active {
    color: var(--secondary-color);
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
    text-shadow: var(--glow-secondary);
}

/* ============================================
   Bottom Sheet (Drawer style Modal)
   ============================================ */
.bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.bottom-sheet.active {
    display: flex;
}

.bottom-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    transition: opacity var(--transition-base);
}

.bottom-sheet-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--surface-color);
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    border: 1.5px solid var(--border-color);
    border-bottom: none;
    padding: var(--space-6) var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg);
    z-index: 10;
    transform: translateY(100%);
    animation: slideUpSheet var(--transition-base) forwards;
}

@keyframes slideUpSheet {
    to {
        transform: translateY(0);
    }
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--text-disabled);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-4);
}

/* ============================================
   Toast UI
   ============================================ */
.toast-container {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: var(--space-4);
    right: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 500;
    pointer-events: none;
}

@media (min-width: 640px) {
    .toast-container {
        left: auto;
        right: var(--space-6);
        width: 360px;
    }
}

.toast {
    pointer-events: auto;
    background: var(--surface-light);
    border: 1.5px solid var(--border-color);
    border-left: 4px solid var(--info-color);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    min-height: 48px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    transform: translateY(20px);
    opacity: 0;
    animation: toastIn var(--transition-fast) forwards;
}

@keyframes toastIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast-success { border-left-color: var(--secondary-color); }
.toast-error { border-left-color: var(--danger-color); }
.toast-warning { border-left-color: var(--warning-color); }
