/* ==================== CSS VARIABLES & ROOT ==================== */
:root {
    /* Color Palette - Enhanced with gradients */
    --primary: #0084ff;
    --primary-dark: #0066cc;
    --primary-light: #3399ff;
    --primary-gradient: linear-gradient(135deg, #0084ff 0%, #0066cc 100%);
    
    --secondary: #ff6b9d;
    --secondary-dark: #e85583;
    --secondary-gradient: linear-gradient(135deg, #ff6b9d 0%, #e85583 100%);
    
    --accent: #ffa502;
    --accent-dark: #e69500;
    --accent-gradient: linear-gradient(135deg, #ffa502 0%, #ff8800 100%);
    
    --success: #10b981;
    --success-dark: #059669;
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    
    --info: #06b6d4;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --pink: #ec4899;
    
    --app-bg: #0f172a;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #efefef;
    --bg-hover: #f8f9fa;
    --bg-active: #e9ecef;
    
    /* Text Colors */
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --text-muted: #aaaaaa;
    
    /* Border Colors */
    --border: #e0e0e0;
    --border-light: #f0f0f0;
    --border-dark: #d0d0d0;
    
    /* Shadows - Enhanced for depth */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.16);
    --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.20);
    --shadow-2xl: 0 32px 64px rgba(0, 0, 0, 0.24);
    
    --shadow-colored: 0 8px 24px rgba(0, 132, 255, 0.25);
    --shadow-colored-hover: 0 12px 32px rgba(0, 132, 255, 0.35);
    
    /* Transitions - Smooth and professional */
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', monospace;
    
    /* Spacing Scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* Z-Index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

body.dark-theme {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2e2e2e;
    --bg-hover: #333333;
    --bg-active: #3a3a3a;
    
    --text-primary: #f5f5f5;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --text-muted: #666666;
    
    --border: #333333;
    --border-light: #2a2a2a;
    --border-dark: #3a3a3a;
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.7);
}

body.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    --bg-active: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-dark: #cbd5e1;
    
    --app-bg: linear-gradient(180deg, #f8fafc 0%, #e0e7ff 100%);
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    
    --shadow-colored: 0 8px 24px rgba(37, 99, 235, 0.25);
    --shadow-colored-hover: 0 12px 32px rgba(37, 99, 235, 0.35);
}

body.curious-theme {
    --bg-primary: #0b1020;
    --bg-secondary: #121a2c;
    --bg-tertiary: #17223a;
    --bg-hover: #1c2847;
    --bg-active: #212e54;
    
    --text-primary: #eaf2ff;
    --text-secondary: #9bb5ff;
    --text-tertiary: #7b8bb2;
    --text-muted: #5a6a8f;
    
    --border: #223055;
    --border-light: #1a2642;
    --border-dark: #2a3b65;
    
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --primary-light: #8b5cf6;
    --primary-gradient: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    
    --secondary: #22d3ee;
    --secondary-dark: #06b6d4;
    --secondary-gradient: linear-gradient(135deg, #22d3ee 0%, #06b6d4 100%);
    
    --accent: #f472b6;
    --accent-dark: #ec4899;
    --accent-gradient: linear-gradient(135deg, #f472b6 0%, #ec4899 100%);
    
    --app-bg: radial-gradient(1400px 800px at 80% -20%, rgba(124,58,237,0.35), transparent 60%),
               radial-gradient(1000px 600px at 10% 80%, rgba(34,211,238,0.3), transparent 60%),
               radial-gradient(800px 400px at 50% 50%, rgba(244,114,182,0.1), transparent 70%),
               #0b1020;
    
    --shadow-colored: 0 8px 24px rgba(124, 58, 237, 0.3);
    --shadow-colored-hover: 0 12px 32px rgba(124, 58, 237, 0.45);
}

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

*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: #0f172a;
    color: var(--text-primary);
    transition: background 0.4s ease, color 0.3s ease;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* Mobile viewport fix */
    line-height: 1.6;
    font-size: 16px;
    position: relative;
    
    /* iOS Safe Area Support */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    
    /* Prevent overscroll bounce on mobile */
    overscroll-behavior: none;
    
    /* Optimize for touch */
    -webkit-overflow-scrolling: touch;
}

/* Add subtle texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.03), transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(74, 86, 226, 0.03), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ==================== LOADING SCREEN ==================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f1419 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: var(--z-modal);
    opacity: 1;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

/* Animated gradient background */
.loading-screen::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(46, 160, 67, 0.15) 0%, transparent 70%);
    animation: rotateGradient 20s linear infinite;
}

@keyframes rotateGradient {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.logo-container {
    position: relative;
    width: min(300px, 80vw);
    height: min(300px, 80vw);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
}

.logo-base {
    width: min(200px, 50vw);
    height: min(200px, 50vw);
    background: linear-gradient(135deg, #2ea043 0%, #1e6f3e 100%);
    border-radius: clamp(20px, 5vw, 30px);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 20px 60px rgba(46, 160, 67, 0.4),
        0 10px 30px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: logoFloat 3s ease-in-out infinite, logoPulse 2s ease-in-out infinite;
    transform-style: preserve-3d;
}

/* Add shimmer effect */
.logo-base::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 70%
    );
    animation: shimmer 3s infinite;
}

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

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 20px 60px rgba(46, 160, 67, 0.4), 0 10px 30px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 25px 80px rgba(46, 160, 67, 0.6), 0 15px 40px rgba(0, 0, 0, 0.4); }
}

.logo-base::before {
    content: '';
    position: absolute;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
    top: -10%;
    left: -10%;
}

.infinity {
    position: relative;
    width: 120px;
    height: 60px;
}

.infinity::before,
.infinity::after {
    content: '';
    position: absolute;
    width: 60px;
    height: 60px;
    border: 12px solid white;
    border-radius: 50%;
}

.infinity::before {
    left: 0;
    border-right-color: transparent;
    transform: rotate(45deg);
}

.infinity::after {
    right: 0;
    border-left-color: transparent;
    transform: rotate(-45deg);
}

.connector {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    z-index: 2;
}

.spark {
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    animation: sparkle 3s infinite;
}

.spark:nth-child(1) {
    top: 20%;
    left: 20%;
    animation-delay: 0s;
}

.spark:nth-child(2) {
    top: 20%;
    right: 20%;
    animation-delay: 0.5s;
}

.spark:nth-child(3) {
    bottom: 20%;
    left: 20%;
    animation-delay: 1s;
}

.spark:nth-child(4) {
    bottom: 20%;
    right: 20%;
    animation-delay: 1.5s;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-25px) scale(1.02); }
}

@keyframes sparkle {
    0%, 100% { 
        opacity: 0; 
        transform: scale(0) rotate(0deg); 
    }
    50% { 
        opacity: 1; 
        transform: scale(1.8) rotate(180deg); 
        filter: brightness(1.5);
    }
}

.loading-title {
    color: white;
    text-align: center;
    font-size: 36px;
    font-weight: 800;
    text-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(46, 160, 67, 0.5);
    margin-bottom: 10px;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #e0e0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

.loading-subtitle {
    color: #4ade80;
    text-align: center;
    font-size: 19px;
    margin-bottom: 35px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(74, 222, 128, 0.3);
    animation: subtitlePulse 2s ease-in-out infinite;
}

@keyframes subtitlePulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.loading-progress {
    width: 240px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
}

.loading-progress::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: progressShimmer 2s infinite;
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2ea043, #4ade80, #22c55e, #2ea043);
    background-size: 200% 100%;
    border-radius: 999px;
    animation: loadingProgress 2.5s cubic-bezier(0.4, 0, 0.2, 1), 
               progressFlow 1.5s ease-in-out infinite;
    box-shadow: 
        0 0 10px rgba(46, 160, 67, 0.5),
        0 0 20px rgba(74, 222, 128, 0.3);
}

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

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

.layout-wrapper {
    display: flex;
    height: 100vh;
    height: -webkit-fill-available; /* Mobile viewport fix */
    overflow: hidden;
    position: relative;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 54px;
    background: #1e1e1e;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2a2a;
    overflow: hidden;
    position: relative;
    z-index: var(--z-fixed);
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.35s ease;
    height: 100vh;
    backdrop-filter: blur(10px);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.02) 0%,
        transparent 100%
    );
    pointer-events: none;
}

.sidebar.expanded {
    width: 260px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

body.dark-theme .sidebar {
    background: #1e1e1e;
    border-right-color: #2a2a2a;
}

body.light-theme .sidebar {
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    display: none;
}

.sidebar.expanded .sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
}

.back-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.back-btn:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

.logo-mini {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.logo-mini .logo-img {
    height: 22px;
    width: auto;
    border-radius: 6px;
    object-fit: contain;
}

.logo-mini .fallback-icon {
    font-size: 18px;
    background: linear-gradient(135deg, #0084ff, #ff6b9d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Mini Infinity Logo */
.mini-logo-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #2ea043 0%, #1e6f3e 100%);
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.mini-infinity {
    position: relative;
    width: 16px;
    height: 8px;
}

.mini-infinity::before,
.mini-infinity::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border: 2px solid white;
    border-radius: 50%;
}

.mini-infinity::before {
    left: 0;
    border-right-color: transparent;
    transform: rotate(45deg);
}

.mini-infinity::after {
    right: 0;
    border-left-color: transparent;
    transform: rotate(-45deg);
}

.menu-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.menu-toggle:hover {
    background: var(--bg-secondary);
}

/* Floating menu button when sidebar is collapsed */
.floating-menu-btn {
    display: none;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 8px;
    align-items: center;
}

.sidebar.expanded .sidebar-nav {
    align-items: stretch;
    padding: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    border: none;
    background: transparent;
    overflow: hidden;
}

/* Ripple effect on hover */
.nav-item::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.nav-item:hover::before {
    width: 120%;
    height: 120%;
}

body.light-theme .nav-item {
    color: #475569;
}

.sidebar.expanded .nav-item {
    width: auto;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 14px;
    font-size: 14px;
}

.nav-item span {
    display: none;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.sidebar.expanded .nav-item span {
    display: inline;
}

.nav-item:hover {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
    transform: translateX(2px);
}

body.light-theme .nav-item:hover {
    background: #f1f5f9;
    color: #2563eb;
    transform: translateX(3px);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(0,132,255,0.2), rgba(0,132,255,0.1));
    color: #ffffff;
    box-shadow: inset 3px 0 0 var(--primary);
    font-weight: 600;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    background: var(--primary);
    border-radius: 999px 0 0 999px;
    box-shadow: 0 0 10px var(--primary);
}

body.light-theme .nav-item.active {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #2563eb;
    box-shadow: 
        inset 3px 0 0 #2563eb,
        0 2px 8px rgba(37, 99, 235, 0.1);
}

.nav-item i {
    font-size: 18px;
    width: auto;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.nav-item:hover i {
    transform: scale(1.1);
}

.sidebar.expanded .nav-item i {
    font-size: 16px;
    width: 20px;
}

.badge {
    display: none;
}

.sidebar.expanded .badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin-left: auto;
}

body.light-theme .sidebar.expanded .badge {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
    font-weight: 700;
}

.keyboard-shortcut {
    display: none;
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-left: auto;
    font-weight: 400;
}

.sidebar.expanded .keyboard-shortcut {
    display: inline;
}

body.light-theme .sidebar.expanded .keyboard-shortcut {
    color: #94a3b8;
}

.search-container {
    display: none;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar.expanded .search-container {
    display: block;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px 12px;
    transition: var(--transition);
}

.search-input-wrapper:focus-within {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 132, 255, 0.1);
}

body.light-theme .search-input-wrapper {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

body.light-theme .search-input-wrapper:focus-within {
    background: white;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.search-icon {
    color: rgba(255,255,255,0.5);
    font-size: 14px;
}

body.light-theme .search-icon {
    color: #64748b;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    font-family: var(--font-family);
}

.search-input::placeholder {
    color: rgba(255,255,255,0.4);
}

body.light-theme .search-input {
    color: #1e293b;
}

body.light-theme .search-input::placeholder {
    color: #94a3b8;
}

.search-close-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 4px;
    transition: var(--transition);
}

.search-close-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}

body.light-theme .search-close-btn {
    color: #64748b;
}

body.light-theme .search-close-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.featured-section {
    display: none;
}

.sidebar.expanded .featured-section {
    display: block;
    padding: 12px;
    flex-shrink: 0;
}

.featured-card {
    background: linear-gradient(135deg, rgba(0,132,255,0.1), rgba(255,107,157,0.1));
    border: 1px solid rgba(0,132,255,0.2);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.featured-card:hover {
    background: linear-gradient(135deg, rgba(0,132,255,0.15), rgba(255,107,157,0.15));
    border-color: rgba(0,132,255,0.3);
}

.featured-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #0084ff, #ff6b9d);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}

.featured-icon i {
    color: white;
    font-size: 18px;
}

.featured-card h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.featured-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

body.light-theme .featured-card {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1px solid #bfdbfe;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

body.light-theme .featured-card:hover {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    transform: translateY(-2px);
}

body.light-theme .featured-icon {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.conversations-section {
    display: none;
}

.sidebar.expanded .conversations-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-top: 1px solid var(--border);
    overflow-y: auto;
    min-height: 0;
}

/* Mobile: Always show conversations section */
@media screen and (max-width: 768px) {
    .sidebar .conversations-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: 12px;
        border-top: 1px solid var(--border);
        overflow-y: auto;
        min-height: 0;
    }
}

.conversations-section h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    padding: 0 4px;
}

.conversations-note {
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
    padding: 8px 0;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: 13px;
    position: relative;
}

.conversation-item-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item-content span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-menu-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: var(--transition);
    flex-shrink: 0;
}

.conversation-item:hover .conversation-menu-btn {
    opacity: 1;
}

.conversation-menu-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.pin-indicator {
    margin-left: auto;
    font-size: 12px;
    color: var(--primary);
    opacity: 0.8;
}

.conversation-item.pinned {
    background: rgba(99, 102, 241, 0.05);
}

.conversation-menu {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    z-index: 99999;
    overflow: visible;
}

.conversation-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    font-size: 13px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.conversation-menu-item:hover {
    background: var(--bg-secondary);
}

.conversation-menu-item.danger {
    color: var(--danger);
}

.conversation-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.conversation-menu-item i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.conversation-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.conversation-item.active {
    background: rgba(0,132,255,0.15);
    color: var(--primary);
    border-left: 2px solid var(--primary);
    padding-left: 10px;
}

body.light-theme .conversation-item {
    color: #64748b;
}

body.light-theme .conversation-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

body.light-theme .conversation-item.active {
    background: #eff6ff;
    color: #2563eb;
    border-left: 3px solid #2563eb;
    font-weight: 600;
}

.conversation-item i {
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 0;
    margin-top: auto;
    background: var(--bg-primary);
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

.sidebar.expanded .sidebar-footer {
    padding: 0;
}

/* Collapsed Sidebar Footer Enhancements */
.sidebar:not(.expanded) .sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 8px;
    position: relative;
}

.sidebar:not(.expanded) .footer-profile-section {
    display: none;
}

.sidebar:not(.expanded) .footer-avatar {
    width: 38px;
    height: 38px;
    font-size: 15px;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.6);
}

.sidebar:not(.expanded) .footer-profile-section:hover .footer-avatar {
    transform: scale(1.15) rotate(8deg);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.8);
}

.sidebar:not(.expanded) .footer-menu-buttons {
    width: 100%;
    padding: 6px;
    gap: 8px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    max-height: 0;
    overflow: hidden;
}

.sidebar:not(.expanded) .footer-menu-buttons.expanded {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    max-height: 200px;
    padding: 10px 6px;
}

.sidebar.expanded .footer-quick-access {
    border-top: none;
    border-bottom: 1px solid var(--border);
}

.sidebar:not(.expanded) .footer-menu-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    position: relative;
}

.sidebar:not(.expanded) .footer-menu-btn span {
    display: none;
}

.sidebar:not(.expanded) .footer-menu-btn i {
    width: auto;
    font-size: 18px;
}

.sidebar:not(.expanded) .footer-menu-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%) translateX(-10px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.sidebar:not(.expanded) .footer-menu-btn:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

.sidebar:not(.expanded) .footer-menu-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
}

.sidebar:not(.expanded) .footer-menu-btn:hover::before {
    display: none;
}

.sidebar:not(.expanded) .footer-signout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.sidebar:not(.expanded) .footer-quick-access {
    width: 100%;
    padding: 6px;
    order: 1;
}

.sidebar:not(.expanded) .footer-user-btn {
    width: 42px;
    height: 42px;
    padding: 5px;
    border-radius: 10px;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.5);
    position: relative;
    background: transparent;
}

.sidebar:not(.expanded) .footer-btn-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
    border-width: 2px;
}

.sidebar:not(.expanded) .footer-btn-avatar:hover {
    transform: scale(1.15) rotate(8deg);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.7);
}

.sidebar:not(.expanded) .footer-btn-content {
    display: none;
}

.sidebar:not(.expanded) .footer-btn-icon {
    display: none;
}

.sidebar:not(.expanded) .footer-user-btn::after {
    content: 'User Profile';
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%) translateX(-10px);
    background: linear-gradient(135deg, #0078d4 0%, #0063b1 100%);
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 120, 212, 0.4);
}

.sidebar:not(.expanded) .footer-user-btn:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

.sidebar:not(.expanded) .footer-user-btn:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 8px 20px rgba(0, 120, 212, 0.7);
}

.sidebar:not(.expanded) .footer-menu-buttons.expanded ~ .footer-quick-access .footer-user-btn {
    background: linear-gradient(135deg, #006cbd 0%, #005a9e 100%);
    box-shadow: 0 6px 20px rgba(0, 120, 212, 0.8);
}

.sidebar:not(.expanded) .footer-menu-buttons.expanded ~ .footer-quick-access .footer-btn-icon {
    transform: rotate(180deg);
}

/* Light theme adjustments for collapsed state */
body.light-theme .sidebar:not(.expanded) .footer-menu-btn::after {
    background: rgba(30, 41, 59, 0.95);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

body.light-theme .sidebar:not(.expanded) .footer-user-btn::after {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

.sidebar-account {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.sidebar.expanded .sidebar-account {
    display: flex;
    flex-direction: column-reverse;
}

.sidebar.expanded .footer-profile-section {
    border-top: 1px solid var(--border);
    border-bottom: none;
}

/* Profile Avatar Section */
.footer-profile-section {
    padding: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-primary);
    position: relative;
}

.footer-profile-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(102, 126, 234, 0.03), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.footer-profile-section:hover::before {
    opacity: 1;
}

.footer-profile-section:hover {
    background: var(--bg-secondary);
}

.footer-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2.5px solid rgba(255, 255, 255, 0.15);
    position: relative;
    z-index: 1;
}

.footer-avatar::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s;
    filter: blur(8px);
}

.footer-profile-section:hover .footer-avatar {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.7);
    border-color: rgba(255, 255, 255, 0.25);
}

.footer-profile-section:hover .footer-avatar::before {
    opacity: 0.6;
}

.footer-profile-section:active .footer-avatar {
    transform: scale(1.05);
}

/* Menu Buttons Section */
.footer-menu-buttons {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-primary);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded .footer-menu-buttons.expanded {
    padding: 14px 12px;
    max-height: 300px;
    opacity: 1;
}

.footer-menu-btn {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
    overflow: hidden;
}

.footer-menu-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-menu-btn:hover::before {
    transform: scaleY(1);
}

.footer-menu-btn:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
    padding-left: 20px;
}

.footer-menu-btn:active {
    transform: translateX(2px) scale(0.98);
}

.footer-menu-btn i {
    width: 20px;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s;
}

.footer-menu-btn:hover i {
    transform: rotate(15deg) scale(1.1);
}

.footer-signout-btn {
    color: #ef4444;
}

.footer-signout-btn::before {
    background: #ef4444;
}

.footer-signout-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.footer-signout-btn:hover i {
    transform: translateX(3px);
}

/* Quick Access Button */
.footer-quick-access {
    padding: 12px 12px 16px 12px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
}

.footer-user-btn {
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, #0078d4 0%, #0063b1 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 16px rgba(0, 120, 212, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.footer-btn-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
    z-index: 10;
}

.footer-btn-avatar::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s;
    filter: blur(8px);
}

.footer-btn-avatar:hover {
    transform: scale(1.1) rotate(5deg);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.footer-btn-avatar:hover::after {
    opacity: 0.6;
}

.footer-btn-avatar:active {
    transform: scale(1.05);
}

/* Edit icon overlay on avatar hover */
.sidebar.expanded .footer-btn-avatar::before {
    content: '\f304';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1;
    pointer-events: none;
}

.sidebar.expanded .footer-btn-avatar:hover::before {
    opacity: 1;
}

.footer-btn-content {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.footer-btn-icon {
    font-size: 14px;
    opacity: 0.8;
    transition: transform 0.3s, opacity 0.3s;
}

.sidebar.expanded .footer-menu-buttons.expanded ~ .footer-quick-access .footer-btn-icon {
    transform: rotate(180deg);
}



.footer-user-btn:hover .footer-btn-icon {
    opacity: 1;
}

.footer-user-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.footer-user-btn:hover::before {
    left: 100%;
}

.footer-user-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(255,255,255,0.3), rgba(255,255,255,0));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s;
}

.footer-user-btn:hover {
    background: linear-gradient(135deg, #006cbd 0%, #005a9e 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 28px rgba(0, 120, 212, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.footer-user-btn:hover::after {
    opacity: 1;
}

.footer-user-btn:active {
    transform: translateY(-1px) scale(1);
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.5);
}

.footer-user-btn i {
    font-size: 19px;
    z-index: 1;
    transition: transform 0.3s;
}

.footer-user-btn:hover i {
    transform: scale(1.1) rotate(-5deg);
}

.footer-user-btn span {
    z-index: 1;
    font-weight: 600;
}

/* Expanded sidebar - menu expanded state */
.sidebar.expanded .footer-menu-buttons.expanded ~ .footer-quick-access .footer-user-btn {
    background: linear-gradient(135deg, #006cbd 0%, #005a9e 100%);
}

/* Light theme adjustments */
body.light-theme .footer-profile-section {
    background: #ffffff;
    border-bottom-color: #e2e8f0;
}

body.light-theme .footer-profile-section:hover {
    background: #f8fafc;
}

body.light-theme .footer-profile-section::before {
    background: radial-gradient(circle at center, rgba(37, 99, 235, 0.05), transparent);
}

body.light-theme .footer-avatar {
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    border-color: rgba(102, 126, 234, 0.2);
}

body.light-theme .footer-profile-section:hover .footer-avatar {
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.6);
}

body.light-theme .footer-menu-buttons {
    background: #ffffff;
}

body.light-theme .footer-menu-btn {
    color: #1e293b;
}

body.light-theme .footer-menu-btn:hover {
    background: #f1f5f9;
}

body.light-theme .footer-menu-btn::before {
    background: #2563eb;
}

body.light-theme .footer-signout-btn {
    color: #dc2626;
}

body.light-theme .footer-signout-btn:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

body.light-theme .footer-quick-access {
    background: #ffffff;
}

body.light-theme .footer-user-btn {
    box-shadow: 0 6px 16px rgba(0, 120, 212, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

body.light-theme .footer-user-btn:hover {
    box-shadow: 0 10px 28px rgba(0, 120, 212, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.sign-in-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0;
    margin: 8px;
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.7);
    border: none;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.2s;
}

.sign-in-btn:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

.sidebar.expanded .sign-in-btn {
    width: calc(100% - 16px);
    padding: 12px;
    margin: 12px 8px;
    background: linear-gradient(135deg, #0078d4 0%, #0063b1 100%);
    color: white;
    font-size: 14px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.35);
}

.sidebar.expanded .sign-in-btn:hover {
    background: linear-gradient(135deg, #006cbd 0%, #005a9e 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 120, 212, 0.5);
}

.sign-in-btn span {
    display: none;
}

.sidebar.expanded .sign-in-btn span {
    display: inline;
}

.sign-in-btn:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar.expanded .sign-in-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

body.light-theme .sign-in-btn {
    color: #64748b;
}

body.light-theme .sign-in-btn:hover {
    background: #f1f5f9;
    color: #2563eb;
}

body.light-theme .sidebar.expanded .sign-in-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

body.light-theme .sidebar.expanded .sign-in-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transform: translateY(-2px);
}

.sign-in-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* ==================== MAIN CONTAINER ==================== */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--app-bg);
    overflow-y: auto;
}

body.light-theme .main-container {
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
}

.gradient-blob {
    position: fixed;
    pointer-events: none;
    opacity: 0.08;
    z-index: 0;
}

body.light-theme .gradient-blob {
    opacity: 0.03;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(45deg, #0084ff, #ff6b9d);
    border-radius: 45% 55% 52% 48% / 48% 45% 55% 52%;
    animation: blobAnimation 15s infinite ease-in-out;
    top: -50px;
    right: 10%;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: linear-gradient(45deg, #ffa502, #10b981);
    border-radius: 52% 48% 45% 55% / 55% 52% 48% 45%;
    animation: blobAnimation 18s infinite ease-in-out reverse;
    bottom: 20%;
    left: 5%;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: linear-gradient(45deg, #10b981, #0084ff);
    border-radius: 48% 52% 55% 45% / 45% 48% 52% 55%;
    animation: blobAnimation 20s infinite ease-in-out;
    bottom: -50px;
    right: 20%;
}

@keyframes blobAnimation {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(50px, 50px) scale(1.05); }
    50% { transform: translate(0, 100px) scale(1); }
    75% { transform: translate(-50px, 50px) scale(0.95); }
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    padding: 24px;
    gap: 24px;
    justify-content: flex-start;
    overflow: hidden;
}

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

.header-content h2 {
    font-size: 32px;
    font-weight: 300;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

body.dark-theme .header-content h2,
body.curious-theme .header-content h2 {
    color: #f5f5f5;
}

body.light-theme .header-content h2 {
    color: #1e293b;
    font-weight: 400;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #f5f5f5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

body.light-theme .theme-toggle {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1px solid #bfdbfe;
    color: #2563eb;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}

body.light-theme .theme-toggle:hover {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: #2563eb;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
    transform: scale(1.05);
}

/* ==================== CAROUSEL ==================== */
.carousel-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.carousel-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 120px;
}

.carousel-slide {
    display: none;
    animation: slideIn 0.5s ease-in-out;
}

.carousel-slide.active {
    display: block;
}

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

.slide-card {
    display: flex;
    gap: 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.slide-card:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(0,132,255,0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,132,255,0.15);
}

.slide-image {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.slide-image i {
    font-size: 32px;
    color: white;
    z-index: 2;
    position: relative;
}

.image-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.3), transparent);
    top: 0;
    left: 0;
}

.slide-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.slide-action {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.slide-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.carousel-nav {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.08);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.carousel-nav:hover {
    background: rgba(255,255,255,0.15);
    border-color: var(--primary);
}

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

body.light-theme .carousel-nav {
    border-color: rgba(0,0,0,0.15);
    background: rgba(0,0,0,0.05);
    color: var(--text-primary);
}

body.light-theme .carousel-nav:hover {
    background: rgba(0,0,0,0.08);
}

body.light-theme .slide-card {
    background: rgba(0,0,0,0.02);
    border-color: rgba(0,0,0,0.08);
}

body.light-theme .slide-card:hover {
    background: rgba(0,0,0,0.04);
    border-color: var(--primary);
}

/* ==================== MESSAGES ==================== */
.messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    min-height: 0;
    max-height: calc(100vh - 350px);
    padding-right: 8px;
    /* Enhanced mobile scrolling */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

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

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.message {
    display: flex;
    gap: 12px;
}

.message.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0084ff, #ff6b9d);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: rgba(255,255,255,0.2);
    color: #f5f5f5;
}

.message.assistant .message-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #2ea043 0%, #1e6f3e 100%);
    border-radius: 8px;
    padding: 6px;
}

.assistant-infinity {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistant-infinity-icon {
    position: relative;
    width: 18px;
    height: 9px;
}

.assistant-infinity-icon::before,
.assistant-infinity-icon::after {
    content: '';
    position: absolute;
    width: 9px;
    height: 9px;
    border: 2px solid white;
    border-radius: 50%;
}

.assistant-infinity-icon::before {
    left: 0;
    border-right-color: transparent;
    transform: rotate(45deg);
}

.assistant-infinity-icon::after {
    right: 0;
    border-left-color: transparent;
    transform: rotate(-45deg);
}

.message-bubble {
    max-width: 60%;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    color: #f5f5f5;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 15px;
    border: 1px solid rgba(255,255,255,0.1);
}

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

.message.assistant .message-bubble {
    border-bottom-left-radius: 4px;
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message.assistant:hover .message-actions,
.message.user:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: var(--transition);
}

.message.user .message-action-btn {
    background: rgba(0,0,0,0.2);
    border-color: rgba(0,0,0,0.25);
    color: rgba(255,255,255,0.8);
}

.message-action-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #f5f5f5;
    border-color: rgba(255,255,255,0.25);
}

body.light-theme .message-action-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
}

body.light-theme .message-action-btn:hover {
    background: #e0e7ff;
    border-color: #2563eb;
    color: var(--primary);
}

/* Edit Message */
.edit-message-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.edit-message-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.15);
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-family);
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: var(--transition);
}

.edit-message-input:focus {
    border-color: var(--primary);
    background: rgba(255,255,255,0.08);
    box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.1);
}

body.light-theme .edit-message-input {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #1e293b;
}

body.light-theme .edit-message-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.edit-message-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.edit-save-btn,
.edit-cancel-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family);
}

.edit-save-btn {
    background: var(--primary);
    color: white;
}

.edit-save-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.3);
}

.edit-cancel-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
}

.edit-cancel-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

body.light-theme .edit-save-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

body.light-theme .edit-save-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

body.light-theme .edit-cancel-btn {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #64748b;
}

body.light-theme .edit-cancel-btn:hover {
    background: #e2e8f0;
}

/* ==================== STRUCTURED MESSAGE CONTENT ==================== */
/* Content Sections */
.message-content {
    word-break: break-word;
    overflow-wrap: break-word;
}

.message-content > *:first-child {
    margin-top: 0;
}

.message-content > *:last-child {
    margin-bottom: 0;
}

/* Headings with underline style */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 16px 0 12px 0;
    font-weight: 700;
    line-height: 1.4;
}

.message-content h1 {
    font-size: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(255,255,255,0.2);
}

.message-content h2 {
    font-size: 18px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    color: #ffffff;
}

.message-content h3 {
    font-size: 16px;
    color: #f0f0f0;
    font-weight: 600;
}

.message-content h4 {
    font-size: 15px;
    color: #e8e8e8;
    font-weight: 600;
}

/* Paragraphs */
.message-content p {
    margin: 10px 0;
    line-height: 1.6;
}

/* Lists - Numbered and Unordered */
.message-content ol,
.message-content ul {
    margin: 12px 0 12px 24px;
    line-height: 1.7;
}

.message-content li {
    margin: 8px 0;
    line-height: 1.6;
}

.message-content ol li {
    list-style-type: decimal;
}

.message-content ul li {
    list-style-type: disc;
}

.message-content ul ul li {
    list-style-type: circle;
}

.message-content ol ol li {
    list-style-type: lower-alpha;
}

/* Bold text */
.message-content strong,
.message-content b {
    font-weight: 700;
    color: #ffffff;
}

/* Italic text */
.message-content em,
.message-content i {
    font-style: italic;
    opacity: 0.95;
}

/* Code blocks and inline code */
.message-content code {
    background: rgba(0,0,0,0.3);
    color: #a8e6a1;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.message-content pre {
    background: rgba(0,0,0,0.4);
    border-left: 3px solid var(--primary);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.message-content pre code {
    background: transparent;
    color: #a8e6a1;
    padding: 0;
}

/* Blockquotes */
.message-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 12px;
    margin: 12px 0;
    opacity: 0.9;
    font-style: italic;
    color: #d0d0d0;
}

/* Horizontal Rule */
.message-content hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.15);
    margin: 16px 0;
}

/* Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}

.message-content table thead {
    background: rgba(255,255,255,0.08);
}

.message-content table th,
.message-content table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.message-content table th {
    font-weight: 700;
    color: #ffffff;
}

.message-content table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

/* Links */
.message-content a {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0,132,255,0.3);
}

.message-content a:hover {
    color: #70c0ff;
    border-bottom-color: var(--primary);
    text-decoration: underline;
}

/* Highlighted content - For emphasis blocks */
.message-content .highlight {
    background: rgba(255,255,255,0.08);
    padding: 12px;
    border-left: 3px solid var(--secondary);
    border-radius: 4px;
    margin: 12px 0;
}

/* Definition lists */
.message-content dt {
    font-weight: 700;
    margin-top: 12px;
}

.message-content dd {
    margin-left: 20px;
    margin-bottom: 8px;
    opacity: 0.95;
}

/* Light theme adjustments for structured content */
body.light-theme .message-content h1,
body.light-theme .message-content h2,
body.light-theme .message-content h3,
body.light-theme .message-content h4,
body.light-theme .message-content h5,
body.light-theme .message-content h6 {
    color: var(--text-primary);
}

body.light-theme .message-content h1 {
    border-bottom-color: var(--border);
}

body.light-theme .message-content h2 {
    border-bottom-color: var(--border);
}

body.light-theme .message-content strong,
body.light-theme .message-content b {
    color: var(--text-primary);
}

body.light-theme .message-content code {
    background: rgba(37, 99, 235, 0.08);
    color: #0066cc;
}

body.light-theme .message-content pre {
    background: rgba(0,0,0,0.05);
    border-left-color: var(--primary);
}

body.light-theme .message-content pre code {
    color: #0066cc;
}

body.light-theme .message-content blockquote {
    border-left-color: var(--primary);
    color: var(--text-secondary);
}

body.light-theme .message-content hr {
    border-top-color: var(--border);
}

body.light-theme .message-content table th,
body.light-theme .message-content table td {
    border-bottom-color: var(--border);
}

body.light-theme .message-content table thead {
    background: rgba(37, 99, 235, 0.05);
}

body.light-theme .message-content table tbody tr:hover {
    background: rgba(37, 99, 235, 0.03);
}

body.light-theme .message-content a {
    color: var(--primary);
    border-bottom-color: rgba(37, 99, 235, 0.3);
}

body.light-theme .message-content a:hover {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

body.light-theme .message-content .highlight {
    background: rgba(37, 99, 235, 0.05);
    border-left-color: var(--secondary);
}

/* Voice Listening Modal */
.voice-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(10px);
}

.voice-modal.active {
    display: flex;
}

.voice-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 40px;
}

.voice-listening-text {
    font-size: 28px;
    font-weight: 300;
    color: white;
    letter-spacing: 0.5px;
}

.voice-controls {
    display: flex;
    gap: 20px;
    align-items: center;
}

.voice-control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: var(--transition);
}

.voice-control-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.voice-mic-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.4);
    animation: voicePulse 2s infinite;
}

@keyframes voicePulse {
    0%, 100% {
        box-shadow: 0 0 30px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 0 50px rgba(102, 126, 234, 0.8), 0 0 80px rgba(102, 126, 234, 0.3);
    }
}

.voice-mic-btn:hover {
    transform: scale(1.05);
}

/* ==================== CHAT SECTION ==================== */
.chat-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: auto;
    flex-shrink: 0;
    position: relative;
    transition: all 0.3s ease;
}

/* ==================== CHATGPT-LIKE BEHAVIOR ==================== */
/* After chat starts - input sticky at bottom */
.main-content.chat-started .chat-section,
.chat-container.chat-started .chat-section {
    position: fixed;
    bottom: 0;
    left: 280px;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    z-index: 1000;
    margin: 0;
    padding: 16px 24px;
}

/* Adjust for mobile when sidebar is hidden */
@media (max-width: 768px) {
    .main-content.chat-started .chat-section,
    .chat-container.chat-started .chat-section {
        left: 0;
        right: 0;
    }
}

/* Add padding to messages container when input is fixed */
.main-content.chat-started #messagesContainer,
.chat-container.chat-started #messagesContainer {
    padding-bottom: 100px;
}

/* Hide action grid and carousel after chat starts */
.main-content.chat-started #actionGrid,
.chat-container.chat-started #actionGrid {
    opacity: 0 !important;
    pointer-events: none !important;
    height: 0 !important;
    overflow: hidden !important;
}

.main-content.chat-started #carouselSection,
.chat-container.chat-started #carouselSection {
    display: none !important;
}

/* More Options Menu */
.more-options-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 250px;
}

.more-options-menu.show {
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

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

.more-option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
    text-align: left;
}

.more-option-item:hover {
    background: var(--bg-secondary);
}

.more-option-item i {
    width: 20px;
    font-size: 16px;
    color: var(--text-secondary);
}

body.dark-theme .more-options-menu {
    background: #2a2a2a;
    border-color: #3a3a3a;
}

/* Input Controls */
.input-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.control-btn:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
}

.control-btn i {
    font-size: 14px;
}

body.light-theme .control-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
}

body.light-theme .control-btn:hover {
    background: #e0e7ff;
    border-color: #2563eb;
    color: var(--primary);
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 24px;
    padding: 12px 16px;
    transition: var(--transition);
}

.input-area:focus-within {
    border-color: rgba(0,132,255,0.5);
    background: rgba(255,255,255,0.12);
    box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.1);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    color: #f5f5f5;
    font-size: 15px;
    font-family: var(--font-family);
    outline: none;
    resize: none;
    min-height: 20px;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
}

.chat-input::placeholder {
    color: rgba(255,255,255,0.5);
}

.input-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-response-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    white-space: nowrap;
}

.quick-response-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #f5f5f5;
}

.quick-response-btn i:first-child {
    font-size: 10px;
}

.quick-response-btn i:last-child {
    font-size: 10px;
    margin-left: 4px;
}

.input-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
}

.input-action:hover {
    color: #f5f5f5;
}

.more-btn {
    color: rgba(255,255,255,0.7);
    font-size: 18px;
}

.more-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--primary);
    transform: rotate(90deg);
}

.attach-btn {
    color: rgba(255,255,255,0.7);
}

.attach-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #10b981;
}

.photo-btn {
    color: rgba(255,255,255,0.7);
}

.photo-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #ff6b9d;
}

.voice-btn {
    color: rgba(255,255,255,0.7);
}

.voice-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #f5f5f5;
}

.voice-btn.active {
    background: var(--danger);
    color: white;
    animation: pulse 1.5s infinite;
}

.transcribe-btn {
    color: rgba(255,255,255,0.7);
    transition: all 0.2s ease;
}

.transcribe-btn:hover {
    background: rgba(100, 200, 255, 0.2);
    color: #64c8ff;
}

.transcribe-btn:active {
    transform: scale(0.95);
}

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

.audio-btn {
    color: rgba(255,255,255,0.7);
}

.audio-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #f5f5f5;
}

.voice-assistant-label {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-left: 8px;
    white-space: nowrap;
    transition: var(--transition);
}

.voice-assistant-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    padding: 0 8px;
    border-radius: 20px;
}

.voice-bubble-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.sound-waves line {
    opacity: 0.7;
    animation: soundWave 1.5s ease-in-out infinite;
}

.sound-waves line:nth-child(1) {
    animation-delay: 0s;
}

.sound-waves line:nth-child(2) {
    animation-delay: 0.1s;
}

.sound-waves line:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes soundWave {
    0%, 100% {
        opacity: 0.4;
        stroke-width: 1.5px;
    }
    50% {
        opacity: 1;
        stroke-width: 2px;
    }
}

body.light-theme .voice-btn,
body.light-theme .audio-btn,
body.light-theme .more-btn,
body.light-theme .attach-btn,
body.light-theme .photo-btn {
    color: var(--text-secondary);
}

body.light-theme .more-btn:hover {
    background: #f1f5f9;
    color: var(--primary);
    transform: rotate(90deg);
}

body.light-theme .voice-btn:hover,
body.light-theme .audio-btn:hover {
    background: #f1f5f9;
    color: var(--primary);
}

body.light-theme .attach-btn:hover {
    background: #f1f5f9;
    color: #10b981;
}

body.light-theme .photo-btn:hover {
    background: #f1f5f9;
    color: #ff6b9d;
}

body.light-theme .voice-btn.active {
    background: var(--danger);
    color: white;
}

body.light-theme .transcribe-btn {
    color: var(--text-secondary);
}

body.light-theme .transcribe-btn:hover {
    background: #e0f2fe;
    color: #0284c7;
}

body.light-theme .voice-assistant-label {
    color: var(--text-secondary);
}

body.light-theme .voice-assistant-btn:hover {
    background: #f1f5f9;
}

.send-btn {
    background: var(--primary);
    color: white;
}

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.newline-btn {
    background: rgba(74, 144, 226, 0.2);
    color: var(--primary);
}

.newline-btn:hover {
    background: rgba(74, 144, 226, 0.3);
    transform: scale(1.1);
}

.newline-btn i {
    transform: rotate(90deg);
}

body.light-theme .send-btn {
    background: var(--primary);
    color: white;
}

body.light-theme .send-btn:hover {
    background: var(--primary-dark);
}

body.light-theme .newline-btn {
    background: rgba(74, 144, 226, 0.15);
    color: var(--primary);
}

body.light-theme .newline-btn:hover {
    background: rgba(74, 144, 226, 0.25);
}

.quick-response-dropdown {
    display: none;
    flex-direction: row;
    gap: 8px;
    padding: 8px 0;
    animation: slideDown 0.3s ease-out;
}

.quick-response-dropdown.show {
    display: flex;
}

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

.quick-btn {
    padding: 8px 16px;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.quick-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
    text-align: center;
}

.action-btn:hover {
    background: rgba(0,132,255,0.15);
    border-color: rgba(0,132,255,0.3);
    color: #f5f5f5;
}

.action-btn i {
    font-size: 20px;
}

/* ==================== LIGHT THEME ENHANCEMENTS ==================== */
body.light-theme .input-area {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body.light-theme .input-area:focus-within {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), 0 4px 12px rgba(0,0,0,0.08);
}

body.light-theme .chat-input {
    color: var(--text-primary);
}

body.light-theme .chat-input::placeholder {
    color: #94a3b8;
}

body.light-theme .quick-response-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
}

body.light-theme .quick-response-btn:hover {
    background: #e0e7ff;
    border-color: #2563eb;
    color: var(--primary);
}

body.light-theme .input-action {
    color: #64748b;
}

body.light-theme .input-action:hover {
    color: var(--primary);
    background: #f1f5f9;
}

body.light-theme .action-btn {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

body.light-theme .action-btn:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

body.light-theme .quick-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
}

body.light-theme .quick-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

body.light-theme .message-bubble {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body.light-theme .message.user .message-bubble {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

body.light-theme .message.assistant .message-bubble {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
}

body.light-theme .message-avatar {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

body.light-theme .message.user .message-avatar {
    background: #e0e7ff;
    color: var(--primary);
}

body.light-theme .carousel-nav {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    color: var(--text-primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

body.light-theme .carousel-nav:hover:not(:disabled) {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

body.light-theme .slide-card {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

body.light-theme .slide-card:hover {
    background: #f8fafc;
    border-color: #2563eb;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15);
}

body.light-theme .slide-image {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
}

body.light-theme .slide-image i {
    color: #2563eb;
}

body.light-theme .floating-menu-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

body.light-theme .floating-menu-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .action-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .layout-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 200px;
        flex-direction: row;
    }

    .sidebar-nav {
        flex-direction: row;
        flex: 1;
    }

    .featured-section,
    .conversations-section,
    .sidebar-footer {
        display: none;
    }

    .main-container {
        height: calc(100vh - 200px);
    }

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

    .header-content h2 {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .sidebar-header {
        padding: 12px 8px;
    }

    .main-content {
        padding: 16px;
        gap: 16px;
    }

    .action-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .action-btn {
        padding: 12px 8px;
        font-size: 12px;
    }

    .action-btn i {
        font-size: 18px;
    }

    .message-bubble {
        max-width: 80%;
    }

    .header-content h2 {
        font-size: 20px;
    }

    .quick-response-btn span {
        display: none;
    }

    .quick-response-btn {
        padding: 6px 10px;
    }

    .control-btn span {
        display: none;
    }

    .control-btn {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        max-height: 150px;
    }

    .main-container {
        height: calc(100vh - 150px);
    }

    .main-content {
        padding: 12px;
        gap: 12px;
    }

    .action-grid {
        grid-template-columns: 1fr;
    }

    .quick-response-btn span {
        display: none;
    }

    .message-bubble {
        max-width: 100%;
    }

    .header-content h2 {
        font-size: 18px;
    }
}

/* ==================== AUTH MODAL ==================== */
.auth-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.auth-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-modal {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
    position: relative;
}

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

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

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

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

.auth-modal-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auth-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.auth-modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.auth-modal-body {
    padding: 24px;
}

.auth-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: -2px;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.auth-tab:hover {
    color: var(--text-primary);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
    font-family: var(--font-family);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
}

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

.auth-submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.auth-submit-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.3);
}

.auth-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-tertiary);
    font-size: 14px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-divider::before {
    margin-right: 12px;
}

.auth-divider::after {
    margin-left: 12px;
}

.social-auth-btns {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.social-auth-btn {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.social-auth-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
    transform: translateY(-2px);
}

.social-auth-btn i {
    font-size: 18px;
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: none;
}

.auth-error.show {
    display: block;
}

.auth-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: none;
}

.auth-success.show {
    display: block;
}

.password-toggle {
    position: relative;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    transition: var(--transition);
}

.password-toggle-btn:hover {
    color: var(--text-primary);
}

.form-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.form-link:hover {
    text-decoration: underline;
}

/* ==================== SETTINGS MODAL ==================== */
.settings-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.settings-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-modal {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.settings-modal-header {
    padding: 24px;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 1;
}

.settings-modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 24px;
}

.settings-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--transition);
}

.settings-modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-modal-body {
    padding: 24px;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section-title i {
    color: var(--primary);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.settings-item:hover {
    background: var(--bg-tertiary);
}

.settings-item-info {
    flex: 1;
}

.settings-item-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.settings-item-description {
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-toggle {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--text-tertiary);
    border-radius: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.settings-toggle.active {
    background: var(--primary);
}

.settings-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

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

.settings-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 132, 255, 0.3);
}

.settings-btn i {
    font-size: 12px;
}

.settings-btn-danger {
    background: var(--danger);
}

.settings-btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.settings-divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
    width: 100%;
}

.settings-danger-zone {
    border: 2px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 16px;
    background: rgba(239, 68, 68, 0.05);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge i {
    font-size: 10px;
}

body.light-theme .settings-btn {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.light-theme .settings-danger-zone {
    background: rgba(239, 68, 68, 0.03);
    border-color: rgba(239, 68, 68, 0.15);
}

.settings-select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.settings-select:focus {
    outline: none;
    border-color: var(--primary);
}

.settings-input {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    min-width: 100px;
}

.settings-input:focus {
    outline: none;
    border-color: var(--primary);
}

.settings-button {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.settings-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.settings-button.danger {
    background: var(--danger);
}

.settings-button.danger:hover {
    background: #dc2626;
}

.settings-button.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.settings-button.secondary:hover {
    background: var(--border);
}

.settings-footer {
    padding: 16px 24px;
    border-top: 2px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
}

/* Memory Manager Styles */
.settings-manage-btn {
    padding: 6px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-manage-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.memory-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.memory-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

.memory-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.memory-item-content {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.memory-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.memory-item-actions {
    display: flex;
    gap: 8px;
}

.memory-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s;
}

.memory-action-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.memory-action-btn.delete:hover {
    color: var(--danger);
}

.memory-category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0, 132, 255, 0.1);
    color: var(--primary);
}

/* Memory Tabs */
.memory-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
}

.memory-tab {
    flex: 1;
    padding: 16px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.memory-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.memory-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-secondary);
}

.memory-tab i {
    font-size: 16px;
}

.memory-tab-content {
    display: none;
}

.memory-tab-content.active {
    display: block;
}

/* Insights Styles */
.insights-panel {
    padding: 0;
}

.insight-section {
    margin-bottom: 24px;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
}

.insight-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-section h3 i {
    color: var(--primary);
}

.topic-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topic-tag {
    display: inline-block;
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border-radius: 16px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.topic-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 132, 255, 0.3);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.predictions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prediction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.prediction-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.prediction-text {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
}

.prediction-confidence {
    padding: 4px 10px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.active-topic-card {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary);
}

.active-topic-card h4 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 15px;
}

.active-topic-card p {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.topic-date {
    font-size: 11px;
    color: var(--text-tertiary);
}

.feedback-confirmation {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    animation: slideUp 0.3s ease;
}

.feedback-confirmation.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Profile Photo Section */
.profile-photo-section {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.profile-photo-container {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid var(--border);
    transition: var(--transition);
}

.profile-photo-container:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

.profile-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-photo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    border-radius: 50%;
}

.profile-photo-container:hover .profile-photo-overlay {
    opacity: 1;
}

.profile-photo-overlay i {
    color: white;
    font-size: 20px;
}

.profile-photo-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

/* Profile Edit Fields */
.profile-edit-field {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.profile-edit-field .settings-input {
    flex: 1;
}

.profile-name-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.settings-textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
    resize: vertical;
    min-height: 80px;
    transition: var(--transition);
}

.settings-textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
}

.bio-counter {
    align-self: flex-end;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: -4px;
}

.bio-counter.limit-warning {
    color: var(--warning);
}

.bio-counter.limit-exceeded {
    color: var(--danger);
}

/* Responsive adjustments for profile section */
@media (max-width: 768px) {
    .profile-photo-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .profile-photo-actions {
        flex-direction: row;
        width: 100%;
    }
    
    .profile-name-fields {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .profile-edit-field {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
}

/* Light theme support for profile components */
body.light-theme .profile-photo-container {
    border-color: #e2e8f0;
}

body.light-theme .profile-photo-container:hover {
    border-color: var(--primary);
}

body.light-theme .settings-textarea {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #1e293b;
}

body.light-theme .settings-textarea:focus {
    border-color: var(--primary);
    background: white;
}

body.light-theme .bio-counter {
    color: #64748b;
}

/* Library Styles */
.library-header {
    text-align: center;
    padding: 40px 20px 30px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 30px;
}

.library-header h2 {
    color: var(--text-primary);
    font-size: 28px;
    margin-bottom: 8px;
    font-weight: 600;
}

.library-header p {
    color: var(--text-secondary);
    font-size: 16px;
}

.library-section {
    margin: 30px 20px;
}

.library-section h3 {
    color: var(--text-primary);
    font-size: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.library-section h3 i {
    color: var(--primary);
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.library-image-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.library-image-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.image-container {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: var(--transition);
}

.library-image-card:hover .image-overlay {
    opacity: 1;
}

.image-overlay button {
    background: var(--bg-primary);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.image-overlay button:hover {
    background: var(--primary);
    color: white;
}

.image-overlay button.delete-btn:hover {
    background: var(--danger);
}

.image-info {
    padding: 15px;
}

.image-prompt {
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 8px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    text-overflow: ellipsis;
}

.image-date {
    color: var(--text-secondary);
    font-size: 12px;
}

.library-empty {
    padding: 60px 20px;
    text-align: center;
}

.empty-state {
    max-width: 300px;
    margin: 0 auto;
}

.empty-state i {
    font-size: 48px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-primary);
    font-size: 20px;
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Image Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.image-modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.image-modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.image-modal-header h3 {
    color: var(--text-primary);
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.image-modal-body {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-body img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
}

/* Generated Image Styles */
.message-bubble.image-bubble {
    max-width: 100%;
    padding: 0;
    background: transparent;
    border: none;
}

.generated-image-container {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.generated-image-container img {
    max-width: 100%;
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}

.image-details {
    padding: 0 8px;
}

.image-details p {
    margin: 8px 0;
    font-size: 0.85em;
    color: var(--text-secondary);
    word-break: break-word;
}

.image-details strong {
    color: var(--text-primary);
}

.image-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    padding: 0 8px;
}

.image-actions button {
    flex: 1;
    min-width: 100px;
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
}

.image-actions button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 132, 255, 0.3);
}

.image-actions button:active {
    transform: translateY(0);
}

.image-actions button i {
    font-size: 0.9em;
}

/* Image Generation Loading */
.image-generation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    text-align: center;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== VIDEO GENERATION MODAL ==================== */

.video-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.video-modal-overlay.show {
    display: flex !important;
}

.video-modal {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

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

.video-modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.video-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.video-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--transition);
}

.video-modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.video-modal-body {
    overflow-y: auto;
    flex: 1;
    padding: 24px;
}

.video-form .form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 14px;
}

.form-input,
.video-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    transition: var(--transition);
}

.form-input:focus,
.video-textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.1);
}

.video-textarea {
    resize: vertical;
    min-height: 100px;
    font-family: var(--font-family);
}

.char-counter {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
    text-align: right;
}

.video-preview {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.video-preview video {
    width: 100%;
    border-radius: 8px;
    background: #000;
}

.video-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.video-loading {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 132, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.video-modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.settings-button {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-button:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.3);
}

.settings-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.settings-button.secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-button.secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.settings-button.danger {
    background: var(--danger);
}

.settings-button.danger:hover:not(:disabled) {
    background: #dc2626;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #f0f0f0;
  border-radius: 8px;
  width: fit-content;
}

.typing-indicator.hidden {
  display: none;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: typing 1.4s infinite;
}

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

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

@keyframes menuPulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 4px 20px rgba(0, 132, 255, 0.4);
        transform: scale(1.05);
    }
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.5;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-10px);
  }
}

/* ==================== FILE PREVIEW AREA ==================== */
#filePreviewArea { transition: all 0.3s ease; position: relative; }
#filePreviewArea:hover { opacity: 1 !important; }
#filePreviewContainer { scrollbar-width: thin; }
.file-preview-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--primary-color); color: white; border-radius: 8px; }

/* ==================== MOBILE RESPONSIVE STYLES ==================== */

/* Mobile Menu Button (Hamburger) - Hidden on desktop */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1100;
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    touch-action: manipulation;
    animation: menuPulse 2s ease-in-out 3;
}

.mobile-menu-btn:hover {
    background: var(--bg-tertiary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transform: scale(1.05);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Hide menu button when sidebar is open */
.sidebar.open ~ .main-container .mobile-menu-btn {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* Sidebar Overlay - Hidden on desktop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.dark-theme .sidebar-overlay.active {
    background: rgba(0, 0, 0, 0.8);
}

body.light-theme .sidebar-overlay.active {
    background: rgba(0, 0, 0, 0.5);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Tablets and smaller devices */
@media screen and (max-width: 1024px) {
    .app-container {
        padding: 8px;
    }

    .sidebar {
        width: 280px;
    }

    /* Removed margin-left to fix mobile layout */

    .settings-modal {
        max-width: 90%;
        margin: 20px;
    }
}

/* Mobile devices */
@media screen and (max-width: 768px) {
    /* App layout */
    .app-container {
        padding: 0;
    }

    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 100;
        position: relative;
    }

    /* Show sidebar overlay when sidebar is open */
    .sidebar-overlay {
        display: block;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        background: rgba(0, 0, 0, 0.65);
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 90vw;
        height: 100vh;
        height: 100dvh;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid var(--border);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        background: var(--bg-primary);
        display: flex;
        flex-direction: column;
        will-change: transform;
        border-right: 1px solid var(--border);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 48px rgba(0, 0, 0, 0.6);
    }

    /* Force expanded state on mobile - always show full width with labels */
    .sidebar,
    .sidebar.expanded {
        width: 280px;
        max-width: 90vw;
    }
    
    /* Show all sidebar content on mobile */
    .sidebar .nav-item {
        width: auto;
        justify-content: flex-start;
        gap: 12px;
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .sidebar .nav-item span {
        display: inline;
        font-weight: 500;
    }
    
    .sidebar .nav-item i {
        font-size: 16px;
        width: 20px;
    }
    
    .sidebar .sidebar-nav {
        align-items: stretch;
        padding: 12px;
    }
    
    /* Show search container on mobile */
    .sidebar .search-container {
        display: block;
    }
    
    /* Show badges and shortcuts on mobile */
    .sidebar .badge {
        display: inline-block;
        background: var(--primary);
        color: white;
        font-size: 10px;
        padding: 2px 6px;
        border-radius: 4px;
        font-weight: 600;
        margin-left: auto;
    }
    
    /* Show sidebar header on mobile */
    .sidebar .sidebar-header {
        display: flex;
    }
    
    /* Show sidebar footer properly on mobile */
    .sidebar .sidebar-footer {
        display: block;
        padding: 0;
    }
    
    /* Override collapsed footer styles on mobile */
    .sidebar .footer-profile-section {
        display: block;
    }
    
    /* Show featured section on mobile */
    .sidebar .featured-section {
        display: block;
        padding: 12px;
        flex-shrink: 0;
    }

    /* Ensure sidebar content is visible when open */
    .sidebar.open .sidebar-nav,
    .sidebar.open .sidebar-content,
    .sidebar.open .sidebar-footer {
        opacity: 1;
        visibility: visible;
    }

    /* Better touch targets for sidebar items */
    .sidebar .nav-item,
    .sidebar .conversation-item {
        min-height: 44px;
        padding: 12px 16px;
        touch-action: manipulation;
    }

    /* Improve sidebar scrolling */
    .sidebar .conversations-list {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Add visual edge indicator for sidebar (shows when closed) */
    .sidebar::after {
        content: '';
        position: fixed;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 60px;
        background: linear-gradient(to right, var(--primary), transparent);
        opacity: 0.6;
        pointer-events: none;
        z-index: 999;
        transition: opacity 0.3s ease;
    }

    .sidebar.open::after {
        opacity: 0;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
    }

    .main-container {
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
    }

    /* Center content vertically when no messages */
    .main-content:has(.messages-container:empty) {
        justify-content: space-between;
    }

    /* Header adjustments for mobile menu button */
    .header {
        display: flex;
        align-items: center;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-primary);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border);
    }

    .header-content {
        flex: 1;
        min-width: 0; /* Prevent text overflow */
    }

    /* Header adjustments */
    .app-header {
        padding: 12px 16px;
        gap: 12px;
    }

    .app-header h1 {
        font-size: 18px;
    }

    .header-actions {
        gap: 8px;
    }

    .header-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .header-btn span {
        display: none;
    }

    /* Main header with greeting */
    .header {
        padding: 16px;
        margin-bottom: 0;
        background: transparent;
        border-bottom: none;
    }

    .header h2 {
        font-size: 28px;
        line-height: 1.3;
        font-weight: 500;
        text-align: center;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        padding: 0 20px;
        margin: 20px 0;
    }

    /* Hide header when messages are present */
    .messages-container:not(:empty) ~ .chat-section .header h2 {
        display: none;
    }

    .theme-toggle {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    /* Chat input area */
    .chat-section {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 16px 16px 16px;
        background: var(--bg-primary);
        border-top: none;
        z-index: 100;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .input-wrapper {
        padding: 0;
        max-width: 100%;
    }

    .input-area {
        padding: 4px 4px 4px 12px;
        gap: 8px;
        border-radius: 26px;
        background: var(--bg-secondary);
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
        border: 1px solid var(--border);
        max-width: 600px;
        margin: 0 auto;
    }

    .chat-input {
        font-size: 16px;
        padding: 12px 8px;
        min-height: 44px;
        max-height: 120px;
        line-height: 1.5;
        background: transparent;
        border: none;
        color: var(--text-primary);
    }

    .chat-input::placeholder {
        color: var(--text-tertiary);
        opacity: 0.7;
    }

    .chat-input:focus {
        outline: none;
    }

    .input-action {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 18px;
        transition: all 0.2s ease;
        background: transparent;
        border: none;
        color: var(--text-secondary);
    }

    .input-action:active {
        transform: scale(0.92);
        background: var(--bg-tertiary);
    }

    .input-right {
        gap: 6px;
        display: flex;
        align-items: center;
    }

    .more-btn {
        order: -1;
    }

    .send-btn {
        background: var(--primary);
        color: white;
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .send-btn:hover {
        background: var(--primary-dark);
    }

    .send-btn:active {
        transform: scale(0.9);
    }

    /* Hide some input actions to match ChatGPT's cleaner look */
    .transcribe-btn {
        display: none;
    }

    /* Keep voice assistant button visible on mobile */
    .voice-assistant-btn,
    .input-action.audio-btn.voice-assistant-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        align-items: center;
        justify-content: center;
    }

    .voice-assistant-btn .voice-bubble-icon {
        width: 20px;
        height: 20px;
        display: block !important;
    }

    /* Show only essential buttons */
    .voice-btn {
        color: var(--text-secondary);
    }

    /* Messages container */
    .messages-container {
        padding: 20px 16px 180px 16px;
        max-height: none;
        min-height: calc(100vh - 180px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
    }

    /* Center content when empty */
    .messages-container:empty {
        justify-content: center;
        align-items: center;
    }

    .message {
        padding: 16px 18px;
        max-width: 85%;
        margin-bottom: 16px;
        border-radius: 22px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
        border: 1px solid rgba(0, 0, 0, 0.05);
    }

    .message.user {
        margin-left: auto;
        background: var(--primary);
        color: white;
        border-bottom-right-radius: 6px;
    }

    .message.assistant {
        margin-right: auto;
        background: var(--bg-secondary);
        border-bottom-left-radius: 6px;
    }

    .message-content {
        font-size: 15px;
        line-height: 1.6;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .message-content p {
        margin-bottom: 12px;
    }

    .message-content code {
        font-size: 14px;
        padding: 2px 6px;
        border-radius: 4px;
    }

    .message-content pre {
        margin: 12px 0;
        border-radius: 8px;
        overflow-x: auto;
    }

    /* Action grid */
    .action-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 20px 16px 180px 16px;
        margin: 0 auto;
        max-width: 600px;
        align-items: stretch;
    }

    /* Show as grid when there are many items */
    .action-grid:has(:nth-child(5)) {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .action-btn {
        padding: 20px 18px;
        font-size: 14px;
        min-height: 80px;
        border-radius: 20px;
        display: flex;
        flex-direction: row;
        gap: 14px;
        align-items: center;
        justify-content: flex-start;
        text-align: left;
        transition: all 0.2s ease;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        border: 1px solid var(--border);
    }

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

    .action-btn i {
        font-size: 22px;
        margin-bottom: 0;
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .action-btn span {
        line-height: 1.4;
        flex: 1;
        font-weight: 400;
    }

    /* Modals */
    .settings-modal-overlay {
        padding: 0;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .settings-modal {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .settings-modal-header {
        padding: 16px 20px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }

    .settings-modal-header h2 {
        font-size: 20px;
        font-weight: 600;
    }

    .settings-modal-close {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }

    .settings-modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px 12px;
    }

    .settings-section {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 12px;
    }

    .settings-section-title {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 16px;
    }

    .settings-item {
        padding: 16px 12px;
        gap: 12px;
        min-height: 60px;
    }

    .settings-item-label {
        font-size: 15px;
        font-weight: 500;
    }

    .settings-item-description {
        font-size: 13px;
        line-height: 1.4;
    }

    .settings-toggle {
        width: 48px;
        height: 28px;
        flex-shrink: 0;
    }

    .settings-select {
        font-size: 15px;
        padding: 10px 12px;
        border-radius: 8px;
        min-height: 44px;
    }

    .settings-footer {
        padding: 16px 20px;
        gap: 10px;
        border-top: 1px solid var(--border);
        flex-shrink: 0;
    }

    .settings-button {
        padding: 14px 20px;
        font-size: 15px;
        flex: 1;
        border-radius: 12px;
        min-height: 48px;
        font-weight: 500;
    }

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

    /* Video/Podcast modals */
    .video-modal-overlay {
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .video-modal {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .video-modal-header {
        padding: 16px 20px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }

    .video-modal-header h2 {
        font-size: 20px;
        font-weight: 600;
    }

    .video-modal-close {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }

    .video-modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px 12px;
    }

    .form-group {
        margin-bottom: 20px;
    }

    .form-label {
        font-size: 15px;
        font-weight: 500;
        margin-bottom: 8px;
    }

    .form-input,
    .video-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 14px;
        border-radius: 12px;
        line-height: 1.5;
        min-height: 48px;
    }

    .video-textarea {
        min-height: 120px;
        resize: vertical;
    }

    .char-counter {
        font-size: 13px;
        margin-top: 6px;
    }

    /* More options menu */
    .more-options-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 20px 20px 0 0;
        grid-template-columns: repeat(2, 1fr);
        padding: 16px;
        gap: 10px;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
        z-index: 200;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .more-options-menu.active {
        transform: translateY(0);
    }

    .more-option-item {
        padding: 18px 14px;
        font-size: 13px;
        min-height: 85px;
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        align-items: center;
        justify-content: center;
        text-align: center;
        transition: all 0.2s ease;
    }

    .more-option-item:active {
        transform: scale(0.97);
    }

    .more-option-item i {
        font-size: 24px;
        margin-bottom: 4px;
    }

    .more-option-item span {
        line-height: 1.3;
    }

    /* Carousel */
    .carousel-container {
        padding: 20px 12px;
        margin-bottom: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 40vh;
    }

    .carousel {
        padding: 0;
        border-radius: 20px;
        overflow: hidden;
        max-width: 500px;
        margin: 0 auto;
    }

    .carousel-wrapper {
        touch-action: pan-x;
    }

    .carousel-slide {
        padding: 24px 20px;
    }

    .carousel-slide h2 {
        font-size: 24px;
        line-height: 1.3;
        margin-bottom: 12px;
    }

    .carousel-slide p {
        font-size: 15px;
        line-height: 1.5;
    }

    .carousel-nav {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .carousel-nav:active {
        transform: scale(0.9);
    }

    .slide-card {
        gap: 16px;
    }

    .slide-image {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .slide-content {
        flex: 1;
    }

    .slide-action {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 4px;
    }

    .slide-description {
        font-size: 14px;
        line-height: 1.4;
    }

    /* Voice modal */
    .voice-modal-content {
        width: 90%;
        padding: 32px 20px;
    }

    .voice-listening-text {
        font-size: 24px;
        margin-bottom: 24px;
    }

    .voice-controls {
        gap: 16px;
    }

    .voice-control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .voice-mic-btn {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }

    /* Edit profile modal adjustments */
    #editProfileModal .settings-modal {
        max-width: 100%;
    }

    #editProfileAvatar {
        width: 100px !important;
        height: 100px !important;
        font-size: 40px !important;
    }

    /* Sidebar content adjustments */
    .sidebar-nav {
        padding: 8px;
        gap: 4px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }

    .nav-item {
        padding: 12px 14px;
        font-size: 14px;
        border-radius: 10px;
        min-height: 44px;
        display: flex;
        align-items: center;
        gap: 12px;
        font-weight: 400;
        background: transparent;
    }

    .nav-item.active {
        background: var(--bg-tertiary);
    }

    .nav-item i {
        width: 20px;
        font-size: 18px;
        text-align: center;
    }

    /* Hide menu toggle on mobile sidebar */
    .nav-item:first-child {
        display: none;
    }

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

    .search-container {
        padding: 8px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }

    .search-input-wrapper {
        background: var(--bg-tertiary);
        border-radius: 8px;
        padding: 10px 12px;
    }

    .search-input {
        font-size: 14px;
        background: transparent;
        border: none;
        color: var(--text-primary);
        padding: 0 0 0 8px;
    }

    .search-icon {
        font-size: 16px;
        color: var(--text-secondary);
    }

    .sidebar-header {
        padding: 16px 12px 8px;
    }

    .sidebar-section {
        padding: 0;
    }

    .featured-section {
        padding: 8px;
        margin: 8px 0;
        flex-shrink: 0;
    }

    .featured-card {
        padding: 14px;
        border-radius: 10px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
    }

    .featured-card h4 {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 6px;
    }

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

    .featured-icon {
        width: 32px;
        height: 32px;
        font-size: 18px;
        margin-bottom: 8px;
    }

    .conversations-section {
        padding: 8px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .conversations-section h3 {
        font-size: 13px;
        font-weight: 500;
        padding: 8px 8px 6px;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .conversations-note {
        font-size: 13px;
        padding: 6px 8px 12px;
        color: var(--text-tertiary);
        line-height: 1.4;
    }

    .conversation-item {
        padding: 12px;
        font-size: 14px;
        border-radius: 8px;
        margin-bottom: 4px;
        min-height: 44px;
        transition: all 0.2s ease;
        background: transparent;
        display: flex;
        align-items: center;
        gap: 10px;
        cursor: pointer;
        border: none;
    }

    .conversation-item:hover {
        background: var(--bg-tertiary);
    }

    .conversation-item.active {
        background: var(--bg-tertiary);
    }

    .conversation-item:active {
        transform: scale(0.98);
        opacity: 0.8;
    }

    #conversationsList {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .new-chat-btn {
        padding: 12px 14px;
        font-size: 14px;
        border-radius: 10px;
        min-height: 44px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        display: flex;
        align-items: center;
        gap: 10px;
        font-weight: 400;
        transition: all 0.2s ease;
    }

    .new-chat-btn i {
        font-size: 18px;
    }

    .new-chat-btn:hover {
        background: var(--bg-primary);
    }

    .sidebar-footer {
        padding: 12px 8px;
        margin-top: auto;
        border-top: 1px solid var(--border);
        flex-shrink: 0;
        background: var(--bg-secondary);
    }

    .sign-in-btn {
        width: 100%;
        padding: 12px 14px;
        font-size: 14px;
        border-radius: 10px;
        min-height: 44px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        display: flex;
        align-items: center;
        gap: 10px;
        justify-content: center;
        font-weight: 500;
    }

    .sign-in-btn i {
        font-size: 18px;
    }

    .footer-user-btn {
        padding: 10px 12px;
        border-radius: 10px;
        min-height: 48px;
        background: transparent;
        border: none;
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        transition: all 0.2s ease;
    }

    .footer-user-btn:hover {
        background: var(--bg-tertiary);
    }

    .footer-btn-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-size: 14px;
        flex-shrink: 0;
    }

    .footer-btn-content {
        flex: 1;
        text-align: left;
        overflow: hidden;
    }

    .footer-btn-content span {
        font-size: 14px;
        font-weight: 500;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }

    .footer-btn-icon {
        font-size: 16px;
        color: var(--text-secondary);
    }

    /* Quick response dropdown */
    .quick-response-dropdown {
        position: fixed;
        bottom: 90px;
        left: 12px;
        right: 12px;
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        border-radius: 16px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
        background: var(--bg-primary);
        z-index: 150;
    }

    .quick-btn {
        width: 100%;
        padding: 14px 16px;
        font-size: 15px;
        border-radius: 12px;
        min-height: 48px;
        transition: all 0.2s ease;
    }

    .quick-btn:active {
        transform: scale(0.98);
    }

    /* Footer menu buttons */
    .footer-menu-buttons {
        display: none;
        flex-direction: column;
        gap: 4px;
        margin-top: 8px;
        padding: 8px 0;
        border-top: 1px solid var(--border);
    }

    .footer-menu-buttons.active {
        display: flex;
    }

    .footer-menu-btn {
        padding: 10px 12px;
        border-radius: 8px;
        background: transparent;
        border: none;
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 14px;
        color: var(--text-primary);
        transition: all 0.2s ease;
        cursor: pointer;
    }

    .footer-menu-btn:hover {
        background: var(--bg-tertiary);
    }

    .footer-menu-btn i {
        width: 20px;
        font-size: 16px;
        text-align: center;
    }

    .footer-menu-btn span {
        flex: 1;
        text-align: left;
    }

    .footer-signout-btn {
        color: var(--danger);
    }

    .footer-profile-section {
        display: none;
    }

    .sidebar-account {
        width: 100%;
    }

    /* Keyboard shortcut badges in sidebar */
    .keyboard-shortcut {
        font-size: 11px;
        padding: 2px 6px;
        border-radius: 4px;
        background: var(--bg-primary);
        color: var(--text-tertiary);
        margin-left: auto;
    }

    /* DOCX Preview Modal */
    #docxPreviewModal {
        padding: 0;
    }

    #docxPreviewModal > div {
        border-radius: 0;
        max-width: 100%;
    }

    #docxPreviewContent {
        padding: 20px 16px;
    }

    #docxPreviewContent > div {
        padding: 20px 16px;
    }
}

/* Small mobile devices - Enhanced */
@media screen and (max-width: 480px) {
    /* Typography adjustments */
    .app-header h1 {
        font-size: 18px;
        font-weight: 700;
    }

    .header-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .mobile-menu-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
        border-radius: 14px;
    }

    .theme-toggle {
        width: 44px;
        height: 44px;
    }

    .header {
        padding: 14px 16px;
    }

    .header h2 {
        font-size: 18px;
        font-weight: 600;
    }

    /* Action grid - Better mobile layout */
    .action-grid {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 16px 14px 200px 14px;
    }

    .action-btn {
        min-height: 80px;
        padding: 18px;
        flex-direction: row;
        align-items: center;
        gap: 16px;
    }
    
    .action-btn i {
        font-size: 28px;
    }
    
    .action-btn span {
        font-size: 16px;
        font-weight: 600;
    }

    /* More options menu */
    .more-options-menu {
        grid-template-columns: 1fr;
        padding: 14px;
        gap: 12px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .more-option-item {
        min-height: 80px;
        padding: 16px;
    }

    /* Settings */
    .settings-footer {
        flex-direction: column;
        padding: 14px 16px;
        gap: 12px;
    }

    .settings-button {
        width: 100%;
        min-height: 52px;
        font-size: 15px;
    }

    /* Input area - Enhanced touch targets */
    .input-action {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        font-size: 18px;
    }

    /* Keep voice assistant button visible on small mobile */
    .voice-assistant-btn,
    .input-action.audio-btn.voice-assistant-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        align-items: center;
        justify-content: center;
    }

    .voice-assistant-btn .voice-bubble-icon {
        width: 24px;
        height: 24px;
        display: block !important;
    }

    .input-area {
        padding: 10px 12px;
        gap: 10px;
    }

    .chat-input {
        font-size: 16px;
        padding: 12px 8px;
        min-height: 48px;
    }

    /* Carousel */
    .carousel-slide {
        padding: 24px 18px;
    }

    .carousel-slide h2 {
        font-size: 24px;
        margin-bottom: 12px;
    }

    .carousel-slide p {
        font-size: 15px;
        line-height: 1.6;
    }

    .slide-image {
        width: 60px;
        height: 60px;
        font-size: 28px;
        margin-bottom: 16px;
    }

    /* Messages */
    .message {
        padding: 14px 16px;
        max-width: 85%;
        margin-bottom: 12px;
    }

    .message-content {
        font-size: 15px;
        line-height: 1.6;
    }

    .messages-container {
        padding: 14px 12px 200px 12px;
    }

    /* Sidebar mobile */
    .sidebar {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 24px 24px 0 0;
        height: 85vh;
        max-height: 85vh;
    }

    .sidebar-account {
        width: 100%;
    }

    .footer-profile-section {
        display: none;
    }

    .nav-item {
        padding: 14px 16px;
        font-size: 15px;
    }

    .conversation-item {
        padding: 14px 16px;
        font-size: 15px;
    }
    
    /* Better scroll padding */
    .conversations-section {
        padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
    }
    
    /* Optimize sidebar grid for small screens */
    .sidebar-nav {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
        padding: 36px 14px 14px !important;
    }
    
    .sidebar .nav-item {
        min-height: 80px !important;
        padding: 12px 8px !important;
    }
    
    .sidebar .nav-item i {
        font-size: 24px !important;
    }
    
    .sidebar .nav-item span {
        font-size: 11px !important;
    }
}

/* Landscape orientation on mobile - Enhanced */
@media screen and (max-width: 896px) and (orientation: landscape) {
    /* Optimize vertical space */
    .messages-container {
        max-height: calc(100vh - 200px);
        padding-top: 10px;
        padding-bottom: 160px;
    }

    .carousel {
        padding: 12px 8px;
    }

    .carousel-slide {
        padding: 16px;
    }

    .carousel-slide h2 {
        font-size: 22px;
        margin-bottom: 8px;
    }
    
    .carousel-slide p {
        font-size: 14px;
    }

    .action-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 12px;
    }
    
    .action-btn {
        min-height: 70px;
        padding: 12px;
    }
    
    /* Compact sidebar for landscape */
    .sidebar {
        max-height: 85vh !important;
    }
    
    .sidebar-nav {
        padding: 24px 12px 12px !important;
    }
    
    .nav-item {
        padding: 10px !important;
        min-height: 70px !important;
    }
    
    /* Reduce logo size in landscape loading */
    .logo-base {
        width: 140px !important;
        height: 140px !important;
    }
    
    .loading-title {
        font-size: 24px;
    }
    
    .loading-subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets - Enhanced */
    button, 
    .action-btn,
    .more-option-item,
    .conversation-item,
    .header-btn,
    .input-action,
    .nav-item,
    .quick-btn,
    .settings-button {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 12px !important;
    }

    /* Remove hover effects on touch devices */
    .action-btn:hover,
    .more-option-item:hover,
    .conversation-item:hover,
    .nav-item:hover,
    .settings-button:hover,
    button:hover {
        transform: none;
        box-shadow: initial;
        background: initial;
    }

    /* Add active states with better feedback */
    .action-btn:active,
    .more-option-item:active,
    .conversation-item:active,
    .nav-item:active {
        transform: scale(0.97);
        opacity: 0.85;
        transition: transform 0.1s ease, opacity 0.1s ease;
    }

    button:active,
    .settings-button:active,
    .input-action:active {
        transform: scale(0.94);
        opacity: 0.9;
        transition: transform 0.1s ease, opacity 0.1s ease;
    }

    /* Better tap highlight with brand color */
    * {
        -webkit-tap-highlight-color: rgba(0, 132, 255, 0.15);
        -webkit-touch-callout: none;
    }

    /* Prevent text selection on interactive elements */
    button,
    .action-btn,
    .more-option-item,
    .nav-item,
    .conversation-item,
    .header-btn {
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
    }

    /* Allow text selection in messages and inputs */
    .message-content,
    .chat-input,
    .form-input,
    textarea,
    p,
    span,
    div[contenteditable="true"] {
        -webkit-user-select: text;
        -moz-user-select: text;
        user-select: text;
    }
    
    /* Optimize scrolling performance */
    .conversations-section,
    .messages-container,
    .sidebar {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scroll-behavior: smooth;
    }
    
    /* Better input focus */
    input:focus,
    textarea:focus {
        outline: 3px solid var(--primary);
        outline-offset: 2px;
        border-radius: var(--radius-md);
    }
}

/* iPad Pro and tablets - Enhanced */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .sidebar.expanded {
        width: 320px;
    }

    .action-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        padding: 20px;
    }
    
    .action-btn {
        min-height: 100px;
        padding: 20px;
    }
    
    /* Better use of tablet space */
    .container {
        max-width: 900px;
    }
    
    .message {
        max-width: 75%;
    }
    
    /* Optimize sidebar for tablets */
    .nav-item {
        padding: 12px 14px;
        font-size: 15px;
    }
    
    .conversation-item {
        padding: 12px 14px;
        font-size: 14px;
    }
}

    .settings-modal {
        max-width: 80%;
    }

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .app-header,
    .sidebar,
    .message,
    .action-btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Safe area for notched devices (iPhone X and later) */
@supports (padding: max(0px)) {
    .app-header {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .chat-section {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .sidebar {
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        padding-left: max(0px, env(safe-area-inset-left));
    }

    .header {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .messages-container {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .action-grid {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}

/* Performance optimizations for mobile */
@media screen and (max-width: 768px) {
    /* GPU acceleration for animations */
    .sidebar,
    .sidebar-overlay,
    .mobile-menu-btn,
    .action-btn,
    .more-option-item,
    .conversation-item,
    .message,
    .input-action {
        will-change: transform;
    }

    /* Optimize scrolling */
    .messages-container,
    .sidebar,
    .settings-modal-body,
    .video-modal-body,
    .more-options-menu {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

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

    /* Dark mode improvements for mobile */
    @media (prefers-color-scheme: dark) {
        .input-area {
            box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
        }

        .message {
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .action-btn,
        .more-option-item {
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }
    }

    /* Pull-to-refresh prevention */
    body {
        overscroll-behavior-y: contain;
    }

    /* Prevent double-tap zoom */
    button,
    .action-btn,
    .more-option-item,
    .input-action,
    .nav-item {
        touch-action: manipulation;
    }

    /* Prevent body scroll when sidebar is open */
    body.sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    /* Add subtle animation to overlay */
    .sidebar-overlay {
        animation: fadeIn 0.3s ease-out;
    }
    
    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
}

/* 🔥 CRITICAL MOBILE FIX - FORCE RESET LAYOUT (MUST BE LAST) */
@media (max-width: 1024px) {
    /* Prevent horizontal scroll on mobile */
    body {
        overflow-x: hidden;
    }

    /* ======================== */
    /* 📱 MOBILE REDESIGN - NEW ENHANCED SIDEBAR */
    /* ======================== */

    /* Show mobile menu button - repositioned */
    .mobile-menu-btn {
        display: flex !important;
        position: fixed;
        top: calc(16px + env(safe-area-inset-top));
        left: 16px;
        z-index: 999;
        width: 52px;
        height: 52px;
        border-radius: 16px;
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.75) 100%);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1.5px solid rgba(255, 255, 255, 0.15);
        box-shadow: 
            0 6px 20px rgba(0, 0, 0, 0.4),
            0 2px 8px rgba(0, 0, 0, 0.2);
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.light-theme .mobile-menu-btn {
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid rgba(0, 0, 0, 0.1);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    }

    .mobile-menu-btn:active {
        transform: scale(0.92);
        box-shadow: 
            0 3px 12px rgba(0, 0, 0, 0.3),
            0 1px 4px rgba(0, 0, 0, 0.15);
    }

    .mobile-menu-btn i {
        font-size: 22px;
        color: #ffffff;
        transition: transform 0.3s ease;
    }
    
    .sidebar.open ~ .layout-wrapper .mobile-menu-btn i {
        transform: rotate(90deg);
    }

    body.light-theme .mobile-menu-btn i {
        color: #1e293b;
    }

    /* Sidebar Overlay - Hidden by default */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0);
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        pointer-events: none;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
        visibility: visible;
        pointer-events: all;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    /* Mobile Sidebar - Bottom Sheet Style (Hidden by default) */
    .sidebar {
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100% !important;
        max-width: 100%;
        height: 80vh;
        max-height: 80vh;
        background: #1a1a2e;
        border-radius: 28px 28px 0 0;
        transform: translateY(100%);
        z-index: 1001;
        transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        overflow: hidden;
        display: flex !important;
        flex-direction: column;
        box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.6);
        visibility: hidden;
        pointer-events: none;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    body.light-theme .sidebar {
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    }

    .sidebar.open {
        transform: translateY(0);
        visibility: visible;
        pointer-events: all;
        animation: slideUpBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    
    @keyframes slideUpBounce {
        0% {
            transform: translateY(100%);
        }
        70% {
            transform: translateY(-10px);
        }
        100% {
            transform: translateY(0);
        }
    }

    /* Drag Handle for Bottom Sheet */
    .sidebar::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 48px;
        height: 5px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
        z-index: 10;
        animation: dragPulse 2.5s ease-in-out infinite;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    body.light-theme .sidebar::before {
        background: rgba(0, 0, 0, 0.25);
    }

    @keyframes dragPulse {
        0%, 100% {
            opacity: 1;
            transform: translateX(-50%) scaleX(1);
        }
        50% {
            opacity: 0.5;
            transform: translateX(-50%) scaleX(1.2);
        }
    }

    .sidebar.open::before {
        animation: none;
        opacity: 1;
    }

    /* Mobile Sidebar Header - New Design */
    .sidebar-nav {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        padding: 40px 16px 16px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.25) 100%);
        align-items: stretch !important;
    }

    body.light-theme .sidebar-nav {
        border-bottom-color: rgba(0, 0, 0, 0.1);
        background: rgba(0, 0, 0, 0.02);
    }

    .sidebar .nav-item {
        width: 100% !important;
        height: auto !important;
        padding: 14px 10px !important;
        flex-direction: column !important;
        gap: 6px !important;
        justify-content: center !important;
        align-items: center !important;
        border-radius: 14px !important;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.12);
        text-align: center;
        min-height: 85px;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    body.light-theme .sidebar .nav-item {
        background: rgba(0, 0, 0, 0.04);
        border-color: rgba(0, 0, 0, 0.12);
    }
    
    body.light-theme .sidebar .nav-item.active {
        background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
        border-color: #3b82f6;
        box-shadow: 
            0 4px 16px rgba(37, 99, 235, 0.4),
            0 0 0 2px rgba(59, 130, 246, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }

    .sidebar .nav-item i {
        font-size: 26px !important;
        width: auto !important;
        color: #60a5fa;
        margin-bottom: 2px;
        filter: drop-shadow(0 2px 4px rgba(96, 165, 250, 0.3));
    }

    body.light-theme .sidebar .nav-item i {
        color: #2563eb;
        filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.3));
    }

    .sidebar .nav-item span {
        display: block !important;
        font-size: 11.5px !important;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        letter-spacing: 0.3px;
        opacity: 0.95;
    }

    .sidebar .nav-item.active {
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
        border-color: #60a5fa;
        box-shadow: 
            0 4px 16px rgba(59, 130, 246, 0.4),
            0 0 0 2px rgba(96, 165, 250, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
        transform: translateY(-1px);
    }
    
    .sidebar .nav-item.active i {
        color: white !important;
        filter: drop-shadow(0 2px 6px rgba(255, 255, 255, 0.3));
    }
    
    .sidebar .nav-item.active span {
        opacity: 1;
        color: white;
    }

    .sidebar .nav-item:active {
        transform: scale(0.96);
        transition: transform 0.1s ease;
    }

    .sidebar .keyboard-shortcut {
        display: none !important;
    }

    /* Search Section - Enhanced */
    .sidebar .search-container {
        display: flex !important;
        padding: 14px 16px !important;
        background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.25) 100%);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    body.light-theme .sidebar .search-container {
        background: rgba(0, 0, 0, 0.03);
        border-bottom-color: rgba(0, 0, 0, 0.08);
    }

    .sidebar .search-input-wrapper {
        width: 100%;
        background: rgba(255, 255, 255, 0.09);
        border-radius: 14px;
        padding: 13px 16px;
        border: 1.5px solid rgba(255, 255, 255, 0.12);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        transition: all 0.25s ease;
    }
    
    .sidebar .search-input-wrapper:focus-within {
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(96, 165, 250, 0.5);
        box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
    }

    body.light-theme .sidebar .search-input-wrapper {
        background: rgba(255, 255, 255, 0.95);
        border-color: rgba(0, 0, 0, 0.12);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    body.light-theme .sidebar .search-input-wrapper:focus-within {
        background: white;
        border-color: rgba(37, 99, 235, 0.5);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }

    .sidebar .search-input {
        background: transparent;
        color: #ffffff;
        font-size: 15px;
    }

    body.light-theme .sidebar .search-input {
        color: #1e293b;
    }

    /* Quick Actions Section - NEW */
    .mobile-quick-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 16px;
        background: rgba(0, 0, 0, 0.15);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    body.light-theme .mobile-quick-actions {
        background: rgba(0, 0, 0, 0.02);
        border-bottom-color: rgba(0, 0, 0, 0.1);
    }

    .quick-action-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 12px 8px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.3s ease;
        color: #ffffff;
        font-size: 11px;
        text-align: center;
    }

    body.light-theme .quick-action-btn {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.1);
        color: #1e293b;
    }

    .quick-action-btn i {
        font-size: 20px;
        color: #60a5fa;
    }

    body.light-theme .quick-action-btn i {
        color: #2563eb;
    }

    .quick-action-btn:active {
        transform: scale(0.95);
    }

    /* Conversations Section - Scrollable */
    .sidebar .conversations-section {
        display: flex !important;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        overscroll-behavior: contain;
    }
    
    /* Custom scrollbar for conversations */
    .sidebar .conversations-section::-webkit-scrollbar {
        width: 4px;
    }
    
    .sidebar .conversations-section::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
    }

    .sidebar .conversations-section h3 {
        font-size: 13px;
        margin-bottom: 14px;
        color: rgba(255, 255, 255, 0.7);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.8px;
    }

    body.light-theme .sidebar .conversations-section h3 {
        color: rgba(0, 0, 0, 0.6);
    }
    
    .sidebar .conversation-item {
        padding: 14px 16px;
        margin-bottom: 6px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
        transition: all 0.2s ease;
    }
    
    .sidebar .conversation-item:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.1);
    }
    
    body.light-theme .sidebar .conversation-item {
        background: rgba(0, 0, 0, 0.03);
        border-color: rgba(0, 0, 0, 0.08);
    }

    /* Hide featured section on mobile */
    .sidebar .featured-section {
        display: none !important;
    }

    /* Footer - Compact Design */
    .sidebar .sidebar-footer {
        display: flex !important;
        padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        background: linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.35) 100%);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    body.light-theme .sidebar .sidebar-footer {
        border-top-color: rgba(0, 0, 0, 0.1);
        background: rgba(0, 0, 0, 0.04);
    }

    /* Footer menu buttons - Mobile support */
    .sidebar.open .footer-menu-buttons.expanded {
        padding: 14px 12px;
        max-height: 300px;
        opacity: 1;
        display: flex;
    }

    .sidebar .footer-menu-buttons {
        width: 100%;
    }

    .sidebar .footer-menu-btn {
        width: 100%;
        padding: 16px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.08);
        border: 1.5px solid rgba(255, 255, 255, 0.12);
        color: #ffffff;
        margin-bottom: 8px;
        font-size: 15px;
        font-weight: 600;
        transition: all 0.25s ease;
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .sidebar .footer-menu-btn:active {
        transform: scale(0.97);
        background: rgba(255, 255, 255, 0.12);
    }

    body.light-theme .sidebar .footer-menu-btn {
        background: rgba(255, 255, 255, 0.95);
        border-color: rgba(0, 0, 0, 0.12);
        color: #1e293b;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    }

    .sidebar .footer-user-btn {
        width: 100%;
        border-radius: 14px;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.08) 100%);
        border: 1.5px solid rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        transition: all 0.25s ease;
        padding: 14px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    body.light-theme .sidebar .footer-user-btn {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.1);
    }

    .sidebar .sign-in-btn {
        width: 100%;
        padding: 14px;
        border-radius: 12px;
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
        color: #ffffff;
        font-weight: 600;
        font-size: 15px;
        border: none;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    }

    /* 🚨 RESET ALL DESKTOP LAYOUT - FULL WIDTH */
    .main-container,
    .main-content,
    .app,
    main,
    .layout-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Adjust content for floating menu button and fixed input */
    .main-content {
        width: 100%;
        padding-left: 16px;
        padding-right: 16px;
        padding-top: 80px; /* Space for floating menu button */
        padding-bottom: 140px; /* Space for fixed chat input */
    }

    .main-container {
        min-height: 100vh;
        min-height: 100dvh;
        position: relative;
    }

    /* Header adjustments */
    .header {
        padding-top: 0 !important;
        margin-top: -12px;
    }

    .header-content h2 {
        font-size: 22px !important;
        padding-right: 16px;
    }

    /* Floating New Chat Button - Mobile Only */
    .mobile-fab {
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
        box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 998;
        border: none;
        transition: all 0.3s ease;
    }

    .mobile-fab:active {
        transform: scale(0.9);
    }

    .mobile-fab i {
        font-size: 24px;
        color: #ffffff;
    }

    /* Hide FAB when sidebar is open */
    .sidebar.open ~ .main-container .mobile-fab {
        opacity: 0;
        pointer-events: none;
    }

    /* Message bubbles - better mobile sizing */
    .message-bubble {
        max-width: 90% !important;
        font-size: 15px;
        padding: 14px 16px;
    }

    /* Input area - fixed at bottom on mobile */
    .chat-section {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        background: var(--bg-primary) !important;
        border-top: 1px solid var(--border);
        padding: 12px 16px !important;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
}

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

/* Responsive Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--space-md);
}

/* Responsive Grid */
.grid {
    display: grid;
    gap: var(--space-md);
}

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

@media (max-width: 768px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    .md\\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

/* Flexbox Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Display Utilities */
.hidden { display: none !important; }
.block { display: block !important; }
.inline-block { display: inline-block !important; }

@media (max-width: 768px) {
    .md\\:hidden { display: none !important; }
    .md\\:block { display: block !important; }
}

@media (min-width: 769px) {
    .md\\:flex { display: flex !important; }
}

/* Glass Morphism Effects */
.glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-strong {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Gradient Text */
.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-rainbow {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Smooth Hover Scale */
.hover-scale {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-scale-sm:hover {
    transform: scale(1.02);
}

.hover-scale-lg:hover {
    transform: scale(1.1);
}

/* Hover Lift Effect */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Pulse Animation */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Bounce Animation */
.bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(-5%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

/* Spin Animation */
.spin {
    animation: spin 1s linear infinite;
}

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

/* Fade In Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.fade-in-down {
    animation: fadeInDown 0.6s ease-out;
}

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

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

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

/* Slide Animations */
.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

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

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

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

/* Gradient Borders */
.gradient-border {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    padding: 2px;
    background: var(--primary-gradient);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
}

/* Shimmer Effect */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: shimmerMove 2s infinite;
}

@keyframes shimmerMove {
    to {
        left: 100%;
    }
}

/* Glow Effects */
.glow-primary {
    box-shadow: 0 0 20px rgba(0, 132, 255, 0.5);
}

.glow-success {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.glow-danger {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

/* Selection Styling */
::selection {
    background: var(--primary);
    color: white;
}

::-moz-selection {
    background: var(--primary);
    color: white;
}

/* Focus Visible for Accessibility */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Print Styles */
@media print {
    .sidebar,
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* ==================== ENHANCED MOBILE RESPONSIVE STYLES ==================== */

/* Mobile First - Base Styles */
@media (max-width: 480px) {
    :root {
        /* Adjust spacing for small screens */
        --space-md: 0.75rem;
        --space-lg: 1rem;
        --space-xl: 1.5rem;
    }
    
    /* Typography adjustments */
    body {
        font-size: 14px;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
    
    /* Loading screen */
    .loading-title {
        font-size: 28px;
    }
    
    .loading-subtitle {
        font-size: 16px;
    }
    
    .loading-progress {
        width: 200px;
    }
}

/* Tablet Styles */
@media (min-width: 481px) and (max-width: 768px) {
    :root {
        --space-md: 0.875rem;
        --space-lg: 1.25rem;
    }
    
    body {
        font-size: 15px;
    }
    
    .loading-title {
        font-size: 32px;
    }
}

/* Desktop Small */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar.expanded {
        width: 240px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase all interactive elements */
    button,
    input[type="button"],
    input[type="submit"],
    .btn,
    .action-btn,
    .nav-item,
    .conversation-item,
    .input-action,
    .header-btn {
        min-height: 44px !important;
        min-width: 44px !important;
        cursor: pointer;
    }
    
    /* Better tap targets */
    .nav-item {
        padding: 14px !important;
    }
    
    /* Remove all hover effects */
    *:hover {
        transition: none !important;
    }
    
    /* Add touch feedback */
    button:active,
    .btn:active,
    .action-btn:active,
    .nav-item:active {
        transform: scale(0.96);
        opacity: 0.8;
        transition: transform 0.1s ease, opacity 0.1s ease;
    }
    
    /* Better tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(0, 132, 255, 0.2);
        -webkit-touch-callout: none;
    }
    
    /* Prevent text selection on UI elements */
    button,
    .nav-item,
    .action-btn,
    .header-btn {
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection where needed */
    p,
    span,
    .message-content,
    input,
    textarea {
        -webkit-user-select: text;
        -moz-user-select: text;
        user-select: text;
    }
    
    /* Optimize scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile Landscape */
@media (max-width: 896px) and (orientation: landscape) {
    .layout-wrapper {
        height: 100vh;
    }
    
    .sidebar.open {
        max-height: 90vh;
    }
    
    /* Reduce vertical spacing */
    .nav-item {
        padding: 8px 12px !important;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper borders */
    .sidebar,
    .nav-item,
    .action-btn {
        border-width: 0.5px;
    }
    
    /* Better shadow rendering */
    .logo-base,
    .nav-item.active {
        box-shadow: 
            0 0.5px 1px rgba(0, 0, 0, 0.1),
            0 1px 2px rgba(0, 0, 0, 0.1),
            0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* Accessibility - Reduced Motion */
@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;
    }
    
    .pulse,
    .bounce,
    .spin {
        animation: none !important;
    }
}

/* Dark Mode Preference */
@media (prefers-color-scheme: dark) {
    body:not(.light-theme):not(.curious-theme) {
        --bg-primary: #1a1a1a;
        --text-primary: #f5f5f5;
    }
}

/* Mobile Navigation Enhancements */
@media (max-width: 768px) {
    /* Prevent zoom on input focus (iOS) */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }
    
    /* Full viewport height fix for mobile browsers */
    .layout-wrapper,
    .main-container {
        min-height: -webkit-fill-available;
    }
    
    /* Safe area padding */
    .sidebar {
        padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
    }
    
    /* Better scroll containers */
    .conversations-section,
    .messages-container {
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Optimize animations for mobile */
    .nav-item,
    .action-btn,
    .conversation-item {
        transition: transform 0.2s ease, background 0.2s ease;
    }
    
    /* Better focus states for mobile */
    input:focus,
    textarea:focus,
    button:focus {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }
    
    /* Sticky elements support */
    .header,
    .chat-input-container {
        position: -webkit-sticky;
        position: sticky;
    }
}

/* PWA Support */
@media all and (display-mode: standalone) {
    /* Add status bar spacing */
    body {
        padding-top: calc(env(safe-area-inset-top) + 20px);
    }
    
    /* Adjust header for PWA */
    .header {
        padding-top: env(safe-area-inset-top);
    }
}

/* Foldable Devices */
@media (horizontal-viewport-segments: 2) {
    .layout-wrapper {
        display: grid;
        grid-template-columns: env(viewport-segment-width 0 0) env(viewport-segment-width 1 0);
    }
    
    .sidebar {
        grid-column: 1;
    }
    
    .main-container {
        grid-column: 2;
    }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    .container {
        max-width: 1600px;
    }
    
    .sidebar.expanded {
        width: 300px;
    }
    
    :root {
        --space-xl: 3rem;
        --space-2xl: 4rem;
    }
}

/* ==================== MOBILE PERFORMANCE OPTIMIZATIONS ==================== */

/* GPU Acceleration for Smooth Animations */
.nav-item,
.action-btn,
.sidebar,
.conversation-item,
.message,
.loading-screen {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Optimize Repaints */
@media (max-width: 768px) {
    .sidebar,
    .sidebar-overlay {
        contain: layout style paint;
    }
    
    .messages-container,
    .conversations-section {
        contain: layout paint;
    }
    
    /* Reduce animation complexity on mobile */
    .logo-base::after,
    .shimmer::after {
        animation-duration: 4s;
    }
}

/* ==================== MOBILE SPECIFIC FIXES ==================== */

/* Fix iOS viewport issues */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
    
    .layout-wrapper {
        min-height: -webkit-fill-available;
    }
}

/* Fix Android Chrome address bar */
@media screen and (max-width: 768px) {
    @supports (height: 100dvh) {
        .layout-wrapper {
            height: 100dvh;
        }
    }
}

/* Prevent elastic scrolling on mobile */
@media (max-width: 768px) {
    body {
        position: fixed;
        overflow: hidden;
        width: 100%;
        height: 100%;
    }
    
    body.sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    .layout-wrapper {
        overflow: auto;
        height: 100%;
        -webkit-overflow-scrolling: touch;
    }
}

/* Better loading states on mobile */
@media (max-width: 768px) {
    .loading-screen {
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
    }
    
    /* Optimize memory usage */
    img,
    video {
        max-width: 100%;
        height: auto;
    }
}

/* ==================== MOBILE BUTTON ENHANCEMENTS ==================== */

@media (max-width: 768px) {
    /* Floating Action Button improvements */
    .mobile-fab {
        position: fixed;
        right: 20px;
        bottom: calc(20px + env(safe-area-inset-bottom));
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary-gradient);
        box-shadow: 
            0 6px 20px rgba(0, 132, 255, 0.4),
            0 2px 8px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: var(--z-fixed);
        border: none;
        cursor: pointer;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    box-shadow 0.3s ease;
    }
    
    .mobile-fab:active {
        transform: scale(0.92);
        box-shadow: 
            0 3px 12px rgba(0, 132, 255, 0.4),
            0 1px 4px rgba(0, 0, 0, 0.2);
    }
    
    .mobile-fab i {
        font-size: 24px;
        color: white;
    }
    
    /* Ripple effect on tap */
    .mobile-fab::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0);
        opacity: 0;
        transition: transform 0.3s, opacity 0.3s;
    }
    
    .mobile-fab:active::before {
        transform: scale(1);
        opacity: 1;
        transition: none;
    }
}

/* ==================== MOBILE MODAL IMPROVEMENTS ==================== */

@media (max-width: 768px) {
    /* Full screen modals on mobile */
    .modal,
    .settings-modal,
    .profile-modal {
        padding: 0 !important;
    }
    
    .modal-content,
    .settings-content {
        margin: 0;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        overflow-y: auto;
    }
    
    /* Better close buttons */
    .close-btn,
    .modal-close {
        position: sticky;
        top: 0;
        right: 0;
        z-index: 10;
        background: var(--bg-primary);
        width: 44px;
        height: 44px;
        border-radius: 50%;
        margin: 12px;
    }
}

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

@media (max-width: 768px) {
    /* Adjust layout when keyboard is visible */
    @supports (height: 100dvh) {
        .chat-input-container {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            padding-bottom: env(safe-area-inset-bottom);
            background: var(--bg-primary);
            z-index: var(--z-fixed);
        }
    }
    
    /* Prevent zoom on input focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

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

@media (max-width: 768px) {
    /* Larger focus indicators */
    *:focus-visible {
        outline: 3px solid var(--primary);
        outline-offset: 3px;
    }
    
    /* Better contrast for text */
    body.light-theme {
        --text-primary: #0f172a;
        --text-secondary: #334155;
    }
    
    /* Skip to main content link */
    .skip-link {
        position: absolute;
        top: -40px;
        left: 0;
        background: var(--primary);
        color: white;
        padding: 12px 20px;
        text-decoration: none;
        z-index: var(--z-modal);
        border-radius: 0 0 8px 0;
    }
    
    .skip-link:focus {
        top: 0;
    }
}

/* ==================== MOBILE ERROR STATES ==================== */

@media (max-width: 768px) {
    .error-message,
    .warning-message,
    .success-message {
        position: fixed;
        bottom: calc(20px + env(safe-area-inset-bottom));
        left: 20px;
        right: 20px;
        padding: 16px;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        z-index: var(--z-tooltip);
        animation: slideInUp 0.3s ease-out;
    }
}

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

/* ==================== MOBILE LOADING STATES ==================== */

@media (max-width: 768px) {
    .skeleton,
    .loading-skeleton {
        background: linear-gradient(
            90deg,
            var(--bg-secondary) 0%,
            var(--bg-tertiary) 50%,
            var(--bg-secondary) 100%
        );
        background-size: 200% 100%;
        animation: skeletonLoading 1.5s ease-in-out infinite;
        border-radius: var(--radius-md);
    }
}

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

/* ==================== MOBILE PRINT FIXES ==================== */

@media print {
    @page {
        margin: 1cm;
    }
    
    .mobile-fab,
    .mobile-menu-btn,
    .sidebar-overlay,
    .no-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
}
    /* Override chat-started positioning for mobile */
    .main-content.chat-started .chat-section,
    .chat-container.chat-started .chat-section {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        padding: 12px 16px !important;
    }

    .chat-input {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 48px;
        padding: 12px 16px;
    }

    /* Add bottom padding to messages container for fixed input */
    .messages-container,
    #messagesContainer {
        padding-bottom: 140px !important;
    }

    .main-content.chat-started #messagesContainer,
    .chat-container.chat-started #messagesContainer {
        padding-bottom: 140px !important;
    }

    .input-action {
        width: 44px !important;
        height: 44px !important;
        font-size: 20px;
    }

    .send-btn {
        width: 48px !important;
        height: 48px !important;
    }

    /* Action grid - better mobile layout */
    .action-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }

    .action-btn {
        padding: 16px !important;
        font-size: 14px;
        min-height: 72px;
    }

    .action-btn i {
        font-size: 24px !important;
    }

    /* Better touch feedback */
    .nav-item,
    .quick-action-btn,
    .action-btn,
    .mobile-menu-btn,
    .mobile-fab {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
    }

    /* Enhanced smooth scrolling for mobile */
    .conversations-section,
    .messages-container,
    #messagesContainer {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior: contain;
        /* Ensure proper height calculation on mobile */
        height: 100%;
        position: relative;
    }

    /* Fix for iOS Safari scroll issues */
    #messagesContainer {
        min-height: 0;
        flex: 1;
    }

    /* Safe area support for notched devices */
    .mobile-menu-btn {
        top: max(16px, env(safe-area-inset-top));
        left: max(16px, env(safe-area-inset-left));
    }

    .mobile-fab {
        bottom: max(24px, calc(env(safe-area-inset-bottom) + 24px));
        right: max(24px, env(safe-area-inset-right));
    }

    .main-content {
        padding-bottom: max(140px, calc(env(safe-area-inset-bottom) + 140px));
    }

    /* Ensure chat input respects safe area on notched devices */
    .chat-section {
        padding-bottom: max(12px, calc(env(safe-area-inset-bottom) + 12px)) !important;
    }

    /* Mobile Animations & Polish */
    @keyframes slideUpFade {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @keyframes pulseRing {
        0%, 100% {
            box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
        }
        50% {
            box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
        }
    }

    .mobile-fab {
        animation: pulseRing 2s ease-in-out infinite;
    }

    .sidebar.open .nav-item,
    .sidebar.open .quick-action-btn {
        animation: slideUpFade 0.3s ease forwards;
    }

    .sidebar.open .nav-item:nth-child(1) { animation-delay: 0.05s; }
    .sidebar.open .nav-item:nth-child(2) { animation-delay: 0.1s; }
    .sidebar.open .nav-item:nth-child(3) { animation-delay: 0.15s; }
    .sidebar.open .nav-item:nth-child(4) { animation-delay: 0.2s; }

    .sidebar.open .quick-action-btn:nth-child(1) { animation-delay: 0.1s; }
    .sidebar.open .quick-action-btn:nth-child(2) { animation-delay: 0.15s; }
    .sidebar.open .quick-action-btn:nth-child(3) { animation-delay: 0.2s; }
    .sidebar.open .quick-action-btn:nth-child(4) { animation-delay: 0.25s; }
    .sidebar.open .quick-action-btn:nth-child(5) { animation-delay: 0.3s; }
    .sidebar.open .quick-action-btn:nth-child(6) { animation-delay: 0.35s; }

    /* Ripple effect on touch */
    .nav-item::after,
    .quick-action-btn::after,
    .mobile-fab::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        transform: translate(-50%, -50%);
        transition: width 0.6s, height 0.6s, opacity 0.6s;
        opacity: 0;
        pointer-events: none;
    }

    .nav-item:active::after,
    .quick-action-btn:active::after,
    .mobile-fab:active::after {
        width: 100px;
        height: 100px;
        opacity: 1;
        transition: 0s;
    }

    /* Improve text readability on mobile */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }

    /* Prevent text size adjustment on orientation change */
    html {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    /* Accessibility improvements */
    .nav-item:focus,
    .quick-action-btn:focus,
    .mobile-fab:focus,
    .mobile-menu-btn:focus {
        outline: 2px solid #3b82f6;
        outline-offset: 2px;
    }

    /* Dark mode overlay adjustments */
    body.dark-theme .sidebar-overlay.active {
        background: rgba(0, 0, 0, 0.75);
    }

    body.light-theme .sidebar-overlay.active {
        background: rgba(0, 0, 0, 0.5);
    }

    /* Loading state for mobile */
    .sidebar.loading .nav-item,
    .sidebar.loading .quick-action-btn {
        pointer-events: none;
        opacity: 0.6;
    }

    /* Empty state message styling */
    .conversations-note {
        font-size: 13px;
        opacity: 0.7;
        text-align: center;
        padding: 8px 0;
    }

    /* Conversation item hover on mobile */
    #conversationsList > * {
        padding: 12px;
        border-radius: 8px;
        margin-bottom: 8px;
        cursor: pointer;
        transition: background 0.2s ease;
    }

    #conversationsList > *:active {
        background: rgba(255, 255, 255, 0.1);
    }

    body.light-theme #conversationsList > *:active {
        background: rgba(0, 0, 0, 0.05);
    }

/* ======================== */
/* 📱 MOBILE - LANDSCAPE MODE ADJUSTMENTS */
/* ======================== */
@media (max-width: 1024px) and (orientation: landscape) {
    .sidebar {
        height: 90vh;
        max-height: 90vh;
    }

    .mobile-quick-actions {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
        padding: 12px 16px;
    }

    .sidebar-nav {
        padding: 24px 16px 12px !important;
    }

    .conversations-section {
        max-height: 40vh;
    }
}

/* ======================== */
/* 📱 SMALL MOBILE DEVICES (< 375px) */
/* ======================== */
@media (max-width: 374px) {
    .mobile-menu-btn {
        width: 44px;
        height: 44px;
    }

    .mobile-fab {
        width: 52px;
        height: 52px;
        bottom: 20px;
        right: 20px;
    }

    .mobile-fab i {
        font-size: 22px;
    }

    .sidebar-nav {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .nav-item {
        min-height: 72px;
        padding: 12px 6px !important;
    }

    .nav-item i {
        font-size: 20px !important;
    }

    .nav-item span {
        font-size: 11px !important;
    }

    .mobile-quick-actions {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .quick-action-btn {
        padding: 10px 6px;
        font-size: 10px;
    }

    .quick-action-btn i {
        font-size: 18px;
    }

    .header-content h2 {
        font-size: 20px !important;
    }
}

