/* ============================================
   FINBUDDY SHARED STYLES v1.0
   Responsive + Design System Tokens
   ============================================ */

/* --------------------------------------------
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   From: Design System/finbuddy_design_system.html
   -------------------------------------------- */
:root {
    /* Core Palette */
    --fin-bg: #ffffff;
    --fin-surface: #F9FAFB;
    --fin-border: #F3F4F6;
    
    /* Typography Colors */
    --fin-text-main: #121212;
    --fin-text-sub: #6B7280;
    
    /* Accent Colors (Liquid Metal Identity) */
    --fin-accent: #D4AF37;
    --fin-accent-light: #F3E5AB;
    --fin-accent-dark: #B8860B;
    
    /* Functional Colors */
    --fin-positive: #10B981;
    --fin-negative: #EF4444;
    --fin-btn-bg: #121212;
    --fin-btn-text: #ffffff;
    
    /* Effects & Shadows */
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-gold: 0 10px 30px -10px rgba(212, 175, 55, 0.25);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.4);
    
    /* Safe Areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* --------------------------------------------
   2. BASE STYLES
   -------------------------------------------- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f0f0f0;
    color: var(--fin-text-main);
    margin: 0;
    padding: 0;
    min-height: 100%;
    min-height: -webkit-fill-available;
    overflow: hidden;
}

/* --------------------------------------------
   3. RESPONSIVE IPHONE FRAME
   -------------------------------------------- */

/* Base frame styles */
.iphone-frame {
    width: 393px;
    height: 852px;
    background-color: #ffffff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Mobile: Full viewport, no frame decoration */
@media (max-width: 430px) {
    body {
        background-color: #ffffff;
    }
    
    .iphone-frame {
        width: 100vw;
        width: 100dvw;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    
    /* Adjust for safe areas on notch devices */
    .iphone-frame > *:first-child {
        padding-top: calc(12px + var(--safe-top));
    }
}

/* Small tablets / Large phones */
@media (min-width: 431px) and (max-width: 768px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .iphone-frame {
        width: 393px;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 852px;
        margin: 0 auto;
        border-radius: 0;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    }
}

/* Desktop: iPhone frame preview mode */
@media (min-width: 769px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        padding: 2rem;
    }
    
    .iphone-frame {
        width: 393px;
        height: 852px;
        margin: 0 auto;
        border-radius: 40px;
        box-shadow: 
            0 0 0 12px #1a1a1a,
            0 0 0 14px #000,
            0 25px 50px rgba(0, 0, 0, 0.25);
    }
    
    /* Notch simulation */
    .iphone-frame::before {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 150px;
        height: 30px;
        background: #1a1a1a;
        border-radius: 0 0 20px 20px;
        z-index: 9999;
    }
}

/* --------------------------------------------
   4. COMPONENT CLASSES
   -------------------------------------------- */

/* Content Card */
.fin-card {
    background-color: #fff;
    border: 1px solid var(--fin-border);
    border-radius: 1rem;
    box-shadow: var(--shadow-soft);
}

/* Liquid Glass Material */
.liquid-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-top: 1px solid var(--glass-border);
}

/* Liquid Glass Navigation */
.liquid-glass-nav {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.04);
}

/* Liquid FAB Button */
.liquid-fab {
    background: linear-gradient(135deg, #ffffff 0%, #e2e4e8 49%, #d1d5db 51%, #f3f4f6 100%);
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.15),
        inset 0 2px 4px rgba(255, 255, 255, 1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

/* Liquid Icon (inactive) */
.liquid-icon {
    background: linear-gradient(135deg, #9CA3AF 0%, #D1D5DB 50%, #9CA3AF 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.8));
    transition: all 0.3s ease;
}

/* Liquid Icon (active) */
.liquid-icon-active {
    background: linear-gradient(135deg, #121212 0%, #4B5563 50%, #121212 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transform: scale(1.1);
}

/* Gold shimmer animation */
.shimmer-gold {
    background: linear-gradient(90deg, #D4AF37, #F3E5AB, #D4AF37);
    background-size: 200% 100%;
    animation: shimmer 3s infinite linear;
}

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

/* --------------------------------------------
   5. UTILITY CLASSES
   -------------------------------------------- */

/* Click bounce effect */
.click-bounce:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Hide scrollbar but keep functionality */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Safe bottom padding for content above nav */
.safe-bottom {
    padding-bottom: calc(100px + var(--safe-bottom));
}

/* Smooth iOS scrolling */
.scroll-smooth {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

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

/* Slide up animation */
.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

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

/* --------------------------------------------
   6. TYPOGRAPHY HELPERS
   -------------------------------------------- */

.text-main { color: var(--fin-text-main); }
.text-sub { color: var(--fin-text-sub); }
.text-accent { color: var(--fin-accent); }
.text-positive { color: var(--fin-positive); }
.text-negative { color: var(--fin-negative); }

.bg-surface { background-color: var(--fin-surface); }
.bg-accent { background-color: var(--fin-accent); }
.border-default { border-color: var(--fin-border); }

/* --------------------------------------------
   7. BOTTOM NAV SAFE AREA
   -------------------------------------------- */

@media (max-width: 430px) {
    .liquid-glass-nav {
        padding-bottom: calc(28px + var(--safe-bottom)) !important;
    }
    
    .liquid-glass-nav .relative {
        padding-bottom: var(--safe-bottom);
    }
}

/* --------------------------------------------
   8. MOBILE RESPONSIVE PROTOTYPE NAVIGATION
   Override inline styles from HTML files
   -------------------------------------------- */

/* Mobile Navigation Toggle Button */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    z-index: 100001;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.mobile-nav-toggle:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05);
}

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

.mobile-nav-toggle svg {
    width: 22px;
    height: 22px;
}

.mobile-nav-toggle.active {
    background: var(--fin-accent);
    border-color: var(--fin-accent);
}

/* Nav bar overlay background */
.nav-bar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-bar-overlay.visible {
    display: block;
    opacity: 1;
}

/* Mobile: Show toggle, transform nav-bar */
@media (max-width: 500px) {
    /* Show mobile toggle button */
    .mobile-nav-toggle {
        display: flex !important;
    }
    
    /* Transform nav-bar to mobile drawer */
    .nav-bar {
        position: fixed !important;
        top: 70px !important;
        right: 16px !important;
        left: auto !important;
        bottom: auto !important;
        transform: none !important;
        max-height: calc(100vh - 180px) !important;
        max-height: calc(100dvh - 180px) !important;
        width: auto !important;
        min-width: 200px !important;
        max-width: calc(100vw - 32px) !important;
        border-radius: 16px !important;
        padding: 12px !important;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-10px) scale(0.95) !important;
        transition: all 0.25s cubic-bezier(0.32, 0.72, 0, 1) !important;
    }
    
    .nav-bar.mobile-open {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: translateY(0) scale(1) !important;
    }
    
    /* Adjust nav items for mobile */
    .nav-bar .nav-title {
        font-size: 11px !important;
        padding: 0 !important;
        margin-bottom: 8px !important;
    }
    
    .nav-bar .nav-arrows {
        margin-bottom: 8px !important;
    }
    
    .nav-bar .nav-button {
        padding: 10px 12px !important;
        min-width: 44px !important;
    }
    
    .nav-bar .screen-list {
        gap: 6px !important;
    }
    
    .nav-bar .screen-item {
        padding: 10px 14px !important;
        max-width: 100% !important;
        font-size: 13px !important;
        border-radius: 10px !important;
    }
    
    .nav-bar .nav-separator {
        margin: 8px 0 !important;
    }
    
    /* Ensure iPhone frame fills viewport properly */
    body {
        background-color: #ffffff !important;
        overflow: auto !important;
    }
    
    .iphone-frame {
        width: 100vw !important;
        width: 100dvw !important;
        height: 100vh !important;
        height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    
    /* Remove desktop notch simulation on mobile */
    .iphone-frame::before {
        display: none !important;
    }
}

/* Tablet: Adjust nav-bar position */
@media (min-width: 501px) and (max-width: 768px) {
    .mobile-nav-toggle {
        display: none !important;
    }
    
    .nav-bar {
        right: 10px !important;
        max-height: 70vh !important;
    }
    
    .nav-bar .screen-item {
        max-width: 140px !important;
    }
}

/* Desktop: Standard nav-bar */
@media (min-width: 769px) {
    .mobile-nav-toggle {
        display: none !important;
    }
    
    .nav-bar {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
}

/* --------------------------------------------
   9. ENHANCED SCROLLING FOR MOBILE
   -------------------------------------------- */

@media (max-width: 500px) {
    /* Ensure content is scrollable */
    .flex-1.overflow-y-auto,
    .flex-1.overflow-auto {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Fix for iOS rubber-banding */
    .iphone-frame {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Ensure fixed bottom nav stays visible */
    .iphone-frame > .absolute.bottom-0 {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
    }
}
