/**
 * ESDLB Mobile Design System
 * Premium Light/White Theme
 * Version 3.0
 */

/* ============================================
   ROOT VARIABLES - Premium White Theme
   ============================================ */
:root {
    /* Background Colors - Light */
    --bg-void: #F5F5F5;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F8F8;
    --bg-tertiary: #F0F0F0;
    --bg-elevated: #FFFFFF;
    --bg-surface: #FAFAFA;

    /* Text Colors */
    --text-primary: #1A1A1A;
    --text-secondary: rgba(0, 0, 0, 0.7);
    --text-tertiary: rgba(0, 0, 0, 0.5);
    --text-muted: rgba(0, 0, 0, 0.35);
    --text-disabled: rgba(0, 0, 0, 0.2);

    /* Accent Colors - Premium Purple */
    --accent-purple: #8B5CF6;
    --accent-violet: #A78BFA;
    --accent-indigo: #6366F1;
    --accent-pink: #EC4899;
    --accent-rose: #F43F5E;

    /* Semantic Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;

    /* Gradients */
    --gradient-accent: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    --gradient-dark: linear-gradient(180deg, #F8F8F8 0%, #FFFFFF 100%);
    --gradient-card: linear-gradient(180deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0) 100%);
    --gradient-glow: radial-gradient(circle at center, rgba(139, 92, 246, 0.08) 0%, transparent 70%);

    /* Shadows & Glows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);
    --glow-soft: 0 0 20px rgba(139, 92, 246, 0.2);
    --glow-strong: 0 0 40px rgba(139, 92, 246, 0.3);

    /* Borders */
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-default: rgba(0, 0, 0, 0.1);
    --border-strong: rgba(0, 0, 0, 0.15);
    --border-accent: rgba(139, 92, 246, 0.3);

    /* Typography Scale */
    --text-2xs: 0.625rem;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-extrabold: 800;

    /* Letter Spacing */
    --tracking-tighter: -0.05em;
    --tracking-tight: -0.025em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;
    --tracking-wider: 0.05em;

    /* Line Heights */
    --leading-none: 1;
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

    /* Spacing Scale */
    --space-0: 0;
    --space-0-5: 0.125rem;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;

    /* Border Radius */
    --radius-none: 0;
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-3xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --duration-75: 75ms;
    --duration-100: 100ms;
    --duration-150: 150ms;
    --duration-200: 200ms;
    --duration-300: 300ms;
    --duration-500: 500ms;
    --duration-700: 700ms;
    --ease-linear: linear;
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --header-height: 90px;
    --nav-height: 72px;
    --container-max: 430px;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================
   DARK THEME OVERRIDES
   ============================================ */
[data-theme="dark"] {
    /* Background Colors */
    --bg-void: #0A0A0F;
    --bg-primary: #111118;
    --bg-secondary: #1A1A24;
    --bg-tertiary: #22222E;
    --bg-elevated: #1E1E2A;
    --bg-surface: #161620;

    /* Text Colors */
    --text-primary: #F0F0F5;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);
    --text-muted: rgba(255, 255, 255, 0.35);
    --text-disabled: rgba(255, 255, 255, 0.2);

    /* Gradients */
    --gradient-dark: linear-gradient(180deg, #1A1A24 0%, #111118 100%);
    --gradient-card: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 100%);
    --gradient-glow: radial-gradient(circle at center, rgba(139, 92, 246, 0.12) 0%, transparent 70%);

    /* Shadows (deeper for dark) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.7);
    --glow-soft: 0 0 20px rgba(139, 92, 246, 0.25);
    --glow-strong: 0 0 40px rgba(139, 92, 246, 0.4);

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);
    --border-accent: rgba(139, 92, 246, 0.4);
}

/* Dark theme component overrides */
[data-theme="dark"] .app-header {
    background: rgba(17, 17, 24, 0.95);
}

[data-theme="dark"] .app-nav {
    background: rgba(17, 17, 24, 0.95);
}

[data-theme="dark"] .share-sheet {
    background: rgba(26, 26, 36, 0.97);
}

[data-theme="dark"] .share-preview {
    background: #22222E;
}

[data-theme="dark"] .share-preview-title {
    color: #F0F0F5;
}

[data-theme="dark"] .share-preview-source {
    color: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .share-platform-name {
    color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .share-handle {
    background: rgba(255, 255, 255, 0.15);
}

@media (min-width: 769px) {
    [data-theme="dark"] body {
        background: #000000;
    }
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--gradient-glow);
    pointer-events: none;
    z-index: -1;
}

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

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

button, input {
    font: inherit;
    border: none;
    background: none;
    outline: none;
}

button {
    cursor: pointer;
}

ul, ol {
    list-style: none;
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app-container {
    width: 100%;
    max-width: var(--container-max);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    background: var(--bg-primary);
    position: relative;
    display: flex;
    flex-direction: column;
}

@media (min-width: 769px) {
    body {
        background: #000000;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: var(--space-8);
    }

    body::before {
        background: none;
    }

    .app-container {
        height: 90vh;
        max-height: 900px;
        border-radius: var(--radius-3xl);
        overflow: hidden;
        box-shadow:
            0 0 0 1px var(--border-subtle),
            var(--shadow-2xl);
    }
}

/* ============================================
   HEADER
   ============================================ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    min-height: var(--header-height);
    padding: 0 var(--space-4);
    padding-top: var(--safe-area-top);
    gap: var(--space-4);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
}

.app-header-logo {
    flex: 1;
    display: flex;
    align-items: center;
}

.app-header-logo-mark {
    width: 32px;
    height: 32px;
    background: var(--gradient-accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-extrabold);
    font-size: var(--text-lg);
    color: white;
    box-shadow: var(--glow-soft);
}

.app-header-title {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    letter-spacing: var(--tracking-tight);
}

.app-header-actions {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-1);
}

/* Profile Avatar */
.app-header-avatar {
    width: 51px;
    height: 51px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 1.5px solid var(--border-default);
    transition: all var(--duration-200) var(--ease-out);
    flex-shrink: 0;
}

.app-header-avatar:active {
    transform: scale(0.92);
    border-color: var(--accent-purple);
}

.app-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-header-avatar-placeholder {
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.app-header-avatar-placeholder svg {
    width: 29px;
    height: 29px;
    fill: currentColor;
}

/* Icon Buttons */
.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    transition: all var(--duration-200) var(--ease-out);
}

.btn-icon:active {
    transform: scale(0.92);
    background: var(--bg-tertiary);
}

.btn-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.btn-icon-ghost {
    background: transparent;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + var(--space-4));
    -webkit-overflow-scrolling: touch;
}

.app-content::-webkit-scrollbar {
    display: none;
}

.app-content {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.app-container::-webkit-scrollbar {
    display: none;
}

.app-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--container-max);
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    padding-bottom: var(--safe-area-bottom);
}

.app-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: var(--nav-height);
    padding: 0 var(--space-2);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-2);
    color: var(--text-muted);
    transition: all var(--duration-200) var(--ease-out);
}

.nav-item.active {
    color: var(--text-primary);
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-icon {
    width: 24px;
    height: 24px;
    position: relative;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.nav-item.active .nav-icon::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--accent-purple);
    border-radius: var(--radius-full);
    box-shadow: var(--glow-soft);
}

/* Central Discovery Button */
.nav-item-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.nav-item-center-btn {
    width: 56px;
    height: 56px;
    margin-top: -20px;
    border-radius: var(--radius-full);
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        var(--glow-strong),
        var(--shadow-lg);
    transition: all var(--duration-200) var(--ease-spring);
    color: white;
}

.nav-item-center-btn:active {
    transform: scale(0.9);
}

.nav-item-center-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.nav-item-center.active .nav-item-center-btn {
    box-shadow:
        var(--glow-strong),
        var(--shadow-xl),
        0 0 0 4px rgba(139, 92, 246, 0.2);
}

.nav-label {
    font-size: var(--text-2xs);
    font-weight: var(--font-medium);
    letter-spacing: var(--tracking-wide);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-in {
    animation: fadeIn var(--duration-300) var(--ease-out);
}

.animate-slide-up {
    animation: slideUp var(--duration-500) var(--ease-out);
}

.animate-pulse {
    animation: pulse 2s var(--ease-in-out) infinite;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        var(--bg-elevated) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
