/**
 * RunSmart Design System
 * Unified Design Tokens & Component Styles
 * Apple HIG Compliant | Quantum-Spatial Design System
 */

/* ========================================
   WEB FONT FALLBACK FOR NON-APPLE SYSTEMS
   ======================================== */

/* Inter font for Windows/Linux - only loads if Apple fonts unavailable */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ========================================
   DESIGN TOKENS - COLOR SYSTEM
   ======================================== */

:root {
    /* Brand Colors - Primary */
    --purple-primary: #7B00FF;          /* Primary action buttons */
    --purple-hover: #8C45FF;            /* Hover state */
    --purple-pressed: #6600D6;          /* Pressed state */
    --purple-disabled: rgba(123, 0, 255, 0.4);

    /* Brand Colors - Secondary */
    --lime-primary: #CDFF00;            /* RunSmart electric lime */
    --lime-accent: #A0CC00;             /* Darker lime for gradients */
    --lime-glow: rgba(205, 255, 0, 0.2);

    /* Neutral Palette */
    --black: #000000;
    --dark-bg: #0A0A0A;
    --dark-surface: #151515;
    --border-subtle: #1A1A1A;
    --border-medium: #2A2A2A;
    --border-strong: #3A3A3A;

    /* Text Colors - WCAG AA Compliant */
    --text-primary: #FFFFFF;
    --text-secondary: #888888;          /* 4.6:1 contrast */
    --text-tertiary: #666666;           /* 3.8:1 contrast - large text only */
    --text-quaternary: #444444;         /* UI elements only */

    /* UI Colors */
    --ui-primary: #007AFF;
    
    /* Status Colors - HIG Semantic */
    --status-critical: #EF4444;         /* Red - Critical/High Risk */
    --status-warning: #F59E0B;          /* Orange - Warning/Medium Risk */
    --status-success: #10B981;          /* Green - Success/Low Risk */
    --status-info: #3B82F6;             /* Blue - Information */

    /* Medal/Gamification Colors */
    --gold: #FFD60A;
    --gold-gradient-end: #FF9F0A;
    --silver: #E5E5EA;
    --silver-dark: #AEAEB2;
    --bronze: #FF9F0A;

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

    /* Border Radius - Smooth, modern */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Shadows - Liquid glass depth */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.4);

    /* Purple glow effects */
    --glow-purple-sm: 0 0 20px rgba(123, 0, 255, 0.3);
    --glow-purple-md: 0 0 40px rgba(123, 0, 255, 0.4);
    --glow-lime-sm: 0 0 20px rgba(205, 255, 0, 0.2);

    /* Typography Scale - Apple fonts priority, Inter fallback for Windows/Linux */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, 'Inter', sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-base: 14px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 32px;
    --font-size-4xl: 48px;

    /* Font Weights */
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Transitions - Apple-like easing */
    --transition-fast: 0.15s cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-base: 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ========================================
   GLOBAL STYLES
   ======================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, 'Inter', sans-serif;
    background: var(--black);
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: #0A0A0A;
    border-right: 1px solid #1A1A1A;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #000;
}

.logo-text {
    font-size: 18px;
    font-weight: 500;
}


.header-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.detail-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.team-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.summary-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.user-name {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 2px;
    letter-spacing: -0.5px;
}



/* Main Content */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background: radial-gradient(circle at top right, #0A1A0A 0%, #000000 50%);
}

/* ========================================
   BUTTON SYSTEM - Unified Classes
   ======================================== */

.btn,
.btn-primary,
.header-button.primary,
button.primary {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
    font-family: var(--font-family);
    background: var(--purple-primary);
    color: var(--text-primary);
}

.btn-primary:hover,
.header-button.primary:hover,
button.primary:hover {
    background: var(--purple-hover);
    transform: translateY(-1px);
    box-shadow: var(--glow-purple-sm);
}

.btn-primary:active,
.header-button.primary:active,
button.primary:active {
    background: var(--purple-pressed);
    transform: translateY(0);
}

.btn-secondary,
.header-button.secondary,
button.secondary {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
    font-family: var(--font-family);
    background: var(--dark-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

.btn-secondary:hover,
.header-button.secondary:hover,
button.secondary:hover {
    background: #252525;
    border-color: var(--border-strong);
}

.btn-lime {
    background: var(--lime-primary);
    color: var(--black);
    font-weight: var(--font-weight-semibold);
}

.btn-lime:hover {
    background: var(--lime-accent);
    box-shadow: var(--glow-lime-sm);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-strong);
}

/* Button sizes */
.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: 16px 32px;
    font-size: var(--font-size-md);
}

.filter-toggle {
    display: flex;
    gap: 4px;
    background: #0A0A0A;
    border: 1px solid #1A1A1A;
    border-radius: 20px;
    padding: 4px;
}

.filter-btn {
    padding: 6px 12px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: #888888};
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background: #7B00FF;
    color: #FFFFFF;
}

.reaction-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

/* ========================================
   NAVIGATION SYSTEM
   ======================================== */

/* Tab Bar */
.bottom-nav {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 369px;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid #1A1A1A;
    border-radius: 24px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-around;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.nav-label {
    font-size: 10px;
    color: #888;
    font-weight: 500;
}

.tab-icon.active {
    color: var(--purple-primary);
}
.nav-item.active .nav-icon {
    opacity: 1;
    filter: drop-shadow(0 0 8px #7B00FF);
    color: var(--purple-primary);
}

.nav-item,
.tab-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: var(--font-size-base);
    text-decoration: none;
}

.nav-item:hover,
.tab-item:hover {
    background: var(--dark-surface);
    color: var(--text-primary);
}

.nav-item.active,
.tab-item.active {
    opacity: 1;
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

.nav-icon,
.tab-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon,
.tab-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item.active .nav-label {
    color: #FFFFFF;
    font-weight: 600;
}

/* SF Symbols Icons */
.nav-icon svg,
.status-icons svg,
.action-icon svg {
    width: 24px;
    height: 24px;
}

.notification-badge svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   CARD COMPONENTS
   ======================================== */

.card,
.stat-card,
.member-card,
.insight-card {
    background: var(--dark-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
}

.card:hover,
.stat-card:hover,
.member-card:hover {
    background: var(--dark-surface);
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ========================================
   STATUS INDICATORS
   ======================================== */

.status-critical,
.risk-critical {
    color: var(--status-critical);
}

.status-warning,
.risk-high {
    color: var(--status-warning);
}

.status-success,
.risk-low {
    color: var(--status-success);
}

.status-info {
    color: var(--status-info);
}

/* Status badges */
.badge-critical {
    background: var(--status-critical);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.badge-warning {
    background: var(--status-warning);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.badge-success {
    background: var(--status-success);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.challenge-icon {
    font-size: 32px;
}

.challenge-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(205, 255, 0, 0.2);
    border: 1px solid var{--border-medium};
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    color: #CDFF00;
    text-transform: uppercase;
}

.milestone-badge {
    display: inline-flex;
    align-items: center;
    margin-top: 4px;
    gap: 4px;
    background: rgba(205, 255, 0, 0.2);
    border: 1px solid var{--border-medium};
    padding: 4px 10px;
    border-radius: 12px;
    font-size:9px;
    font-weight: 600;
    color: #CDFF00;
    text-transform: uppercase;
}

.challenge-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--dark-bg);
    border: 1px solid var{--border-strong};
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    color: #CDFF00;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--dark-bg);
    border: 1px solid #1A1A1A;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #FF9500;
    margin-top: 8px;
}


/* ========================================
   ICON SYSTEM
   ======================================== */

.icon-sm svg {
    width: 16px;
    height: 16px;
}

.icon-base svg,
.icon svg {
    width: 20px;
    height: 20px;
}

.icon-md svg {
    width: 24px;
    height: 24px;
}

.icon-lg svg {
    width: 32px;
    height: 32px;
}

.icon-xl svg {
    width: 48px;
    height: 48px;
}

/* Icon colors */
.icon-purple svg,
.icon-purple svg path {
    stroke: var(--purple-primary);
    fill: var(--purple-primary);
}

.icon-lime svg,
.icon-lime svg path {
    stroke: var(--lime-primary);
    fill: var(--lime-primary);
}

.icon-white svg,
.icon-white svg path {
    stroke: white;
    fill: white;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

.text-purple { color: var(--purple-primary); }
.text-lime { color: var(--lime-primary); }
.text-critical { color: var(--status-critical); }
.text-warning { color: var(--status-warning); }
.text-success { color: var(--status-success); }

.bg-purple { background: var(--purple-primary); }
.bg-lime { background: var(--lime-primary); }
.bg-dark { background: var(--dark-bg); }
.bg-surface { background: var(--dark-surface); }

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

@media (max-width: 768px) {
    :root {
        --space-lg: 16px;
        --space-xl: 24px;
    }

    .btn,
    .btn-primary,
    .btn-secondary {
        padding: 10px 20px;
        font-size: var(--font-size-sm);
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus states */
button:focus-visible,
.btn:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--purple-primary);
    outline-offset: 2px;
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-subtle: #444444;
        --border-medium: #666666;
    }
}


/* Page Load Overlay */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.4s ease-out;
    pointer-events: none;
}

.page-loader.loaded {
    opacity: 0;
}

/* RunSmart Logo Animation */
.loader-logo {
    width: 80px;
    height: 80px;
    background: var{--black};
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 32px;
    color: #000;
    animation: logoFloat 1.5s ease-in-out infinite;
    box-shadow: 0 8px 32px rgba(123, 0, 255, 0.4);
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 8px 32px rgba(123, 0, 255, 0.4);
    }
    50% {
        transform: translateY(-12px) scale(1.05);
        box-shadow: 0 16px 48px rgba(123, 0, 255, 0.6);
    }
}

/* Loading Spinner */
.loader-spinner {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 3px solid rgba(123, 0, 255, 0.1);
    border-top-color: #7B00FF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Content Fade In */
body {
    opacity: 0;
    animation: fadeIn 0.6s ease-out 0.2s forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Stagger animations for cards */
.animate-stagger > * {
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-stagger > *:nth-child(1) { animation-delay: 0.1s; }
.animate-stagger > *:nth-child(2) { animation-delay: 0.2s; }
.animate-stagger > *:nth-child(3) { animation-delay: 0.3s; }
.animate-stagger > *:nth-child(4) { animation-delay: 0.4s; }
.animate-stagger > *:nth-child(5) { animation-delay: 0.5s; }
.animate-stagger > *:nth-child(6) { animation-delay: 0.6s; }

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

/* Image Styling */
.photo-frame img,
.route-preview img,
.member-avatar img,
.logo img,
.logo-icon img,
.message-avatar img,
.member-avatar-large img,
.profile-avatar img,
.conversation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit; /* Inherits parent's border-radius */
}

/* Ensure avatars maintain aspect ratio */
.photo-frame img,
.route-preview img,
.logo img,
.logo-icon img,
.member-avatar,
.message-avatar,
.member-avatar-large,
.profile-avatar,
.conversation-avatar {
    position: relative;
    overflow: hidden;
}

/* Fallback initials styling */
.avatar-initials {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: linear-gradient(135deg, #7B00FF, #A0CC00);
    color: #000;
}

/* Loading state shimmer effect */
.member-avatar img[loading="lazy"],
.conversation-avatar img[loading="lazy"] {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.03) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Photo Timeline */
.photo-timeline {
    background: #0A0A0A;
    border: 1px solid #1A1A1A;
    border-radius: 20px;
    padding: 20px;
}

.timeline-header {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
}

.timeline-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.timeline-scroll::-webkit-scrollbar {
    display: none;
}

.photo-item {
    flex-shrink: 0;
    width: 120px;
}

.photo-frame {
    width: 120px;
    height: 160px;
    background: linear-gradient(135deg, #1A1A1A 0%, #0A0A0A 100%);
    border: 1px solid #1A1A1A;
    border-radius: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.photo-date {
    font-size: 11px;
    color: #888;
    text-align: center;
}

