/**
 * WePla — Global App CSS
 * Source of Truth: WEPLA_VIBE_CODING_UI_GUIDE.md + DESIGN.md
 * Style: Soft Romantic Minimalism + Native App Experience
 */

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

/* =============================================
   CSS Reset
============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
    overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* =============================================
   Design Tokens — EXACTLY from Vibe Guide §4
============================================= */
:root {
    /* Primary — Pastel Dusty Rose (Vibe Guide) */
    --primary: #E8A0BF;
    --primary-dark: #D4789E;
    --primary-soft: #FFF1F6;

    /* Secondary & Accent */
    --secondary: #FFEFFA;
    --lavender: #F8F1FF;
    --sage: #7BC89C;
    --sage-soft: #EAF8F0;

    /* Material Design accent (DESIGN.md primary-container) */
    --accent-strong: #D81B60;
    --accent-dark: #B0004A;

    /* Semantic */
    --success: #22C55E;
    --success-light: #F0FDF4;
    --warning: #F59E0B;
    --warning-light: #FFFBEB;
    --danger: #EF4444;
    --danger-light: #FEF2F2;
    --info: #3B82F6;
    --info-light: #EFF6FF;

    /* Surfaces — Blush & Bloom (DESIGN.md) */
    --bg: #FFFCFD;
    --bg-soft: #FFF7FA;
    --bg-screen: #FFFCFD;
    --white: #FFFFFF;
    --surface: #FFFFFF;
    --surface-glass: rgba(255, 255, 255, 0.72);
    --bg-card: #FFFFFF;

    /* Text */
    --text-primary: #2B2B2B;
    --text-secondary: #777777;
    --text-muted: #A0A0A0;

    /* Neutrals */
    --gray-50: #FAFAFA;
    --gray-100: #F4F4F5;
    --gray-200: #E4E4E7;
    --gray-300: #D4D4D8;
    --gray-400: #A1A1AA;
    --gray-500: #71717A;
    --gray-600: #52525B;
    --gray-700: #3F3F46;
    --gray-800: #27272A;
    --gray-900: #18181B;

    /* Borders & Shadows — warm dusty-rose tint */
    --border-soft: rgba(212, 120, 158, 0.14);
    --outline-variant: #E3BDC3;
    --shadow-soft: 0 10px 30px rgba(43, 43, 43, 0.06);
    --shadow-card: 0 12px 36px rgba(212, 120, 158, 0.10);
    --shadow-sm: 0 1px 3px rgba(212, 120, 158, 0.06);
    --shadow-md: 0 4px 12px rgba(212, 120, 158, 0.08);
    --shadow-lg: 0 18px 45px rgba(43, 43, 43, 0.10);

    /* Radius — from Vibe Guide §4 */
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-pill: 999px;
    --radius-full: 9999px;
    --radius-2xl: 32px;

    /* Spacing (8px grid) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Motion */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Safe Areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* App dimensions */
    --header-h: 0px;
    --bottom-nav-h: 60px;
    --bottom-total: calc(var(--bottom-nav-h) + var(--safe-bottom) + 18px);

    /* Aliases for DESIGN.md compat */
    --primary-light: #FFF1F6;
    --primary-50: rgba(212, 120, 158, 0.12);
}

/* =============================================
   Typography — Vibe Guide §5
============================================= */
body {
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display-title {
    font-family: 'Plus Jakarta Sans', Inter, system-ui, sans-serif;
    letter-spacing: -0.03em;
    line-height: 1.3;
}

/* =============================================
   App Shell — Vibe Guide §6
============================================= */
.app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 430px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    background:
        radial-gradient(circle at top left, rgba(232, 160, 191, 0.22), transparent 32%),
        radial-gradient(circle at top right, rgba(248, 241, 255, 0.9), transparent 35%),
        var(--bg);
    position: relative;
    overflow-x: hidden;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

/* =============================================
   Top Header Bar
============================================= */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    height: var(--header-h);
    padding: 0 var(--sp-4);
    padding-top: var(--safe-top);
    background: rgba(255, 252, 253, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-soft);
}

.top-bar-title {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.top-bar-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--gray-100);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.top-bar-btn:active {
    background: var(--gray-200);
    transform: scale(0.95);
}

.top-bar-btn svg {
    width: 20px;
    height: 20px;
}

.top-bar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

/* =============================================
   Screen Content Area
============================================= */
.screen-content {
    flex: 1;
    padding: var(--sp-5) 18px calc(var(--bottom-total) + var(--sp-4));
    max-width: 100%;
    overflow-x: hidden;
}

.page-container {
    padding: max(24px, var(--safe-top)) 18px calc(var(--bottom-total) + 24px);
}

/* =============================================
   Auth Pages
============================================= */
.auth-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
    background: linear-gradient(160deg, #FFF1F6 0%, #F8F1FF 50%, #EFF6FF 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--sp-8) var(--sp-6);
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: var(--sp-6);
}

.auth-logo .logo-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--sp-3);
    background: var(--primary-soft);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--sp-1);
}

.auth-logo p {
    font-size: 14px;
    color: var(--text-muted);
}

.auth-footer {
    text-align: center;
    margin-top: var(--sp-5);
    font-size: 14px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary-dark);
    font-weight: 600;
}

/* =============================================
   Typography Utilities
============================================= */
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg { font-size: 17px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary-dark); }
.text-success { color: var(--success); }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.hidden { display: none !important; }

/* =============================================
   Animations
============================================= */
.fade-up { animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }

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

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

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

@keyframes ai-pulse-anim {
    0% { box-shadow: 0 0 0 0 rgba(212,120,158,0.5); }
    70% { box-shadow: 0 0 0 6px rgba(212,120,158,0); }
    100% { box-shadow: 0 0 0 0 rgba(212,120,158,0); }
}

.animate-in { animation: fadeInUp 0.35s ease; }

/* =============================================
   Desktop Responsive Strategy (from UX Plan)
============================================ */
:root {
    --sidebar-width: 0px;
}

@media (min-width: 768px) {
    :root {
        --sidebar-width: 80px;
    }
    .app-shell {
        max-width: 100% !important; /* Allow shell to fill */
        padding-left: var(--sidebar-width);
    }
    .screen-content {
        max-width: 800px;
        margin: 0 auto;
    }
}

@media (min-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
    .screen-content {
        max-width: 900px;
    }
}
