/**
 * Smart Agent - Premium Dark Theme V2
 * Production-Ready with Enhanced UX & Animations
 */

:root {
    /* Color Palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #0f0f16;
    --bg-tertiary: #161620;
    --bg-elevated: #1c1c28;
    --bg-hover: #252535;
    --bg-glass: rgba(22, 22, 32, 0.85);

    /* Accent Colors */
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-gradient-hover: linear-gradient(135deg, #7a8fed 0%, #8a5db5 100%);
    --accent-glow: rgba(102, 126, 234, 0.25);
    --accent-glow-strong: rgba(102, 126, 234, 0.4);

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #b0b0c0;
    --text-tertiary: #6b6b80;
    --text-muted: #4a4a5a;

    /* Status Colors */
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.2);
    --error: #ef4444;
    --error-glow: rgba(239, 68, 68, 0.2);
    --info: #3b82f6;
    --info-glow: rgba(59, 130, 246, 0.2);

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(102, 126, 234, 0.3);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.15);
    --shadow-glow-strong: 0 0 60px rgba(102, 126, 234, 0.25);

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 64px;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    /* Allow the browser to manage scrolling to avoid inner clipping and double scrollbars */
    overflow: auto;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Selection */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* App Container */
.app-container {
    display: flex;
    height: 100%;
    /* Fallback */
    height: 100dvh;
    /* Dynamic Full Height */
    width: 100%;
    overflow: hidden;
    background: var(--bg-primary);
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-base), width var(--transition-base), min-width var(--transition-base);
    z-index: 100;
    position: relative;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: -1px;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--accent-primary), transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar:hover::after {
    opacity: 0.3;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    width: 0;
    min-width: 0;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(180deg, rgba(102, 126, 234, 0.05) 0%, transparent 100%);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    position: relative;
    overflow: hidden;
}

.logo-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
}

.logo-icon svg {
    width: 20px;
    height: 20px;
    color: white;
    position: relative;
    z-index: 1;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    letter-spacing: -0.02em;
}

.new-chat-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.new-chat-btn:hover {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.new-chat-btn svg {
    width: 18px;
    height: 18px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.clear-history-btn {
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    opacity: 0;
}

.section-title:hover .clear-history-btn {
    opacity: 1;
}

.clear-history-btn:hover {
    color: var(--error);
    background: var(--error-glow);
}

.clear-history-btn svg {
    width: 14px;
    height: 14px;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-history-item {
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.chat-history-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: height var(--transition-fast);
}

.chat-history-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.chat-history-item:hover::before {
    height: 60%;
}

.chat-history-item.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.15) 0%, transparent 100%);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.chat-history-item.active::before {
    height: 60%;
}

.chat-history-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
}

.chat-history-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.chat-history-item .delete-chat {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.chat-history-item:hover .delete-chat {
    opacity: 1;
}

.chat-history-item .delete-chat:hover {
    color: var(--error);
    background: var(--error-glow);
}

.chat-history-item .delete-chat svg {
    width: 12px;
    height: 12px;
    opacity: 1;
}

.no-chats-message {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 16px;
    text-align: center;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.2) 0%, transparent 100%);
}

.provider-selector {
    margin-bottom: 16px;
}

.provider-selector label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.provider-selector label svg {
    width: 12px;
    height: 12px;
}

.provider-selector select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    cursor: pointer;
    outline: none;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b80' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.provider-selector select:hover {
    border-color: var(--border-hover);
}

.provider-selector select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.4;
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.status-dot.connected {
    background: var(--success);
}

.status-dot.disconnected {
    background: var(--error);
}

.status-dot.disconnected::after {
    animation: none;
}

.keyboard-shortcuts-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

.keyboard-shortcuts-hint kbd {
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.65rem;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Allow children to scroll */
    position: relative;
    background: var(--bg-primary);
}

.main-header {
    height: var(--header-height);
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-secondary);
    position: relative;
    z-index: 10;
}

.main-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    opacity: 0.3;
}

.menu-toggle {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.menu-toggle svg {
    width: 22px;
    height: 22px;
}

.header-title {
    flex: 1;
}

.header-title h1 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-title .subtitle {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    position: relative;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn.preview-toggle {
    width: auto;
    padding: 0 14px;
    gap: 8px;
}

.preview-badge {
    font-size: 0.75rem;
    font-weight: 500;
}

.icon-btn.preview-toggle.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

/* ==================== CHAT AREA ==================== */
.chat-wrapper {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    overflow: visible;
    height: 100%;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 40px 20px 60px;
    text-align: center;
    animation: fadeInUp 0.6s ease;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    -webkit-overflow-scrolling: touch;
}

.welcome-animation {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.welcome-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float-orb 20s ease-in-out infinite;
}

.welcome-orb:nth-child(1) {
    width: 400px;
    height: 400px;
    background: var(--accent-primary);
    top: -200px;
    left: -100px;
    animation-delay: 0s;
}

.welcome-orb:nth-child(2) {
    width: 300px;
    height: 300px;
    background: var(--accent-secondary);
    bottom: -150px;
    right: -100px;
    animation-delay: -7s;
}

.welcome-orb:nth-child(3) {
    width: 200px;
    height: 200px;
    background: var(--info);
    top: 50%;
    left: 50%;
    animation-delay: -14s;
}

@keyframes float-orb {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(50px, -50px) scale(1.1);
    }

    66% {
        transform: translate(-30px, 30px) scale(0.9);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-screen.hidden {
    display: none;
}

.welcome-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    animation: float 4s ease-in-out infinite;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.welcome-icon svg {
    width: 100%;
    height: 100%;
}

.welcome-screen h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
}

.welcome-screen>p {
    color: var(--text-secondary);
    max-width: 480px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    z-index: 1;
    padding: 0 16px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 560px;
    width: 100%;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    padding: 0 16px;
}

.quick-action {
    padding: 12px 14px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    text-align: left;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.quick-action::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.quick-action:hover {
    border-color: var(--border-accent);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.quick-action:hover::before {
    opacity: 0.05;
}

.action-icon-wrapper {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.action-icon-wrapper svg {
    width: 16px;
    height: 16px;
    color: white;
}

.action-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.action-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-desc {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    position: relative;
    z-index: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.welcome-features {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 1;
    padding: 0 16px;
}

.feature-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.feature-tag svg {
    width: 14px;
    height: 14px;
    color: var(--success);
}

/* ==================== MESSAGES ==================== */
.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
    height: 100%;
    min-height: 0;
}

.messages:empty {
    display: none;
}

.message {
    display: flex;
    gap: 16px;
    animation: slideIn 0.4s ease;
    max-width: 100%;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    position: relative;
}

.message.assistant .message-avatar {
    background: var(--accent-gradient);
    box-shadow: var(--shadow-glow);
}

.message.assistant .message-avatar::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
}

.message.user .message-avatar {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
}

.message-content {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    line-height: 1.7;
    position: relative;
}

.message.assistant .message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-top-left-radius: var(--radius-sm);
}

.message.user .message-content {
    background: var(--accent-gradient);
    color: white;
    border-top-right-radius: var(--radius-sm);
}

/* Message Content Typography */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 20px 0 12px;
    font-weight: 600;
    line-height: 1.4;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
    margin-top: 0;
}

.message-content h1 {
    font-size: 1.4rem;
}

.message-content h2 {
    font-size: 1.2rem;
}

.message-content h3 {
    font-size: 1.1rem;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin-bottom: 6px;
}

.message-content li:last-child {
    margin-bottom: 0;
}

.message-content a {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
}

.message-content a:hover {
    border-color: var(--accent-primary);
}

.message.user .message-content a {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

/* Code Blocks */
.message-content pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 16px 0;
    overflow: hidden;
}

.message-content pre code {
    display: block;
    padding: 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
}

.message-content code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 7px;
    border-radius: var(--radius-sm);
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    white-space: normal;
    /* Prevent inheritance from pre */
    font-family: var(--font-sans);
    /* Ensure sans-serif font */
}

.code-header .language {
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.code-header .actions {
    display: flex;
    gap: 6px;
}

.code-header button {
    padding: 5px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
}

.code-header button:hover {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

.code-header button.copied {
    background: var(--success);
    border-color: transparent;
    color: white;
}

/* Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.85rem;
}

.message-content th,
.message-content td {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    text-align: left;
}

/* ==================== RESPONSIVE LAYOUT ==================== */
/* Tablet and below: stack preview under chat and make header smaller */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
        --header-height: 56px;
    }

    .chat-wrapper {
        flex-direction: column;
    }

    .chat-container {
        order: 1;
        width: 100%;
        min-height: 0;
    }

    .preview-panel {
        order: 2;
        width: 100%;
        height: 320px;
        min-height: 220px;
        border-left: none;
        border-top: 1px solid var(--border-color);
        background: var(--bg-secondary);
    }

    .preview-panel .preview-content {
        height: calc(100% - 56px);
    }

    .menu-toggle {
        display: flex;
    }
}

/* Mobile: off-canvas sidebar and overlay, full-width content */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
        --header-height: 56px;
    }

    /* Sidebar becomes off-canvas */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        width: var(--sidebar-width);
        min-width: 0;
        z-index: 220;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    }

    /* When opened, `app.js` adds `open` to the sidebar */
    .sidebar.open {
        transform: translateX(0);
    }

    /* Prevent desktop collapsed behavior from shrinking width to 0 on mobile */
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        min-width: 0;
    }

    /* Overlay behind the sidebar */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 200;
        opacity: 0;
        transition: opacity var(--transition-base);
        pointer-events: none;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Header adjustments */
    .main-header {
        padding: 0 12px;
    }

    .menu-toggle {
        display: flex;
    }

    .header-title h1 {
        font-size: 1rem;
    }

    /* Input area should remain sticky at bottom */
    .input-area {
        position: sticky;
        bottom: 0;
        z-index: 30;
        background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.2));
    }

    /* Make messages area scroll properly with available height */
    .messages {
        padding: 16px;
        gap: 14px;
        max-height: calc(100vh - var(--header-height) - 220px);
        /* account for preview/input */
        overflow-y: auto;
    }

    /* Preview panel: make it collapsible full-width when opened */
    .preview-panel {
        height: 0;
        overflow: hidden;
        transition: height var(--transition-base);
    }

    .preview-panel.open {
        height: 50vh;
    }
}

/* Small phones: tighten spacing and font sizes */
@media (max-width: 420px) {
    .quick-actions {
        grid-template-columns: 1fr;
    }

    .welcome-screen {
        padding: 24px 12px 80px;
    }

    .logo-text {
        display: none;
    }

    .provider-selector select {
        padding: 8px 12px;
    }
}

.message-content th {
    background: var(--bg-elevated);
    font-weight: 600;
}

.message-content blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ==================== PREVIEW PANEL ==================== */
.preview-panel {
    width: 0;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--transition-base);
}

.preview-panel.open {
    width: 50%;
    min-width: 400px;
}

.preview-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
}

.preview-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.preview-title svg {
    width: 16px;
    height: 16px;
}

.preview-actions {
    display: flex;
    gap: 6px;
}

.preview-btn {
    width: 30px;
    height: 30px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.preview-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.preview-btn.close-btn:hover {
    background: var(--error-glow);
    color: var(--error);
    border-color: transparent;
}

.preview-btn svg {
    width: 16px;
    height: 16px;
}

.preview-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px;
    background: var(--bg-primary);
}

.preview-placeholder.hidden {
    display: none;
}

.preview-placeholder svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 20px;
    opacity: 0.5;
}

.preview-placeholder h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.preview-placeholder p {
    color: var(--text-tertiary);
    max-width: 280px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.preview-placeholder .hint {
    margin-top: 20px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--text-muted);
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* ==================== INPUT AREA ==================== */
.input-area {
    padding: 16px 24px 24px;
    background: linear-gradient(to top, var(--bg-primary) 0%, var(--bg-primary) 60%, transparent 100%);
    position: relative;
}

.input-container {
    max-width: 850px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 8px;
    transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-glow);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.5;
    padding: 10px 16px;
    resize: none;
    max-height: 180px;
    outline: none;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    gap: 6px;
    padding-bottom: 2px;
}

.attach-btn,
.send-btn {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.attach-btn {
    background: transparent;
    color: var(--text-muted);
}

.attach-btn:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.send-btn {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.send-btn:active {
    transform: scale(0.98);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.attach-btn svg,
.send-btn svg {
    width: 20px;
    height: 20px;
}

.input-hint {
    text-align: center;
    margin-top: 10px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.input-hint kbd {
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    margin: 0 2px;
}

/* ==================== LOADING ==================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.spinner-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    position: absolute;
}

.loading-spinner {
    position: relative;
    width: 60px;
    height: 60px;
}

.spinner-ring:nth-child(1) {
    border: 3px solid transparent;
    border-top-color: var(--accent-primary);
    animation: spin 1s linear infinite;
}

.spinner-ring:nth-child(2) {
    border: 3px solid transparent;
    border-right-color: var(--accent-secondary);
    animation: spin 1.5s linear infinite reverse;
    width: 38px;
    height: 38px;
    top: 5px;
    left: 5px;
}

.spinner-ring:nth-child(3) {
    border: 3px solid transparent;
    border-bottom-color: var(--info);
    animation: spin 2s linear infinite;
    width: 28px;
    height: 28px;
    top: 10px;
    left: 10px;
}

.loading-text {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1001;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.4s ease;
    max-width: 380px;
    pointer-events: auto;
    backdrop-filter: blur(12px);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 3px solid var(--success);
    background: linear-gradient(90deg, var(--success-glow) 0%, var(--bg-elevated) 30%);
}

.toast.error {
    border-left: 3px solid var(--error);
    background: linear-gradient(90deg, var(--error-glow) 0%, var(--bg-elevated) 30%);
}

.toast.info {
    border-left: 3px solid var(--info);
    background: linear-gradient(90deg, var(--info-glow) 0%, var(--bg-elevated) 30%);
}

.toast.warning {
    border-left: 3px solid var(--warning);
    background: linear-gradient(90deg, var(--warning-glow) 0%, var(--bg-elevated) 30%);
}

/* ==================== SHORTCUTS MODAL ==================== */
.shortcuts-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1002;
}

.shortcuts-modal.open {
    display: flex;
}

.shortcuts-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
}

.shortcuts-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.shortcuts-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.close-shortcuts {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.close-shortcuts:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.close-shortcuts svg {
    width: 18px;
    height: 18px;
}

.shortcuts-list {
    padding: 16px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.shortcut-keys {
    display: flex;
    gap: 6px;
}

.shortcut-keys kbd {
    padding: 4px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-primary);
    min-width: 28px;
    text-align: center;
}

.shortcut-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ==================== RESPONSIVE ==================== */

/* Large Tablets & Small Laptops */
@media (max-width: 1280px) {
    .preview-panel.open {
        width: 48%;
        min-width: 400px;
    }

    .main-header {
        padding: 0 20px;
    }
}

/* Tablets */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }

    .preview-panel.open {
        width: 45%;
        min-width: 350px;
    }

    .welcome-screen h2 {
        font-size: 1.5rem;
    }

    .input-container {
        max-width: 700px;
    }

    .messages {
        padding: 20px;
    }
}

/* Mobile & Small Tablets */
@media (max-width: 768px) {
    :root {
        --header-height: 56px;
    }

    /* Sidebar becomes an overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        height: 100dvh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        z-index: 1000;
        transition: transform var(--transition-base);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Backdrop Overlay */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 900;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Show menu toggle button */
    .menu-toggle {
        display: flex;
    }

    /* Header adjustments */
    .main-header {
        padding: 0 16px;
    }

    .header-title h1 {
        font-size: 1.05rem;
    }

    .header-title .subtitle {
        display: none;
    }

    .header-actions {
        gap: 6px;
    }

    .icon-btn.preview-toggle .preview-badge {
        display: none;
    }

    .icon-btn.preview-toggle {
        width: 40px;
        padding: 0;
    }

    /* Preview panel becomes fullscreen overlay */
    .preview-panel.open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        min-width: 100%;
        z-index: 500;
    }

    /* Welcome screen adjustments */
    .welcome-screen {
        padding: 24px 16px 60px;
        justify-content: flex-start;
    }

    .welcome-icon {
        width: 56px;
        height: 56px;
    }

    .welcome-screen h2 {
        font-size: 1.6rem;
        margin-bottom: 8px;
    }

    .welcome-screen p {
        font-size: 0.875rem;
    }

    /* Quick actions to single column */
    .quick-actions {
        grid-template-columns: 1fr;
        gap: 8px;
        max-width: 100%;
    }

    .quick-action {
        padding: 14px 16px;
    }

    /* Messages area */
    .messages {
        padding: 16px;
        gap: 20px;
    }

    .message {
        gap: 12px;
    }

    .message-content {
        max-width: 100%;
        padding: 14px 16px;
    }

    .message-content pre {
        font-size: 0.8rem;
    }

    /* Input area */
    .input-area {
        padding: 12px 16px 16px;
    }

    #messageInput {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
        padding: 12px 14px;
    }

    .input-hint {
        font-size: 0.7rem;
    }

    /* Toast notifications */
    .toast {
        margin: 0 16px;
        max-width: calc(100% - 32px);
    }

    /* Shortcuts modal */
    .shortcuts-content {
        margin: 20px;
        width: calc(100% - 40px);
        max-width: none;
    }

    .shortcuts-list {
        padding: 12px 16px 20px;
    }

    /* Make buttons more touch-friendly */
    .icon-btn,
    .new-chat-btn,
    .send-btn,
    .attach-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Small Mobile Phones */
@media (max-width: 480px) {
    :root {
        --header-height: 52px;
    }

    /* Further reduce sidebar width */
    .sidebar {
        width: 85%;
        min-width: 85%;
    }

    /* Header */
    .main-header {
        padding: 0 12px;
    }

    .header-title h1 {
        font-size: 0.95rem;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
    }

    /* Welcome screen */
    .welcome-screen {
        padding: 20px 12px 60px;
    }

    .welcome-icon {
        width: 48px;
        height: 48px;
    }

    .welcome-screen h2 {
        font-size: 1.4rem;
    }

    .welcome-screen p {
        font-size: 0.85rem;
        padding: 0 8px;
    }

    .quick-actions {
        padding: 0 8px;
    }

    .quick-action {
        padding: 12px 14px;
    }

    .action-text {
        font-size: 0.85rem;
    }

    .action-desc {
        font-size: 0.7rem;
    }

    .welcome-features {
        flex-direction: column;
        gap: 8px;
    }

    .feature-tag {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    /* Messages */
    .messages {
        padding: 12px;
        gap: 16px;
    }

    .message {
        gap: 10px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .message-content {
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    .message-content h1 {
        font-size: 1.4rem;
    }

    .message-content h2 {
        font-size: 1.2rem;
    }

    .message-content h3 {
        font-size: 1.05rem;
    }

    .message-content pre {
        font-size: 0.75rem;
        padding: 10px;
    }

    .code-header {
        padding: 6px 10px;
    }

    /* Input area */
    .input-area {
        padding: 10px 12px 12px;
    }

    #messageInput {
        font-size: 16px;
        padding: 10px 12px;
    }

    .send-btn,
    .attach-btn {
        width: 40px;
        height: 40px;
    }

    .input-hint {
        font-size: 0.65rem;
        margin-top: 6px;
    }

    .input-hint kbd {
        padding: 2px 4px;
        font-size: 0.6rem;
    }

    /* Loading overlay */
    .loading-spinner {
        transform: scale(0.85);
    }

    /* Toast */
    .toast {
        margin: 0 12px;
        padding: 12px 14px;
        font-size: 0.85rem;
    }
}

/* Extra Small Phones */
@media (max-width: 360px) {
    .sidebar {
        width: 90%;
        min-width: 90%;
    }

    .welcome-screen h2 {
        font-size: 1.25rem;
    }

    .quick-action {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .message-content {
        max-width: 100%;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .welcome-screen {
        padding: 16px 20px 40px;
    }

    .welcome-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 8px;
    }

    .welcome-screen h2 {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }

    .welcome-screen p {
        font-size: 0.8rem;
        margin-bottom: 12px;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .welcome-features {
        flex-direction: row;
        margin-top: 12px;
        margin-bottom: 12px;
    }

    .input-area {
        padding: 8px 16px 12px;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {

    .sidebar,
    .input-area,
    .preview-panel,
    .loading-overlay,
    .toast-container {
        display: none !important;
    }

    .main-content {
        overflow: visible;
    }

    .messages {
        overflow: visible;
    }
}

/* ==================== PREMIUM ENHANCEMENTS ==================== */

/* Animated Background Gradient */
.app-container::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(118, 75, 162, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 40% 30% at 50% 90%, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: ambientShift 20s ease-in-out infinite;
}

@keyframes ambientShift {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Enhanced Glassmorphism for Sidebar */
.sidebar {
    background: rgba(15, 15, 22, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Premium Logo Animation */
.logo-icon {
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {

    0%,
    100% {
        box-shadow: var(--shadow-glow);
    }

    50% {
        box-shadow: var(--shadow-glow-strong), 0 0 30px rgba(102, 126, 234, 0.3);
    }
}

/* Enhanced Quick Action Cards */
.quick-action {
    background: rgba(22, 22, 32, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-style: preserve-3d;
    perspective: 1000px;
}

.quick-action:hover {
    transform: translateY(-6px) rotateX(2deg);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(102, 126, 234, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(102, 126, 234, 0.5);
}

.quick-action:active {
    transform: translateY(-2px) rotateX(0deg);
}

/* Shimmer Effect on Icon */
.action-icon-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
            transparent 30%,
            rgba(255, 255, 255, 0.3) 50%,
            transparent 70%);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s;
}

.quick-action:hover .action-icon-wrapper::after {
    opacity: 1;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }

    100% {
        transform: translateX(200%) rotate(45deg);
    }
}

/* Enhanced Message Bubbles */
.message.assistant .message-content {
    background: linear-gradient(135deg, rgba(22, 22, 32, 0.9) 0%, rgba(28, 28, 40, 0.9) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #667eea 100%);
    background-size: 200% 200%;
    animation: gradientFlow 3s ease infinite;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border-top-left-radius: var(--radius-sm);
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Premium Input Field */
.input-wrapper {
    position: relative;
    overflow: hidden;
}

.input-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    padding: 2px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
    background-size: 200% 200%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s;
    animation: borderGlow 3s ease infinite;
    pointer-events: none;
}

.input-wrapper:focus-within::before {
    opacity: 1;
}

@keyframes borderGlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Enhanced Send Button */
.send-btn {
    position: relative;
    overflow: hidden;
}

.send-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.send-btn:hover::before {
    opacity: 1;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}

/* Enhanced Code Blocks */
.message-content pre {
    position: relative;
    overflow: hidden;
}

.message-content pre::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0.6;
}

/* Smooth Scroll Shadow */
.messages::before,
.messages::after {
    content: '';
    position: sticky;
    left: 0;
    right: 0;
    height: 40px;
    pointer-events: none;
    z-index: 5;
}

.messages::before {
    top: 0;
    background: linear-gradient(to bottom, var(--bg-primary), transparent);
}

.messages::after {
    bottom: 0;
    background: linear-gradient(to top, var(--bg-primary), transparent);
}

/* Provider Badge Enhancement */
.provider-selector select {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-elevated) 100%);
    transition: all 0.3s ease;
}

.provider-selector select:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Feature Tags Glow */
.feature-tag {
    transition: all 0.3s ease;
}

.feature-tag:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
}

/* Welcome Screen Enhancement */
.welcome-screen h2 {
    text-shadow: 0 0 40px rgba(102, 126, 234, 0.3);
}

/* Floating Particles (CSS-only) */
.welcome-animation::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-primary);
    border-radius: 50%;
    top: 20%;
    left: 30%;
    box-shadow:
        60px 80px 0 rgba(102, 126, 234, 0.6),
        120px 40px 0 rgba(118, 75, 162, 0.5),
        200px 100px 0 rgba(102, 126, 234, 0.4),
        280px 60px 0 rgba(118, 75, 162, 0.6),
        80px 160px 0 rgba(59, 130, 246, 0.5),
        180px 180px 0 rgba(102, 126, 234, 0.3),
        320px 140px 0 rgba(118, 75, 162, 0.5);
    animation: floatParticles 15s linear infinite;
}

@keyframes floatParticles {
    0% {
        transform: translateY(0) translateX(0);
    }

    50% {
        transform: translateY(-20px) translateX(10px);
    }

    100% {
        transform: translateY(0) translateX(0);
    }
}

/* Status Indicator Glow */
.status-dot.connected {
    box-shadow: 0 0 10px var(--success);
}

/* Keyboard Hint Enhancement */
.keyboard-shortcuts-hint {
    transition: all 0.3s ease;
}

.keyboard-shortcuts-hint:hover {
    color: var(--text-secondary);
}

.keyboard-shortcuts-hint kbd {
    transition: all 0.2s ease;
}

.keyboard-shortcuts-hint:hover kbd {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}