/* Root Variables */
:root {
    /* Enhanced Color Palette */
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --secondary-color: #06b6d4;
    --secondary-light: #67e8f9;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    /* Modern Background Gradients */
    --bg-gradient-start: #f8fafc;
    --bg-gradient-end: #e2e8f0;
    --bg-gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-gradient-secondary: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    
    /* Enhanced Typography */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    
    /* Modern Color Palette */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Enhanced Shadows with Depth */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Glassmorphism Effects */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-backdrop: blur(16px);
    
    /* Rounded Corners */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.3s ease-out;
    --transition-slow: 0.5s ease-out;
    
    /* Font Weights */
    --font-light: 300;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-extrabold: 800;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-gradient-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    width: 100%;
    font-weight: var(--font-normal);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Enhanced background with subtle pattern */
    background-attachment: fixed;
    background-size: cover;
    position: relative;
}

/* Subtle background pattern overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Mobile-specific body fixes */
@media (max-width: 768px) {
    body {
        position: fixed;
        overflow: hidden;
    }
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    max-width: 500px;
    margin: 0 auto;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

/* Desktop Enhancement */
@media (min-width: 769px) {
    body {
        overflow: auto;
        position: relative;
        background-attachment: fixed;
        min-height: 100vh;
        height: auto;
    }
    
    .app-container {
        height: 90vh;
        margin: 5vh auto;
        border-radius: 16px;
        overflow: hidden;
        position: relative;
    }
    
}

/* Header */
.app-header {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    border-bottom: 1px solid var(--glass-border);
    padding: 1.25rem 1.5rem;
    position: relative;
    z-index: 10;
    /* Subtle gradient overlay */
    background-image: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-gradient);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-size: 1.375rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.logo-icon::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: rotate(45deg);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    50% { transform: translateX(100%) translateY(100%) rotate(45deg); }
    100% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
}

.logo-text {
    font-size: 1.375rem;
    font-weight: var(--font-bold);
    color: var(--text-primary);
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.025em;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: var(--success-color);
    border-radius: var(--radius-full);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1);
    }
}

.status-text {
    font-weight: 500;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 0; /* Fix for Firefox flex issue */
}

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Messages Area */
.messages-area {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    padding-bottom: 200px !important; /* Increased space for input area */
    scroll-behavior: smooth;
    /* iOS scroll fix */
    -webkit-overflow-scrolling: touch;
    min-height: 0; /* Important for flex children */
    position: relative;
}

/* Removed ::after pseudo-element to prevent double spacing */

.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.messages-area::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Messages */
.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-size: 1.125rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.message-avatar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.message:hover .message-avatar::before {
    opacity: 1;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%);
    box-shadow: var(--shadow-md);
}

.message-bubble {
    max-width: 80%;
    animation: slideIn 0.3s ease-out;
}

.message-content {
    background: var(--white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-2xl);
    border-top-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    position: relative;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--transition-normal);
}

.message-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: inherit;
    pointer-events: none;
}

.message:hover .message-content {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.user-message .message-content {
    background: var(--primary-gradient);
    color: var(--text-inverse);
    border-top-left-radius: var(--radius-2xl);
    border-top-right-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-md);
}

.user-message .message-content::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
}

.message-content p {
    margin: 0;
    line-height: 1.6;
    font-weight: var(--font-medium);
    position: relative;
    z-index: 1;
}

.message-time {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.75rem;
    padding: 0 1.5rem 1rem;
}

.typing-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1rem;
}

.typing-bubble {
    background: var(--white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-2xl);
    border-top-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
}

.typing-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    animation: typing-shimmer 2s ease-in-out infinite;
}

@keyframes typing-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: var(--radius-full);
    animation: typingDot 1.4s ease-in-out infinite;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Input Area */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.25rem 1.5rem 1.5rem;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    border-top: 1px solid var(--glass-border);
    z-index: 20;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    min-height: 88px; /* Ensure consistent height */
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: var(--font-medium);
    background: var(--white);
    outline: none;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.message-input::placeholder {
    color: var(--text-muted);
    font-weight: var(--font-normal);
}

.message-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), var(--shadow-md);
    transform: translateY(-2px);
    background: var(--white);
}

.send-button {
    width: 48px;
    height: 48px;
    border: none;
    background: var(--primary-gradient);
    color: var(--text-inverse);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 1.25rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.send-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
}

.send-button:hover::before {
    opacity: 1;
    transform: scale(1);
}

.send-button:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-xl);
}

.send-button:active:not(:disabled) {
    transform: translateY(-1px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Profile Card */
.profile-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 380px;
    max-height: calc(100vh - 60px); /* Default height */
    background: rgba(255, 255, 255, 0.95); /* Less transparent for better readability */
    backdrop-filter: blur(12px); /* Moderate blur for glass effect */
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--glass-border);
    z-index: 1001; /* Higher than sticky ad (999) */
    animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ensure profile card doesn't overlap with sticky ad */
body.has-sticky-ad .profile-card {
    max-height: calc(100vh - 150px) !important; /* 120px ad + 30px margin */
    transform: translate(-50%, -50%) translateY(-30px) !important; /* Move up */
}

.profile-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: var(--primary-gradient);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    z-index: 2;
    box-shadow: var(--shadow-lg);
}

.profile-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
    border-radius: var(--radius-full);
    animation: float-glow 8s ease-in-out infinite;
}

@keyframes float-glow {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.8;
    }
    33% {
        transform: translateY(-20px) scale(1.1);
        opacity: 1;
    }
    66% {
        transform: translateY(10px) scale(0.9);
        opacity: 0.6;
    }
}

.profile-header h3 {
    font-size: 1.125rem;
    font-weight: var(--font-bold);
    color: var(--text-inverse);
    letter-spacing: -0.025em;
    z-index: 2;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.profile-header h3::before {
    content: '✨';
    font-size: 1.1rem;
}

.close-button {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-inverse);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    z-index: 2;
    position: relative;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
}

.close-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: inherit;
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg) scale(1.1);
    box-shadow: var(--shadow-md);
}

.close-button:hover::before {
    opacity: 1;
    transform: scale(1);
}

.profile-content {
    padding: 1.25rem;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0; /* Allow proper scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Profile content scrollbar styling */
.profile-content::-webkit-scrollbar {
    width: 4px;
}

.profile-content::-webkit-scrollbar-track {
    background: transparent;
}

.profile-content::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.2);
    border-radius: 2px;
}

.profile-content::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 58, 237, 0.3);
}

.profile-item {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(124, 58, 237, 0.08);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-item:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.profile-item::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.profile-item:hover::before {
    transform: scale(1.5);
}

.profile-item-content {
    flex: 1;
}

.profile-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 0.125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-value {
    font-size: 0.9375rem;
    color: var(--gray-800);
    font-weight: 600;
    line-height: 1.2;
}

.profile-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: rgba(249, 250, 251, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 0 0 24px 24px;
    flex-shrink: 0; /* Prevent actions from shrinking */
}

.action-button {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: none;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    position: relative;
    overflow: hidden;
}

.action-button.primary {
    background: var(--primary-gradient);
    color: var(--text-inverse);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.action-button.primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.action-button.primary:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-2xl);
}

.action-button.primary:hover::before {
    opacity: 1;
}

.action-button.primary:active {
    transform: translateY(-2px) scale(1.01);
    box-shadow: var(--shadow-lg);
}

.action-button.primary:active {
    transform: translateY(0);
}

.action-button.secondary {
    background: transparent;
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
}

.action-button.secondary:hover {
    background: rgba(124, 58, 237, 0.08);
    border-color: var(--primary-dark);
}

.action-button.full-width {
    width: 100%;
}

/* Ensure buttons are always visible on mobile */
@media (max-width: 768px) {
    .action-button.primary {
        background: #7c3aed;
        color: white;
        min-height: 44px; /* Touch-friendly height */
        font-size: 0.875rem;
        font-weight: 600;
        padding: 0.75rem 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .action-button.primary:hover {
        background: #6d28d9;
    }
}

/* Selection Buttons */
.selection-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    min-height: 40px; /* Prevent layout shift */
}

.selection-button {
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--primary-color);
    background: var(--white);
    color: var(--primary-color);
    border-radius: var(--radius-full);
    font-size: 0.9375rem;
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: all var(--transition-normal);
    outline: none;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.selection-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left var(--transition-slow);
}

.selection-button:hover {
    background: var(--primary-gradient);
    color: var(--text-inverse);
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.selection-button:hover::before {
    left: 100%;
}

.selection-button:active {
    transform: translateY(0);
    box-shadow: none;
}

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

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

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(20px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05) translateY(-5px);
    }
    70% {
        transform: scale(0.98) translateY(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

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

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

@keyframes slideUp {
    from {
        transform: translate(-50%, -45%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* Mobile slideUp animation override */
@media (max-width: 768px) {
    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    @keyframes slideDown {
        from {
            transform: translateY(-100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

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

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.1);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.1);
    }
    70% {
        transform: scale(1);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(99, 102, 241, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.8);
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-12px);
        opacity: 1;
        background-color: var(--primary-color);
    }
}

@keyframes typing {
    0% {
        width: 0;
    }
    100% {
        width: 100%;
    }
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.fade-in {
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fade-in-scale {
    animation: fadeInScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.bounce-in {
    animation: bounceIn 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out forwards;
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out forwards;
}

.glow-effect {
    animation: glow 2s ease-in-out infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        background: var(--white);
        position: relative;
        overflow: auto;
    }
    
    .app-container {
        max-width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height */
        border-radius: 0;
        box-shadow: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    
    .app-header {
        padding: 0.75rem 1rem;
    }
    
    .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .logo-text {
        font-size: 1.1rem;
    }
    
    .header-status {
        font-size: 0.75rem;
    }

    .messages-area {
        padding: 0.75rem;
        padding-bottom: 180px !important; /* Consistent space for input on tablet */
    }
    
    .message {
        margin-bottom: 0.75rem;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }

    .message-bubble {
        max-width: 85%;
        padding: 0.75rem 1rem;
    }
    
    .message-content {
        font-size: 0.9375rem;
    }
    
    .message-time {
        font-size: 0.6875rem;
    }
    
    .quick-action {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .typing-indicator {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .input-area {
        padding: 0.75rem;
        /* Keep absolute positioning from parent */
    }
    
    .input-wrapper {
        gap: 0.5rem;
    }
    
    .message-input {
        padding: 0.75rem 1rem;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        border-radius: 22px;
    }
    
    .send-button {
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }

    .profile-card {
        width: 90%;
        max-width: 340px;
        max-height: calc(100vh - 100px); /* Leave space for top and bottom */
        height: auto;
        margin: 0 auto;
        border-radius: 20px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        border: none;
        animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        z-index: 1001; /* Higher than sticky ad */
    }
    
    .profile-header {
        padding: 0.875rem 1rem;
        flex-shrink: 0;
    }
    
    .profile-header h3 {
        font-size: 1rem;
    }
    
    .profile-content {
        padding: 1rem;
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
    }
    
    .profile-item {
        margin-bottom: 0.75rem;
        padding: 0.375rem 0;
    }
    
    .profile-label {
        font-size: 0.6875rem;
        margin-bottom: 0.125rem;
    }
    
    .profile-value {
        font-size: 0.8125rem;
    }
    
    .profile-actions {
        padding: 0.875rem 1rem;
        flex-shrink: 0;
        gap: 0.375rem;
    }
    
    .action-button {
        padding: 0.75rem 0.625rem;
        font-size: 0.8125rem;
        border-radius: 10px;
    }
}

@media (max-width: 480px) {
    .messages-area {
        padding: 0.5rem;
        padding-bottom: 160px !important; /* Consistent space for input on mobile */
    }
    
    .message {
        gap: 0.5rem;
    }
    
    .message-bubble {
        max-width: 90%;
    }
    
    .quick-actions {
        gap: 0.5rem;
    }
    
    .quick-action {
        flex: 1;
        min-width: auto;
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
    
    .profile-card {
        max-height: 80vh; /* Reduced for better visibility on small screens */
        min-height: 250px; /* Reduced minimum height */
        top: env(safe-area-inset-top, 0); /* Account for iPhone notch/status bar */
    }
    
    .profile-header {
        padding: 0.75rem;
    }
    
    .profile-header h3 {
        font-size: 0.9375rem;
    }
    
    .profile-content {
        padding: 0.75rem;
    }
    
    .profile-item {
        margin-bottom: 0.625rem;
        padding: 0.25rem 0;
    }
    
    .profile-actions {
        padding: 0.75rem;
    }
    
    .action-button {
        padding: 0.6875rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* iOS Safe Area Support */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .input-area {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
    
    .app-header {
        padding-top: calc(0.75rem + env(safe-area-inset-top));
    }
    
    @media (max-width: 768px) {
        .input-area {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        }
        
        .profile-actions {
            padding-bottom: calc(0.875rem + env(safe-area-inset-bottom));
        }
    }
    
    @media (max-width: 480px) {
        .profile-actions {
            padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
        }
    }
}

/* Progress Bar for Multi-step Flow */
.progress-container {
    padding: 0.75rem 1.5rem 0;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    z-index: 9;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: progress-shimmer 2s ease-in-out infinite;
}

@keyframes progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    position: relative;
}

.step.active {
    color: var(--primary-color);
    font-weight: var(--font-semibold);
}

.step.completed {
    color: var(--success-color);
}

.step-indicator {
    width: 24px;
    height: 24px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: var(--font-bold);
    transition: all var(--transition-normal);
    background: var(--white);
}

.step.active .step-indicator {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: var(--text-inverse);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.step.completed .step-indicator {
    border-color: var(--success-color);
    background: var(--success-color);
    color: var(--text-inverse);
}

.step.completed .step-indicator::before {
    content: '✓';
    font-size: 0.75rem;
    font-weight: var(--font-bold);
}

/* Landscape Mode Adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .app-header {
        padding: 0.5rem 1rem;
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
    }
    
    .messages-area {
        padding: 0.5rem;
        padding-bottom: 160px !important; /* Consistent space for input on mobile */
    }
    
    .message-bubble {
        padding: 0.5rem 0.875rem;
    }
    
    .chat-input-container {
        padding: 0.5rem;
    }
    
    .progress-container {
        padding: 0.5rem 1rem 0;
    }
    
    .progress-steps {
        margin: 0.375rem 0 0.5rem;
    }
    
    .step {
        font-size: 0.6875rem;
    }
    
    .step-indicator {
        width: 20px;
        height: 20px;
        font-size: 0.6875rem;
    }
}

/* Interview Container (placeholder) */
.interview-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--white);
    z-index: 200;
}

/* Mobile Profile Card Fixes */
@media (max-width: 768px) {
    /* Center profile card on mobile */
    .profile-card {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 92% !important;
        max-width: 360px !important;
        max-height: calc(100vh - 80px) !important; /* Leave space for margins */
        margin: 0 !important;
        border-radius: 20px !important;
        z-index: 1001 !important; /* Above sticky ad */
        animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* When sticky ad is present on mobile */
    body.has-sticky-ad .profile-card {
        max-height: calc(100vh - 150px) !important; /* 120px ad + 30px margin */
        transform: translate(-50%, -50%) translateY(-20px) !important; /* Shift up slightly */
    }
    
    /* Ensure content is scrollable */
    .profile-content {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: calc(100vh - 200px) !important; /* Account for header and actions */
    }
    
    /* When sticky ad is present */
    body.has-sticky-ad .profile-content {
        max-height: calc(100vh - 250px) !important; /* Account for sticky ad */
    }
    
    /* Fix for very small screens */
    @media (max-height: 600px) {
        .profile-card {
            max-height: calc(100vh - 130px) !important; /* Account for sticky ad */
        }
        
        .profile-content {
            max-height: calc(100vh - 290px) !important; /* Account for sticky ad */
        }
        
        body.has-sticky-ad .profile-card {
            max-height: calc(100vh - 130px) !important;
        }
        
        body.has-sticky-ad .profile-content {
            max-height: calc(100vh - 310px) !important;
        }
        
        .profile-header {
            padding: 0.5rem !important;
        }
        
        .profile-actions {
            padding: 0.5rem !important;
        }
    }
}

/* Profile Card Backdrop - Removed to prevent page blocking */
/* No backdrop needed - profile card should not block the entire page */

/* Ensure backdrop/overlay is behind profile card but above sticky ad */
.modal-backdrop,
.overlay {
    z-index: 1000 !important; /* Above sticky ad but below profile card */
}

/* Tablet-specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    body.has-sticky-ad .profile-card {
        transform: translate(-50%, -50%) translateY(-40px) !important; /* Shift up for tablets */
        max-height: calc(100vh - 160px) !important;
        width: 85%;
        max-width: 400px;
    }
}

/* Desktop-specific fixes */
@media (min-width: 1025px) {
    body.has-sticky-ad .profile-card {
        transform: translate(-50%, -50%) translateY(-50px) !important; /* Shift up for desktop */
        max-height: calc(100vh - 180px) !important; /* More conservative height */
    }
}

/* Extra safety for very short screens */
@media (max-height: 500px) {
    .profile-card {
        max-height: calc(100vh - 100px) !important;
        top: 10px !important;
        transform: translateX(-50%) !important;
    }
    
    body.has-sticky-ad .profile-card {
        max-height: calc(100vh - 130px) !important;
    }
    
    .profile-content {
        max-height: calc(100vh - 250px) !important;
    }
}

/* Profile card active state */
.profile-card.active {
    display: block !important;
}

/* Accessibility Improvements */

/* Focus Management */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.message-input:focus,
.send-button:focus,
.selection-button:focus,
.action-button:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --text-primary: #000000;
        --text-secondary: #333333;
        --bg-primary: #ffffff;
        --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
    
    .message-content {
        border: 2px solid var(--text-primary);
    }
    
    .selection-button,
    .action-button {
        border-width: 3px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .logo-icon::before,
    .progress-fill::after,
    .typing-bubble::before {
        animation: none !important;
    }
}

/* Screen Reader Only Content */
.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;
}

/* Skip Navigation Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: var(--text-inverse);
    padding: 8px;
    text-decoration: none;
    border-radius: var(--radius-md);
    z-index: 10000;
    font-weight: var(--font-semibold);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 6px;
}

/* Enhanced Touch Targets for Mobile */
@media (max-width: 768px) {
    .selection-button,
    .action-button,
    .send-button,
    .close-button {
        min-height: 44px;
        min-width: 44px;
    }
    
    .step-indicator {
        min-height: 32px;
        min-width: 32px;
    }
}

/* Color Blind Friendly Indicators */
.step.completed .step-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 8px;
    border: solid var(--text-inverse);
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Prevent body scroll when profile card is open on mobile */
@media (max-width: 768px) {
    /* Removed profile-open class to prevent page blocking */
}