/* ============================================
   THE THERAPIST AI - PREMIUM MOBILE APP CSS
   Native iOS/Android feel with glassmorphism
   ============================================ */

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

:root {
    /* Brand Colors - Premium Palette */
    --color-primary: #0e2c25;
    --color-secondary: #4c9c8a;
    --color-accent: #e8e3ce;
    --color-teal-light: #5fb3a0;
    --color-teal-dark: #3d8070;

    /* Cream Palette for Warmth */
    --color-cream: #e8e3ce;
    --color-cream-light: #f5f2e8;
    --color-cream-dark: #dad5c0;

    /* Neutral Colors */
    --color-text: #1a1a1a;
    --color-text-light: #6b7280;
    --color-text-muted: #9ca3af;
    --color-background: #f8f6f1;
    --color-surface: #ffffff;
    --color-border: rgba(14, 44, 37, 0.08);

    /* Gradient Colors */
    --gradient-primary: linear-gradient(135deg, var(--color-secondary), var(--color-teal-light));
    --gradient-dark: linear-gradient(135deg, var(--color-primary), #1a4f43);
    --gradient-warm: linear-gradient(180deg, var(--color-cream) 0%, var(--color-background) 100%);
    --gradient-card: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-primary) 100%);

    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-blur: blur(20px);

    /* Shadows - Softer, more elegant */
    --shadow-sm: 0 2px 8px rgba(14, 44, 37, 0.04);
    --shadow-md: 0 4px 16px rgba(14, 44, 37, 0.08);
    --shadow-lg: 0 8px 32px rgba(14, 44, 37, 0.12);
    --shadow-xl: 0 16px 48px rgba(14, 44, 37, 0.16);
    --shadow-glow: 0 4px 20px rgba(76, 156, 138, 0.25);
    --shadow-card: 0 2px 12px rgba(14, 44, 37, 0.06);

    /* Safe Area Insets */
    --sat: env(safe-area-inset-top, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);

    /* App Layout */
    --status-bar-height: max(20px, var(--sat));
    --bottom-nav-height: 70px;
    --safe-bottom-height: max(10px, var(--sab));
    --header-height: 60px;

    /* Border Radius - Rounded, native feel */
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-full: 100px;

    /* Transitions - Smooth, native-like */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --transition-fast: 150ms var(--ease-smooth);
    --transition-normal: 250ms var(--ease-smooth);
    --transition-slow: 350ms var(--ease-smooth);
    --transition-spring: 400ms var(--ease-spring);
}

/* Dark Mode */
[data-theme="dark"] {
    --color-text: #f5f5f5;
    --color-text-light: #a0a0a0;
    --color-background: #0d1f1a;
    --color-surface: #152c26;
    --color-border: rgba(232, 227, 206, 0.1);
    --glass-bg: rgba(21, 44, 38, 0.9);
    --glass-border: rgba(232, 227, 206, 0.1);
    --gradient-warm: linear-gradient(180deg, #0d1f1a 0%, #0a1512 100%);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-background);
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

.selectable,
.message-content,
.content-text {
    -webkit-user-select: text;
    user-select: text;
}

/* ============================================
   STATUS BAR - Premium Glass Effect
   ============================================ */

.status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--status-bar-height);
    background: var(--color-primary);
    z-index: 1000;
}

/* ============================================
   APP LAYOUT
   ============================================ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-top: var(--status-bar-height);
    background: var(--gradient-warm);
}

.content-area {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.page-container {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

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

/* ============================================
   PAGE TRANSITIONS - iOS-like
   ============================================ */

.page {
    min-height: 100%;
    opacity: 0;
    transform: translateX(20px);
    animation: pageSlideIn var(--transition-spring) forwards;
}

.page.active {
    opacity: 1;
    transform: translateX(0);
}

.page.exiting {
    animation: pageSlideOut var(--transition-normal) forwards;
}

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

@keyframes pageSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

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

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   BOTTOM NAVIGATION - Premium Glass
   ============================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom-height));
    padding-bottom: var(--safe-bottom-height);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 8px;
    z-index: 100;
    box-shadow: 0 -4px 24px rgba(14, 44, 37, 0.08);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px 4px;
    text-decoration: none;
    color: var(--color-text-light);
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
    min-height: 54px;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 32px;
    height: 3px;
    background: var(--color-secondary);
    border-radius: 2px;
    transition: transform var(--transition-spring);
}

.nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

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

.nav-icon {
    width: 26px;
    height: 26px;
    margin-bottom: 4px;
    transition: all var(--transition-spring);
    stroke-width: 2;
}

.nav-item.active .nav-icon {
    transform: scale(1.1) translateY(-2px);
}

.nav-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

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

/* ============================================
   LOADING STATES - Premium
   ============================================ */

.page-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-light);
    gap: 16px;
}

.loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--color-cream);
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   PREMIUM CARDS
   ============================================ */

.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
}

.card-gradient {
    background: var(--gradient-card);
    border-radius: var(--radius-xl);
    padding: 24px;
    color: white;
    box-shadow: var(--shadow-lg);
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

/* ============================================
   PREMIUM BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 16px 28px;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    min-height: 52px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 12px rgba(76, 156, 138, 0.2);
}

.btn-secondary {
    background: var(--color-cream);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:active {
    transform: scale(0.97);
    background: var(--color-cream-dark);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--color-secondary);
    color: var(--color-secondary);
}

.btn-outline:active {
    background: rgba(76, 156, 138, 0.1);
    transform: scale(0.97);
}

.btn-ghost {
    background: rgba(76, 156, 138, 0.1);
    color: var(--color-secondary);
}

.btn-ghost:active {
    background: rgba(76, 156, 138, 0.2);
    transform: scale(0.97);
}

/* Ripple effect */
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

/* ============================================
   PREMIUM INPUTS
   ============================================ */

.input-wrapper {
    position: relative;
}

.input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    color: var(--color-text);
    background: var(--color-surface);
    transition: all var(--transition-fast);
    outline: none;
}

.input:focus {
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 4px rgba(76, 156, 138, 0.12);
}

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

/* ============================================
   AVATAR STYLES
   ============================================ */

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-md);
    position: relative;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 18px;
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 32px;
}

.avatar-online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2px solid white;
    border-radius: 50%;
}

/* ============================================
   MOOD BUTTONS
   ============================================ */

.mood-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 10px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-spring);
    backdrop-filter: blur(8px);
    flex: 1;
    min-width: 70px;
}

.mood-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.5);
}

.mood-btn.selected {
    background: rgba(255, 255, 255, 0.4);
    border-color: white;
    transform: scale(1.02);
}

.mood-emoji {
    font-size: 28px;
    margin-bottom: 6px;
}

.mood-label {
    font-size: 12px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ============================================
   QUICK ACTION CARDS
   ============================================ */

.action-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-spring);
    text-decoration: none;
    color: inherit;
    display: block;
}

.action-card:active {
    transform: scale(0.97);
    box-shadow: var(--shadow-md);
}

.action-icon {
    width: 52px;
    height: 52px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    box-shadow: var(--shadow-glow);
}

.action-icon svg {
    width: 26px;
    height: 26px;
    stroke: white;
    stroke-width: 2;
}

.action-card h4 {
    font-size: 16px;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.action-card p {
    font-size: 13px;
    color: var(--color-text-light);
    line-height: 1.4;
}

/* ============================================
   MESSAGE BUBBLES - Premium Chat
   ============================================ */

.message {
    display: flex;
    gap: 10px;
    animation: fadeInUp 0.4s var(--ease-smooth);
    max-width: 85%;
}

.message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message.ai {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #d1d5db, #9ca3af);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.55;
    box-shadow: var(--shadow-sm);
}

.message.ai .message-bubble {
    background: var(--color-surface);
    color: var(--color-text);
    border-bottom-left-radius: 6px;
}

.message.user .message-bubble {
    background: var(--color-secondary);
    color: white;
    border-bottom-right-radius: 6px;
}

.message-time {
    font-size: 11px;
    color: var(--color-text-muted);
    font-weight: 600;
    padding: 0 8px;
}

.message.user .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 16px 18px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 6px;
    width: fit-content;
    box-shadow: var(--shadow-sm);
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-secondary);
    opacity: 0.4;
    animation: typingPulse 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ============================================
   QUICK REPLY BUTTONS
   ============================================ */

.quick-reply-btn {
    padding: 12px 18px;
    background: var(--color-surface);
    border: 2px solid rgba(14, 44, 37, 0.1);
    border-radius: var(--radius-full);
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.quick-reply-btn:active {
    transform: scale(0.95);
    background: rgba(76, 156, 138, 0.1);
    border-color: var(--color-secondary);
    color: var(--color-secondary);
}

/* ============================================
   PWA INSTALL PROMPT - Premium
   ============================================ */

.install-prompt {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom-height) + 20px);
    left: 16px;
    right: 16px;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-xl);
    z-index: 200;
    transition: all var(--transition-spring);
    transform: translateY(0);
}

.install-prompt.hidden {
    transform: translateY(calc(100% + 120px));
    pointer-events: none;
    opacity: 0;
}

.install-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.install-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.install-icon svg {
    width: 28px;
    height: 28px;
    stroke: white;
}

.install-text h3 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
}

.install-text p {
    font-size: 14px;
    opacity: 0.85;
    line-height: 1.5;
}

.btn-install {
    background: white;
    color: var(--color-primary);
    padding: 14px 28px;
    border-radius: var(--radius-md);
    border: none;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-install:active {
    transform: scale(0.97);
}

.btn-dismiss {
    background: transparent;
    color: white;
    padding: 8px;
    border: none;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity var(--transition-fast);
}

.btn-dismiss:active {
    opacity: 1;
}

/* ============================================
   OFFLINE INDICATOR
   ============================================ */

.offline-indicator {
    position: fixed;
    top: calc(var(--status-bar-height) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: #ef4444;
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    transition: all var(--transition-spring);
}

.offline-indicator.hidden {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
    pointer-events: none;
}

.offline-indicator svg {
    width: 18px;
    height: 18px;
    stroke: white;
}

/* ============================================
   SECTION STYLES
   ============================================ */

.section-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-primary);
}

.section-header a {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-secondary);
    text-decoration: none;
}

/* ============================================
   ACTIVITY LIST
   ============================================ */

.activity-item {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 10px;
    transition: all var(--transition-fast);
}

.activity-item:active {
    transform: scale(0.98);
}

.activity-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg {
    width: 22px;
    height: 22px;
    stroke: white;
}

.activity-icon.bg-teal { background: var(--color-secondary); }
.activity-icon.bg-green { background: #10b981; }
.activity-icon.bg-blue { background: #3b82f6; }
.activity-icon.bg-purple { background: #8b5cf6; }
.activity-icon.bg-orange { background: #f59e0b; }

.activity-content {
    flex: 1;
}

.activity-content h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 2px;
}

.activity-content p {
    font-size: 13px;
    color: var(--color-text-light);
}

.activity-badge {
    width: 28px;
    height: 28px;
    background: var(--color-cream);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--color-secondary);
    font-weight: 700;
}

/* ============================================
   STAT CARDS
   ============================================ */

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--color-secondary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-light);
}

/* ============================================
   SETTINGS LIST
   ============================================ */

.settings-group {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}

.settings-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item:active {
    background: rgba(76, 156, 138, 0.05);
}

.settings-icon {
    width: 40px;
    height: 40px;
    background: rgba(76, 156, 138, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
}

.settings-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--color-secondary);
}

.settings-content {
    flex: 1;
}

.settings-content h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 2px;
}

.settings-content p {
    font-size: 13px;
    color: var(--color-text-light);
}

.settings-arrow {
    color: var(--color-text-muted);
}

/* Toggle Switch */
.toggle-switch {
    width: 52px;
    height: 30px;
    background: #e5e7eb;
    border-radius: 15px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle-switch.active {
    background: var(--color-secondary);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-fast);
}

.toggle-switch.active::after {
    transform: translateX(22px);
}

/* ============================================
   KEYBOARD HANDLING
   ============================================ */

body.keyboard-open .bottom-nav {
    transform: translateY(100%);
}

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

.hidden { display: none !important; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-xs { margin-bottom: 4px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.mb-xl { margin-bottom: 32px; }

.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mt-xl { margin-top: 32px; }

.p-sm { padding: 8px; }
.p-md { padding: 16px; }
.p-lg { padding: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* Animation utilities */
.bounce-in {
    animation: bounceIn 0.5s var(--ease-spring);
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Touch feedback */
.touchable {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.touchable:active {
    transform: scale(0.97);
    opacity: 0.85;
}

/* ============================================
   BOTTOM SPACER FOR SAFE AREA
   ============================================ */

.bottom-spacer {
    height: calc(var(--bottom-nav-height) + var(--safe-bottom-height) + 20px);
}

/* ============================================
   SMOOTH SCROLLING & GPU ACCELERATION
   ============================================ */

* {
    -webkit-overflow-scrolling: touch;
}

.page,
.nav-item,
.btn,
.card,
.action-card,
.install-prompt,
.message {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ============================================
   RESPONSIVE (though mobile-first)
   ============================================ */

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

/* ============================================
   2026 UI/UX - EMOTIONAL STATE COLORS
   ============================================ */

:root {
    --emotion-calm: rgba(76, 156, 138, 0.05);
    --emotion-anxious: rgba(237, 108, 2, 0.03);
    --emotion-sad: rgba(100, 100, 120, 0.04);
    --emotion-hopeful: rgba(255, 235, 200, 0.06);

    --mood-excellent: #4ade80;
    --mood-good: #60a5fa;
    --mood-neutral: #fbbf24;
    --mood-poor: #f87171;
    --mood-crisis: #ef4444;
}

/* ============================================
   AI AVATAR BREATHING ANIMATION
   ============================================ */

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.ai-avatar-breathing {
    animation: breathe 4s ease-in-out infinite;
}

.user-is-typing .ai-avatar-breathing {
    animation-play-state: paused;
}

/* Listening state - gentle pulse */
@keyframes listening {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 156, 138, 0.4);
    }
    50% {
        transform: scale(1.01);
        box-shadow: 0 0 0 8px rgba(76, 156, 138, 0);
    }
}

.ai-avatar-listening {
    animation: listening 2s ease-in-out infinite;
}

/* ============================================
   EMOTION-AWARE BACKGROUNDS
   ============================================ */

.chat-container[data-emotion-state="calm"] {
    background: linear-gradient(
        to bottom,
        var(--emotion-calm),
        transparent 60%
    );
}

.chat-container[data-emotion-state="anxious"] {
    background: linear-gradient(
        to bottom,
        var(--emotion-anxious),
        transparent 60%
    );
}

.chat-container[data-emotion-state="sad"] {
    background: linear-gradient(
        to bottom,
        var(--emotion-sad),
        transparent 60%
    );
}

.chat-container[data-emotion-state="hopeful"] {
    background: linear-gradient(
        to bottom,
        var(--emotion-hopeful),
        transparent 60%
    );
}

/* ============================================
   STRESS-ADAPTIVE TYPOGRAPHY
   ============================================ */

[data-stress-level="high"] {
    --text-base: 1.25rem;
    --leading-normal: 1.75;
    --tracking-normal: 0.01em;
}

[data-stress-level="high"] .message-bubble {
    font-size: 1.25rem;
    line-height: 1.75;
    letter-spacing: 0.01em;
}

/* ============================================
   PRIVACY MODE - BLUR FILTER
   ============================================ */

body.privacy-mode .page-content,
body.privacy-mode .messages-container,
body.privacy-mode .chat-page {
    filter: blur(12px);
    transition: filter 0.3s ease;
}

body.privacy-mode .privacy-mode-banner {
    display: flex;
}

.privacy-mode-banner {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-primary);
    color: white;
    padding: 24px 32px;
    border-radius: var(--radius-xl);
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-xl);
}

.privacy-mode-banner h3 {
    font-size: 18px;
    font-weight: 700;
}

.privacy-mode-banner p {
    font-size: 14px;
    opacity: 0.9;
}

/* ============================================
   DISTRESS MODE - HIGH CONTRAST & LARGE TARGETS
   ============================================ */

[data-distress-mode="true"] {
    --color-text: #000000;
    --color-background: #ffffff;
    --color-surface: #ffffff;
}

[data-distress-mode="true"] .btn,
[data-distress-mode="true"] .touchable,
[data-distress-mode="true"] .nav-item {
    min-height: 72px;
    min-width: 72px;
}

[data-distress-mode="true"] .message-bubble {
    font-size: 1.25rem;
    line-height: 1.75;
    padding: 18px 22px;
}

[data-distress-mode="true"] * {
    animation: none !important;
    transition: none !important;
}

[data-distress-mode="true"] .bottom-nav {
    height: calc(90px + var(--safe-bottom-height));
}

[data-distress-mode="true"] .nav-icon {
    width: 32px;
    height: 32px;
}

[data-distress-mode="true"] .nav-label {
    font-size: 14px;
}

/* ============================================
   CRISIS UI - EMERGENCY BUTTONS
   ============================================ */

.crisis-button-emergency {
    min-height: 72px;
    background: var(--mood-crisis);
    color: white;
    border: 3px solid currentColor;
    font-weight: 700;
    font-size: 20px;
    border-radius: var(--radius-lg);
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
    transition: transform 0.1s ease;
}

.crisis-button-emergency:active {
    transform: scale(0.98);
}

.crisis-button-secondary {
    min-height: 60px;
    background: white;
    color: var(--mood-crisis);
    border: 2px solid var(--mood-crisis);
    font-weight: 700;
    font-size: 18px;
    border-radius: var(--radius-lg);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    cursor: pointer;
}

.crisis-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 2000;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.crisis-screen h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-primary);
    text-align: center;
    margin-bottom: 8px;
}

.crisis-screen .crisis-subtitle {
    font-size: 16px;
    color: var(--color-text-light);
    text-align: center;
    margin-bottom: 24px;
}

.safety-checklist {
    background: var(--color-cream);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 16px 0;
}

.safety-checklist h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 16px;
}

.safety-checklist label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    font-size: 16px;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
}

.safety-checklist label:last-child {
    border-bottom: none;
}

.safety-checklist input[type="checkbox"] {
    width: 24px;
    height: 24px;
    accent-color: var(--color-secondary);
}

.crisis-return {
    background: var(--color-secondary);
    color: white;
    border: none;
    padding: 18px 24px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: auto;
}

/* ============================================
   12-EMOTION SELECTOR GRID
   ============================================ */

.emotion-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px;
}

.emotion-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 8px;
    background: var(--color-surface);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform 120ms cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--shadow-sm);
}

.emotion-grid-item:active {
    transform: scale(0.92);
}

.emotion-grid-item.selected {
    border-color: var(--color-secondary);
    background: rgba(76, 156, 138, 0.1);
}

.emotion-grid-item .emotion-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.emotion-grid-item .emotion-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text);
    text-align: center;
}

/* Emotion intensity slider */
.emotion-intensity {
    padding: 16px;
}

.emotion-intensity-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-light);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
}

.emotion-intensity-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right,
        var(--color-cream) 0%,
        var(--color-secondary) 100%
    );
    -webkit-appearance: none;
    appearance: none;
}

.emotion-intensity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-secondary);
    border: 3px solid white;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

/* ============================================
   JOURNEY PHASES (Non-Gamification)
   ============================================ */

.journey-phases {
    display: flex;
    justify-content: space-around;
    padding: 20px 16px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    margin: 16px 0;
}

.journey-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.journey-phase.active {
    opacity: 1;
}

.journey-phase.completed {
    opacity: 0.8;
}

.journey-phase-icon {
    font-size: 32px;
}

.journey-phase-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text);
}

.journey-phase-connector {
    flex: 1;
    height: 2px;
    background: var(--color-border);
    margin-top: 20px;
}

.journey-phase.completed + .journey-phase-connector {
    background: var(--color-secondary);
}

/* ============================================
   MEMORY INDICATORS
   ============================================ */

.memory-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(76, 156, 138, 0.1);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--color-secondary);
    font-weight: 600;
}

.memory-indicator-icon {
    font-size: 14px;
}

/* ============================================
   SESSION TIMER WARNING
   ============================================ */

.session-timer-warning {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom-height) + 20px);
    left: 16px;
    right: 16px;
    background: var(--color-warning);
    color: white;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 150;
    animation: slideUp 0.3s ease;
}

.session-timer-warning.hidden {
    display: none;
}

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

.session-timer-icon {
    font-size: 24px;
}

.session-timer-content {
    flex: 1;
}

.session-timer-content h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
}

.session-timer-content p {
    font-size: 12px;
    opacity: 0.9;
}

.session-timer-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
}

/* ============================================
   ADAPTIVE TYPING INDICATOR
   ============================================ */

.typing-indicator[data-typing-speed="calm"] .typing-dot {
    animation-duration: 1.4s;
}

.typing-indicator[data-typing-speed="anxious"] .typing-dot {
    animation-duration: 2.1s;
}

.typing-indicator[data-typing-speed="crisis"] .typing-dot {
    animation-duration: 0.7s;
}

/* ============================================
   TOOL UNLOCK CARDS (Non-Badge System)
   ============================================ */

.tool-unlock-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-card);
    margin-bottom: 12px;
}

.tool-unlock-card.locked {
    opacity: 0.6;
}

.tool-unlock-card.unlocked {
    border: 2px solid var(--color-secondary);
}

.tool-unlock-icon {
    width: 56px;
    height: 56px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.tool-unlock-card.locked .tool-unlock-icon {
    background: var(--color-cream);
    filter: grayscale(1);
}

.tool-unlock-content {
    flex: 1;
}

.tool-unlock-content h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.tool-unlock-content p {
    font-size: 13px;
    color: var(--color-text-light);
}

.tool-unlock-status {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-secondary);
    padding: 6px 12px;
    background: rgba(76, 156, 138, 0.1);
    border-radius: var(--radius-full);
}

.tool-unlock-card.locked .tool-unlock-status {
    color: var(--color-text-muted);
    background: var(--color-cream);
}
