/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile-first touch optimizations */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection for input fields and content areas */
input, textarea, .message-container, .formatted-message {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Improve scrolling on mobile and Safari */
html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Fix for iOS Safari viewport issues */
    height: 100%;
    height: 100vh;
    height: 100dvh;
}

/* Enhanced mobile scrolling and keyboard handling */
@supports (-webkit-touch-callout: none) {
    /* Safari-specific styles */
    html {
        height: -webkit-fill-available;
    }
    
    body {
        min-height: -webkit-fill-available;
    }
}

/* Mobile keyboard handling */
.chat-main {
    transition: transform 0.3s ease;
}

/* Improved mobile scrolling when keyboard is visible */
@media (max-width: 480px) {
    /* Ensure proper scrolling behavior */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Better keyboard handling for iOS */
    @supports (-webkit-appearance: none) {
        .chat-footer {
            /* Use env() for better keyboard handling */
            padding-bottom: max(0.5rem, env(keyboard-inset-height, 0px));
            padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
        }
        
        body {
            /* Better viewport handling */
            height: 100vh;
            height: 100svh; /* Small viewport height */
        }
    }
}

/* Better touch targets for mobile */
button, .header-btn, .send-btn, .feature-item {
    min-height: 44px;
    min-width: 44px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a3e 25%, #26314e 50%, #1f4670 75%, #634393 100%);
    background-attachment: fixed;
    color: #e5e7eb;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* iOS Safari safe area support */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.chat-header {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: transparent;
    backdrop-filter: blur(20px);
    border-bottom: none;
    flex-shrink: 0;
    box-shadow: none;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    text-shadow: 0 0 20px rgba(96, 165, 250, 0.3);
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.25rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 12px;
    backdrop-filter: blur(15px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
}

.button-group::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.5), transparent);
    border-radius: 12px 12px 0 0;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(79, 70, 229, 0.15);
    border: 1px solid rgba(79, 70, 229, 0.25);
    border-radius: 8px;
    color: #e5e7eb;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    min-height: 36px;
}

/* Button text responsive behavior */
.btn-text {
    display: inline;
    white-space: nowrap;
}

@media (max-width: 1024px) {
    .btn-text {
        display: none;
    }
    
    .header-btn {
        padding: 0.5rem;
        min-width: 36px;
        justify-content: center;
    }
    
    .button-group {
        gap: 0.25rem;
        padding: 0.25rem;
    }
}

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

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

.header-btn:hover {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.4), rgba(99, 102, 241, 0.4));
    border-color: rgba(79, 70, 229, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Main chat area */
.chat-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-top: 100px; /* Account for fixed header height + extra clearance */
    padding-bottom: 100px; /* Account for fixed footer */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem;
    width: 100%;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(79, 70, 229, 0.5) rgba(0, 0, 0, 0.2);
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.5), rgba(99, 102, 241, 0.5));
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.7), rgba(99, 102, 241, 0.7));
}

/* Chat Footer - Fixed position for better desktop accessibility */
.chat-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: transparent;
    backdrop-filter: blur(20px);
    padding: 1rem;
    border-top: none;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: none;
    z-index: 1000;
}

.input-container {
    width: 100%;
    max-width: none;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(79, 70, 229, 0.35);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.input-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(99, 102, 241, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.input-wrapper:focus-within {
    border-color: rgba(79, 70, 229, 0.6);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3), 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.input-wrapper:focus-within::before {
    opacity: 1;
}

#userInput {
    flex: 1 1 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    background: transparent;
    color: #e5e7eb;
    /* Fixed height for consistent placeholder positioning */
    height: 44px !important;
    max-height: 44px !important;
    min-height: 44px;
    overflow-y: hidden !important;
    position: relative;
    z-index: 1;
    text-align: left;
    line-height: 44px; /* Match height for perfect vertical centering */
    box-sizing: border-box;
}

#userInput::placeholder {
    color: rgba(156, 163, 175, 0.8);
    text-align: center;
    line-height: 44px; /* Match input height for perfect vertical centering */
    position: static;
    vertical-align: middle;
    width: 100%;
    display: inline-block;
    height: 100%;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* Hide placeholder when focused or has content */
#userInput:focus::placeholder {
    opacity: 0;
    visibility: hidden;
}

/* When input has content or is focused, align text to left */
#userInput:not(:placeholder-shown),
#userInput:focus {
    text-align: left;
    line-height: 1.5; /* Normal line height for content */
    overflow-y: hidden !important;
    height: 44px !important;
    max-height: 44px !important;
}

/* Chrome-specific text wrapping support for desktop */
@media (min-width: 769px) {
    body.chrome-browser #userInput {
        white-space: pre-wrap !important;
        height: auto !important;
        min-height: 44px !important;
        max-height: 120px !important;
        overflow-y: auto !important;
    }
    
    body.chrome-browser #userInput:placeholder-shown {
        height: 44px !important;
        line-height: 44px !important;
        white-space: nowrap !important;
    }
}

.send-btn {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border: none;
    padding: 0.5rem 0.75rem;
    margin-left: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
    z-index: 1;
}

.send-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;
}

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

.send-btn:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.send-btn:active {
    transform: translateY(0);
}

.token-float {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* Message container styles */

/* Typing Animation Styles */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    background: transparent;
    position: relative;
    animation: fadeInUp 0.5s ease-out;
}

.typing-indicator .typing-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.typing-indicator .typing-avatar {
    font-size: 1.2rem;
    opacity: 0.8;
}

.typing-indicator .typing-text {
    color: #a78bfa;
    font-size: 0.95rem;
    opacity: 0.9;
}

.typing-dots {
    display: inline-flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a78bfa;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

.typing-dot:nth-child(3) {
    animation-delay: 0;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.3;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

/* Typing text animation for character-by-character reveal */
.typing-text-animation {
    overflow: hidden;
    border-right: 2px solid #a78bfa;
    animation: blinkCursor 1s infinite;
}

/* Improved typing cursor with dot indicator */
.typing-cursor {
    display: inline;
    line-height: inherit;
}

.cursor-dot {
    display: inline;
    color: #a78bfa;
    font-size: 0.8em;
    animation: cursorBlink 1.2s infinite;
    vertical-align: baseline;
    line-height: inherit;
}

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

@keyframes blinkCursor {
    0%, 50% {
        border-color: #a78bfa;
    }
    51%, 100% {
        border-color: transparent;
    }
}

.message-container {
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
    background: transparent;
    line-height: 1.65;
    position: relative;
    display: flex;
    width: 100%;
}

/* User messages on the right */
.message-container.user {
    justify-content: flex-end;
}

/* Assistant messages on the left */
.message-container.assistant {
    justify-content: flex-start;
}

/* Message content wrapper - full width for better readability like ChatGPT */
.message-wrapper {
    max-width: 100%;
    padding: 0;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* User message styling - minimal with small right margin */
.message-container.user .message-wrapper {
    background: transparent;
    color: #e5e7eb;
    margin-right: 0.5rem;
}

.message-container.user .message-wrapper strong {
    color: #e5e7eb;
}

/* Assistant message styling - minimal with small left margin */
.message-container.assistant .message-wrapper {
    background: transparent;
    color: #e5e7eb;
    margin-left: 0.5rem;
}

.message-container.assistant .message-wrapper strong {
    color: #e5e7eb;
}

/* Typing indicator alignment */
.typing-indicator {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    background: transparent;
    position: relative;
    animation: fadeInUp 0.5s ease-out;
}


.message-container p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: #e5e7eb;
}

.message-container strong {
    color: #60a5fa;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
}

.message-container.insight-tagged {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.4);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
}

.message-container.insight-tagged::before {
    background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.5), transparent);
}

.message-content {
    position: relative;
}

/* Insight controls removed - now using floating button */

.formatted-message p {
    margin: 0.75rem 0;
    line-height: 1.6;
}

.formatted-list {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.formatted-list li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.formatted-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(10px);
}

.formatted-table th,
.formatted-table td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid rgba(79, 70, 229, 0.2);
    color: #e5e7eb;
}

.formatted-table th {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.3), rgba(99, 102, 241, 0.3));
    font-weight: 600;
    color: #60a5fa;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
}

.formatted-table tr:nth-child(even) {
    background: rgba(79, 70, 229, 0.1);
}

.formatted-table tr:hover {
    background: rgba(79, 70, 229, 0.2);
}

.code-block {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #e5e7eb;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
}

.code-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.5), transparent);
}

.inline-code {
    background: rgba(79, 70, 229, 0.2);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 6px;
    padding: 0.2rem 0.4rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #a78bfa;
    backdrop-filter: blur(5px);
}

/* Real-time formatting styles for typing animation */
.bullet-point {
    color: #60a5fa;
    font-weight: 500;
}

.bullet-content {
    color: #e5e7eb;
    font-weight: normal;
}

.numbered-item {
    color: #34d399;
    font-weight: 500;
}

.item-content {
    color: #e5e7eb;
    font-weight: normal;
}

.text-content {
    color: #e5e7eb;
    line-height: 1.6;
}

.step-by-step {
    margin: 1rem 0;
}

.step {
    margin: 1rem 0 0.5rem 0;
    color: #60a5fa;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
}

.step-content {
    margin: 0.5rem 0 1rem 1rem;
    line-height: 1.5;
    color: #e5e7eb;
}

.qa-format {
    margin: 1rem 0;
}

.question {
    margin: 1rem 0 0.5rem 0;
    color: #f87171;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.3);
}

.answer {
    margin: 1rem 0 0.5rem 0;
    color: #34d399;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

.qa-content {
    margin: 0.5rem 0 1rem 1rem;
    line-height: 1.5;
    color: #e5e7eb;
}

.response-heading {
    color: #60a5fa;
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(79, 70, 229, 0.4);
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
    font-weight: 600;
}

/* Individual insight buttons removed - now using floating button system */

.insight-dropdown {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(79, 70, 229, 0.4);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.insight-dropdown select {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 8px;
    font-size: 0.9rem;
    color: #e5e7eb;
    transition: all 0.3s ease;
}

.insight-dropdown select:focus {
    border-color: rgba(79, 70, 229, 0.6);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
    outline: none;
}

.insight-dropdown input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 8px;
    font-size: 0.9rem;
    color: #e5e7eb;
    transition: all 0.3s ease;
}

.insight-dropdown input[type="text"]:focus {
    border-color: rgba(79, 70, 229, 0.6);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
    outline: none;
}

.insight-dropdown input[type="text"]::placeholder {
    color: rgba(156, 163, 175, 0.6);
}

.insight-dropdown button {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    margin: 0.2rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.6), rgba(99, 102, 241, 0.6));
    border: 1px solid rgba(79, 70, 229, 0.4);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.insight-dropdown button:hover {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.8), rgba(99, 102, 241, 0.8));
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.insight-success {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.2));
    color: #34d399;
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: bold;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
    text-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

.compression-notice {
    margin: 1rem 0;
    padding: 0.75rem;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 12px;
    font-size: 0.875rem;
    color: #fbbf24;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.1);
}

/* Welcome Message Styles */
.welcome-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    transition: opacity 0.5s ease, transform 0.5s ease;
    /* Prevent viewport changes from affecting position */
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden;
    /* Lock position regardless of keyboard/viewport changes */
    transform: none !important;
    -webkit-transform: none !important;
    will-change: auto;
    contain: layout;
    /* Prevent any environmental changes from affecting centering */
    margin: 0 !important;
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
    box-sizing: border-box !important;
}

.welcome-container.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.welcome-card {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 24px;
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    animation: welcomeSlideIn 0.8s ease-out;
}

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

.welcome-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.8), rgba(99, 102, 241, 0.8), transparent);
}

.welcome-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(99, 102, 241, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.welcome-card:hover::after {
    opacity: 1;
}

.welcome-icon {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
}

.welcome-icon svg {
    color: #60a5fa;
    filter: drop-shadow(0 0 20px rgba(96, 165, 250, 0.4));
    animation: welcomeIconFloat 3s ease-in-out infinite;
}

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

.welcome-card h2 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    text-shadow: 0 0 30px rgba(96, 165, 250, 0.3);
}

.welcome-card > p {
    font-size: 1.125rem;
    color: rgba(229, 231, 235, 0.9);
    line-height: 1.6;
    margin-bottom: 2.5rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: 12px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.feature-item:hover {
    background: rgba(79, 70, 229, 0.2);
    border-color: rgba(79, 70, 229, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.feature-item svg {
    color: #a78bfa;
    flex-shrink: 0;
}

.feature-item span {
    color: #e5e7eb;
    font-weight: 500;
    font-size: 0.9rem;
}

.welcome-prompt {
    padding: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.welcome-prompt p {
    font-size: 1rem;
    color: #a78bfa;
    margin: 0;
    font-weight: 500;
    text-shadow: 0 0 10px rgba(167, 139, 250, 0.3);
}

.privacy-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 8px;
    font-size: 0.75rem;
    color: #34d399;
    text-shadow: 0 0 5px rgba(52, 211, 153, 0.3);
    backdrop-filter: blur(5px);
}

.privacy-note svg {
    color: #22c55e;
    flex-shrink: 0;
}

/* Welcome Message Responsive Design */
@media (max-width: 768px) {
    .welcome-container {
        padding: 1rem;
        /* Ensure centering is maintained on tablets */
        height: 100vh !important;
        height: 100dvh !important;
        transform: none !important;
        -webkit-transform: none !important;
    }
    
    .welcome-card {
        padding: 2rem 1.5rem;
        border-radius: 20px;
    }
    
    .welcome-card h2 {
        font-size: 1.75rem;
    }
    
    .welcome-card > p {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    .welcome-features {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 2rem;
    }
    
    .feature-item {
        padding: 0.75rem;
    }
    
    .welcome-prompt {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .welcome-container {
        padding: 0.75rem;
        /* Lock position on mobile devices - prevent keyboard interference */
        height: 100vh !important;
        height: 100dvh !important;
        height: 100svh !important; /* Small viewport height for mobile */
        transform: none !important;
        -webkit-transform: none !important;
        /* Additional mobile viewport locks */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
        /* Prevent scroll or movement */
        overflow: hidden !important;
        -webkit-overflow-scrolling: auto !important;
    }
    
    .welcome-card {
        padding: 1.5rem 1rem;
        border-radius: 16px;
    }
    
    .welcome-icon {
        margin-bottom: 1.5rem;
    }
    
    .welcome-icon svg {
        width: 48px;
        height: 48px;
    }
    
    .welcome-card h2 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    .welcome-card > p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .welcome-features {
        margin-bottom: 1.5rem;
    }
    
    .feature-item {
        padding: 0.625rem;
        gap: 0.5rem;
    }
    
    .feature-item svg {
        width: 16px;
        height: 16px;
    }
    
    .feature-item span {
        font-size: 0.8rem;
    }
    
    .welcome-prompt {
        padding: 0.75rem;
    }
    
    .welcome-prompt p {
        font-size: 0.9rem;
    }
}

/* Feedback Page Styles */
.feedback-page {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.feedback-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.feedback-header {
    text-align: center;
    padding: 1rem 0;
}

.feedback-header .brand h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    text-shadow: 0 0 30px rgba(96, 165, 250, 0.4);
}

.feedback-content {
    display: flex;
    justify-content: center;
    align-items: center;
}

.feedback-card {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 24px;
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    width: 100%;
    max-width: 500px;
}

.feedback-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.8), rgba(99, 102, 241, 0.8), transparent);
}

.feedback-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(79, 70, 229, 0.5);
}

.feedback-icon {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.feedback-icon svg {
    color: #34d399;
    filter: drop-shadow(0 0 20px rgba(52, 211, 153, 0.4));
}

.feedback-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #60a5fa;
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(96, 165, 250, 0.3);
}

.feedback-card p {
    font-size: 1rem;
    color: #e5e7eb;
    line-height: 1.6;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.feedback-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.feedback-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: none;
    min-height: 48px;
}

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

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

.feedback-btn.primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.feedback-btn.primary:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.feedback-btn.secondary {
    background: rgba(79, 70, 229, 0.2);
    border: 1px solid rgba(79, 70, 229, 0.4);
    color: #e5e7eb;
    backdrop-filter: blur(10px);
}

.feedback-btn.secondary:hover {
    background: rgba(79, 70, 229, 0.3);
    border-color: rgba(79, 70, 229, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.2);
}

.feedback-btn svg {
    width: 16px;
    height: 16px;
}

.feedback-footer {
    text-align: center;
    padding: 1rem 0;
}

.feedback-footer p {
    color: rgba(229, 231, 235, 0.6);
    font-size: 0.875rem;
    margin: 0;
}

/* Index Page Styles */
.start-button {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.start-button button {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.start-button button::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;
}

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

.start-button button:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.welcome-card h2 {
    color: #60a5fa;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 2rem 0 1rem 0;
    text-shadow: 0 0 20px rgba(96, 165, 250, 0.3);
}

.welcome-card ul {
    text-align: left;
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.welcome-card li {
    margin-bottom: 0.5rem;
    color: #e5e7eb;
    line-height: 1.5;
}

.welcome-card strong {
    color: #60a5fa;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
}

.welcome-card section {
    margin: 1.5rem 0;
}

.welcome-card section:last-of-type {
    margin-bottom: 2rem;
}

/* Feedback Page Responsive Design */
@media (max-width: 768px) {
    .feedback-page {
        padding: 1rem;
    }
    
    .feedback-container {
        gap: 1.5rem;
    }
    
    .feedback-header .brand h1 {
        font-size: 1.75rem;
    }
    
    .feedback-card {
        padding: 2rem 1.5rem;
        border-radius: 20px;
    }
    
    .feedback-card h2 {
        font-size: 1.25rem;
    }
    
    .feedback-actions {
        gap: 0.75rem;
    }
    
    .feedback-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .feedback-page {
        padding: 0.75rem;
    }
    
    .feedback-container {
        gap: 1rem;
    }
    
    .feedback-header .brand h1 {
        font-size: 1.5rem;
    }
    
    .feedback-card {
        padding: 1.5rem 1rem;
        border-radius: 16px;
    }
    
    .feedback-card h2 {
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
    }
    
    .feedback-card p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .feedback-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
}

/* Show stats button on all devices */
.stats-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(99, 102, 241, 0.2));
    border: 1px solid rgba(79, 70, 229, 0.4);
    border-radius: 8px;
    color: #e5e7eb;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

/* Override header-btn shimmer effect for stats button */
.stats-btn::before {
    display: none !important;
}

.stats-btn:hover {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.4), rgba(99, 102, 241, 0.4));
    border-color: rgba(79, 70, 229, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-header {
        padding: 0.75rem 1rem;
    }
    
    .brand h1 {
        font-size: 1.25rem;
    }
    
    .header-controls {
        gap: 0.25rem;
    }
    
    .header-btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Match stats button styling on tablet too */
    .stats-btn {
        display: inline-flex !important;
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
        background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(99, 102, 241, 0.2));
        border: 1px solid rgba(79, 70, 229, 0.4);
        color: #e5e7eb;
        font-weight: 500;
    }
    
    .chat-messages {
        padding: 0.75rem 0.5rem;
    }
    
    .message-container {
        padding: 0.875rem; /* Slightly reduced for tablet */
        margin-bottom: 1rem;
    }

    .message-container p, .message-container strong {
        font-size: 0.95rem; /* Slightly reduced font size for tablet */
    }
    
    /* Small margins on tablet for full width readability */
    .message-container.user .message-wrapper {
        margin-right: 0.5rem;
    }
    
    .message-container.assistant .message-wrapper {
        margin-left: 0.5rem;
    }
    
    .token-float {
        bottom: 120px; /* Above fixed footer */
        left: 0.5rem;
        font-size: 0.8rem;
        padding: 0.375rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 0.5rem 0.75rem;
    }
    
    .brand h1 {
        font-size: 1.125rem;
    }
    
    .header-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .chat-messages {
        padding: 0.5rem 0.25rem;
        /* Add padding bottom to prevent overlap with input */
        padding-bottom: 1rem;
    }
    
    .message-container {
        padding: 0.5rem; /* Reduced padding */
        margin-bottom: 0.75rem;
    }

    .message-container p, .message-container strong {
        font-size: 0.9rem; /* Reduced font size for better visibility */
    }
    
    /* Full width messages on mobile for maximum readability */
    .message-container.user .message-wrapper {
        margin-right: 0.25rem;
    }
    
    .message-container.assistant .message-wrapper {
        margin-left: 1rem; /* Increased margin to prevent number/bullet cutoff */
        padding-left: 0.5rem; /* Additional internal padding */
    }
    
    .chat-footer {
        padding: 0.5rem;
        /* Footer positioning already handled globally */
    }
    
    .input-container {
        max-width: none;
        width: 100%;
    }
    
    .input-wrapper {
        padding: 0.5rem;
        border-radius: 8px;
        align-items: center;
        position: relative;
        min-height: 60px; /* Ensure consistent height */
    }
    
    #userInput {
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
        line-height: 1.4;
        min-height: 44px; /* Fixed minimum height */
        height: 44px !important; /* Force fixed height */
        max-height: 44px !important; /* Prevent expansion */
        border-radius: 6px;
        resize: none;
        /* Better mobile text input */
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        /* Fix placeholder positioning on mobile */
        text-align: center;
        vertical-align: middle;
        box-sizing: border-box;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        /* Ensure consistent positioning */
        display: block;
        width: 100%;
        /* Prevent auto-resize */
        overflow-y: hidden !important;
    }
    
#userInput::placeholder {
    color: rgba(156, 163, 175, 0.8);
    text-align: center;
    vertical-align: middle;
    line-height: 44px; /* Match input height for perfect vertical centering */
    position: static;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: inline-block;
    height: 100%;
    pointer-events: none;
    /* Chrome mobile specific fixes */
    transform: translateY(0);
    -webkit-transform: translateY(0);
}

/* Hide placeholder when focused */
#userInput:focus::placeholder {
    opacity: 0;
    visibility: hidden;
}

/* When input has content or is focused on mobile, align text to left */
#userInput:not(:placeholder-shown),
#userInput:focus {
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow-x: auto;
    overflow-y: hidden !important;
    height: 44px !important;
    max-height: 44px !important;
}
    
    .send-btn {
        padding: 0.75rem;
        border-radius: 6px;
        margin-left: 0.5rem;
        flex-shrink: 0;
        min-width: 44px;
        min-height: 44px;
    }
    
    .token-float {
        display: none !important;
    }
    
    /* Show stats button on mobile - Original Chrome styling */
    .stats-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 0.25rem 0.5rem;
        border: 1px solid rgba(79, 70, 229, 0.4);
        border-radius: 8px;
        background: rgba(79, 70, 229, 0.2);
        color: #e5e7eb;
        font-size: 0.75rem;
        font-weight: 500;
        text-decoration: none;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: none;
        position: relative;
        overflow: visible;
        -webkit-tap-highlight-color: transparent;
    }

    /* Override header-btn shimmer effect for stats button on mobile */
    .stats-btn::before {
        display: none !important;
    }

    .stats-btn:hover {
        background: linear-gradient(135deg, rgba(79, 70, 229, 0.4), rgba(99, 102, 241, 0.4));
        border-color: rgba(79, 70, 229, 0.6);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    }
    
    /* Adjust main content to account for fixed footer */
    .chat-main {
        padding-bottom: 80px;
    }
}

/* Notification System Styles */
.notification-container {
    position: fixed;
    top: 100px; /* Below fixed header */
    right: 20px;
    z-index: 1000;
    pointer-events: none;
}

.insight-notification {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    min-width: 320px;
    max-width: 400px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

.insight-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.insight-notification.hide {
    opacity: 0;
    transform: translateX(100%);
}

.notification-content {
    position: relative;
}

.notification-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.notification-icon {
    font-size: 20px;
    margin-right: 8px;
}

.notification-title {
    flex-grow: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.notification-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.notification-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.notification-message {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.4;
    opacity: 0.9;
}

.notification-context {
    margin: 8px 0;
    font-size: 12px;
    opacity: 0.7;
    font-style: italic;
}

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

.notification-action {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.notification-action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.notification-action.secondary {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.4);
}

.notification-action.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Enhanced message container styles for insight tagging */
.message-container.insight-tagged {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-left: 4px solid #667eea;
}

/* Enhanced insight controls for simplified UX */
.insight-controls {
    opacity: 1;
}

/* Floating Insight Button */
.floating-insight-btn {
    position: fixed;
    bottom: 120px;
    right: 30px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
    border: 1px solid rgba(79, 70, 229, 0.4);
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #e5e7eb;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), 
                0 4px 12px rgba(79, 70, 229, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    white-space: nowrap;
    min-width: fit-content;
}

.floating-insight-btn::before {
    content: '💡';
    font-size: 1.1rem;
    opacity: 0.9;
    margin-right: 0.25rem;
}

.floating-insight-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.2), transparent);
    transition: left 0.5s ease;
    border-radius: 16px;
}

.floating-insight-btn:hover {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.25), rgba(99, 102, 241, 0.25));
    border-color: rgba(79, 70, 229, 0.6);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(79, 70, 229, 0.25), 
                0 8px 20px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
    color: #a78bfa;
}

.floating-insight-btn:hover::before {
    opacity: 1;
    transform: scale(1.1);
}

.floating-insight-btn:hover::after {
    left: 100%;
}

.floating-insight-btn:active {
    transform: translateY(-1px) scale(0.98);
    transition: all 0.1s ease;
}

/* Hide floating button on mobile/tablet */
@media (max-width: 1024px) {
    .floating-insight-btn {
        display: none;
    }
}

/* Insight Selection Modal */
.insight-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.insight-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.insight-modal {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
    border: 1px solid rgba(79, 70, 229, 0.4);
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.insight-modal-overlay.active .insight-modal {
    transform: scale(1) translateY(0);
}

.insight-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(79, 70, 229, 0.3);
}

.insight-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #e5e7eb;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.insight-modal-title::before {
    content: '💡';
    font-size: 1.2rem;
}

.insight-modal-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.insight-modal-close:hover {
    color: #e5e7eb;
    background: rgba(79, 70, 229, 0.2);
}

.insight-messages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.insight-message-item {
    padding: 1rem;
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.insight-message-item:hover {
    background: rgba(79, 70, 229, 0.15);
    border-color: rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

.insight-message-item.selected {
    background: rgba(79, 70, 229, 0.2);
    border-color: rgba(79, 70, 229, 0.4);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.insight-message-preview {
    color: #e5e7eb;
    font-size: 0.9rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.insight-modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid rgba(79, 70, 229, 0.3);
}

.insight-modal-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.insight-modal-btn.primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.insight-modal-btn.primary:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.insight-modal-btn.secondary {
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid rgba(79, 70, 229, 0.3);
    color: #e5e7eb;
}

.insight-modal-btn.secondary:hover {
    background: rgba(79, 70, 229, 0.2);
    border-color: rgba(79, 70, 229, 0.4);
}

/* Responsive design for notifications */
@media (max-width: 480px) {
    .notification-container {
        top: 70px; /* Below mobile fixed header */
        right: 10px;
        left: 10px;
    }
    
    .insight-notification {
        min-width: auto;
        max-width: none;
    }
}

/* Additional mobile breakpoints to ensure stats button visibility */
@media (max-width: 767px) {
    .stats-btn {
        display: -webkit-inline-flex !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: relative !important;
        left: auto !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        clip: auto !important;
        -webkit-clip-path: none !important;
        clip-path: none !important;
    }
}

    /* Safari-specific mobile rules */
@media screen and (max-device-width: 480px) {
    .stats-btn {
        display: -webkit-inline-flex !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: relative !important;
        left: auto !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        clip: auto !important;
        -webkit-clip-path: none !important;
        clip-path: none !important;
    }
    
    /* Enhanced mobile copy button animations */
    .action-btn {
        -webkit-tap-highlight-color: transparent;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        transform: scale(1);
        will-change: transform, color, background-color;
    }
    
    .action-btn:active {
        transform: scale(0.95) !important;
        transition: transform 0.1s ease !important;
    }
    
    /* Specific copy button mobile styling */
    .copy-btn {
        position: relative;
        overflow: visible;
    }
    
    /* Enhanced feedback animations for mobile */
    .copy-btn.copying {
        animation: mobileSuccessPulse 0.6s ease-in-out;
    }
    
    .copy-btn.copy-error {
        animation: mobileErrorShake 0.5s ease-in-out;
    }
    
    /* Mobile-specific animation keyframes */
    @keyframes mobileSuccessPulse {
        0% { transform: scale(1); }
        50% { transform: scale(1.15); background-color: rgba(16, 185, 129, 0.2); }
        100% { transform: scale(1); }
    }
    
    @keyframes mobileErrorShake {
        0%, 100% { transform: translateX(0); }
        25% { transform: translateX(-2px); }
        75% { transform: translateX(2px); }
    }
}

/* Touch device detection */
@media (hover: none) and (pointer: coarse) {
    .stats-btn {
        display: -webkit-inline-flex !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: relative !important;
        left: auto !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        clip: auto !important;
        -webkit-clip-path: none !important;
        clip-path: none !important;
    }
    
    /* Ensure insight button styling works on touch devices */
    .insight-btn {
        background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
        color: #ffffff !important;
        border: 1px solid rgba(79, 70, 229, 0.6) !important;
        backdrop-filter: blur(10px);
        box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3) !important;
        font-weight: 500 !important;
        -webkit-tap-highlight-color: transparent;
    }
    
    .insight-btn.clicked {
        background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
        color: #ffffff !important;
        border: 1px solid rgba(79, 70, 229, 0.6) !important;
        box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3) !important;
    }
    
    /* Aggressively hide token display on touch devices */
    .token-float, 
    #token-display,
    [id="token-display"],
    [class*="token"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
        top: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        z-index: -9999 !important;
    }
}

/* Safari-specific token hiding */
@supports (-webkit-touch-callout: none) {
    /* This targets Safari specifically */
    @media (max-width: 768px) {
        .token-float, 
        #token-display,
        [id="token-display"],
        [class*="token"] {
            display: none !important;
            visibility: hidden !important;
            opacity: 0 !important;
            position: absolute !important;
            left: -9999px !important;
            top: -9999px !important;
            width: 0 !important;
            height: 0 !important;
            z-index: -9999 !important;
        }
    }
}

/* Chrome mobile specific placeholder fixes */
@media screen and (max-width: 480px) and (-webkit-min-device-pixel-ratio: 0) {
    /* Target Chrome mobile specifically */
    #userInput {
        font-size: 16px !important; /* Prevents zoom on Chrome mobile */
        line-height: 1.4 !important; /* Normal line height for text wrapping */
        padding: 0.75rem !important;
        /* Enable auto-expansion and text wrapping on Chrome mobile */
        min-height: 44px !important;
        height: auto !important;
        max-height: 120px !important; /* Allow expansion up to 120px */
        overflow-y: auto !important; /* Allow scrolling if content exceeds max-height */
        white-space: pre-wrap !important; /* Enable text wrapping */
        word-wrap: break-word !important;
        /* Prevent Chrome's auto-sizing behaviors */
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
        /* Additional Chrome rendering fixes */
        will-change: auto;
        contain: layout style;
    }
    
    #userInput::placeholder {
        /* Chrome mobile placeholder specific fixes */
        line-height: 44px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
        padding: 0 0.5rem !important;
        /* Prevent any transforms or movements */
        transform: none !important;
        -webkit-transform: none !important;
        /* Force rendering as block */
        box-sizing: border-box !important;
        width: 100% !important;
    }
    
    /* Force the input wrapper to maintain stable size */
    .input-wrapper {
        min-height: 60px !important;
        height: 60px !important;
        align-items: center !important;
        display: flex !important;
    }
    
    /* When input has content, hide the custom placeholder positioning */
    #userInput:not(:placeholder-shown)::placeholder {
        display: none !important;
        visibility: hidden !important;
    }
}
