* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body, html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    width: 100vw;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 24px 20px;
    text-align: center;
    font-size: 1.4em;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.3);
    position: relative;
    border-bottom: 3px solid #ff6b35;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    overflow: hidden;
    min-height: 70px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    justify-content: center;
    min-width: 0; /* Allows flex items to shrink */
}

.theme-toggle {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 60px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
    z-index: 10;
    flex-shrink: 0;
}

.theme-toggle::before {
    content: '🌙';
    position: absolute;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    top: 1px;
    left: 1px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle.dark {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(0, 0, 0, 0.4);
}

.theme-toggle.dark::before {
    transform: translateX(30px);
    content: '☀️';
    background: #ff6b35;
    color: white;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.chat-header span {
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chat-header .logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.2));
    transition: all 0.3s ease;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px;
    backdrop-filter: blur(10px);
}

.chat-header .logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    background: rgba(255, 255, 255, 0.15);
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: linear-gradient(45deg, #ff6b35 0%, #f7931e 50%, #ff6b35 100%);
    clip-path: polygon(50% 0%, 0% 50%, 50% 100%, 100% 50%);
}

.chat-header::after {
    content: 'CODEX CHAT';
    position: absolute;
    top: 50%;
    left: 65px;
    transform: translateY(-50%);
    font-size: 0.9em;
    font-weight: 300;
    letter-spacing: 2px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    position: relative;
}

.chat-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255, 107, 53, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(247, 147, 30, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

/* ========== AVATAR SYSTEM ========== */

.message-wrapper {
    display: flex;
    align-items: flex-end;
    margin: 12px 15px;
    gap: 10px;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

.bot-wrapper {
    margin-right: auto;
    flex-direction: row;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.bot-avatar {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #ff6b35;
    padding: 4px;
}

.bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

/* Avatar hover effects */
.avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}



/* User messages - simple styling without avatars */
.user-message-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin: 8px 15px;
    animation: messageSlide 0.3s ease-out;
}

.user-message {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
    max-width: 80%;
    width: fit-content;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.4;
}

/* Bot messages - will be inside message-wrapper with avatar */
.bot-message-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.bot-message {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #2c3e50;
    border-bottom-left-radius: 4px;
    border-left: 3px solid #ff6b35;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0; /* Reset margin when inside wrapper */
    max-width: calc(100% - 42px); /* Account for avatar width + gap */
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.4;
    width: fit-content;
}

/* ========== TIMESTAMP STYLING ========== */

.timestamp {
    font-size: 0.75em;
    color: #6c757d;
    margin-top: 4px;
    opacity: 0.8;
    font-weight: 400;
    transition: opacity 0.3s ease;
}

.user-timestamp {
    text-align: right;
    color: rgba(255, 107, 53, 0.8);
    margin-right: 8px;
}

.bot-timestamp {
    text-align: left;
    color: #6c757d;
    margin-left: 8px;
}

/* Hover effects for timestamps */
.user-message-container:hover .timestamp,
.message-wrapper:hover .timestamp {
    opacity: 1;
}

/* Dark mode timestamp styling */
[data-theme="dark"] .timestamp {
    color: #aaaaaa;
}

[data-theme="dark"] .user-timestamp {
    color: rgba(255, 147, 30, 0.9);
}

[data-theme="dark"] .bot-timestamp {
    color: #aaaaaa;
}

/* ========== COPY FUNCTIONALITY ========== */

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 6px;
    opacity: 0;
    transform: translateY(5px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    color: #ff6b35;
    font-weight: 500;
}

/* Show copy button on hover */
.user-message-container:hover .copy-btn,
.message-wrapper:hover .copy-btn {
    opacity: 1;
    transform: translateY(0);
}

/* User message copy button positioning */
.user-message-container .copy-btn {
    align-self: flex-end;
    margin-right: 8px;
}

/* Bot message copy button positioning */
.bot-message-content .copy-btn {
    align-self: flex-start;
    margin-left: 8px;
}

.copy-btn:hover {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    border-color: #ff6b35;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.copy-btn:active {
    transform: translateY(-1px);
}

.copy-icon {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.copy-text {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.copy-btn:hover .copy-icon {
    transform: scale(1.1);
}

/* Dark mode copy button */
[data-theme="dark"] .copy-btn {
    background: linear-gradient(135deg, #3d3d3d 0%, #2d2d2d 100%);
    border-color: rgba(255, 107, 53, 0.4);
    color: #f7931e;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .copy-btn:hover {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    border-color: #ff6b35;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}


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

.chat-input {
    display: flex;
    padding: 15px 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-top: 1px solid rgba(255, 107, 53, 0.2);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.chat-input input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e9ecef;
    background-color: #ffffff;
    border-radius: 25px;
    outline: none;
    font-size: 0.95em;
    margin-right: 12px;
    transition: all 0.3s ease;
    color: #2c3e50;
}

.chat-input input:focus {
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.chat-input input::placeholder {
    color: #6c757d;
}

.chat-input button {
    padding: 12px 20px;
    border: none;
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
    min-width: 100px;
}

.chat-input button:hover:not(:disabled) {
    background: linear-gradient(135deg, #e55a2b 0%, #e0841a 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.chat-input button:active:not(:disabled) {
    transform: translateY(0);
}

/* ========== INPUT LOCKING SYSTEM ========== */

/* Disabled input state */
.chat-input input:disabled,
.chat-input input.disabled {
    background-color: #f5f5f5 !important;
    color: #999 !important;
    border-color: #ddd !important;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Disabled button state */
.chat-input button:disabled,
.chat-input button.processing {
    background: linear-gradient(135deg, #cccccc 0%, #aaaaaa 100%) !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    opacity: 0.7;
}

/* Processing animation for send button */
.chat-input button.processing::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: buttonSpin 1s linear infinite;
}

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

/* Dark mode disabled states */
[data-theme="dark"] .chat-input input:disabled,
[data-theme="dark"] .chat-input input.disabled {
    background-color: #2a2a2a !important;
    color: #666 !important;
    border-color: #444 !important;
}

[data-theme="dark"] .chat-input button:disabled,
[data-theme="dark"] .chat-input button.processing {
    background: linear-gradient(135deg, #555555 0%, #444444 100%) !important;
    color: #888 !important;
}

/* ========== RESPONSIVE DESIGN ========== */

/* Extra Extra Small Devices (very small phones, up to 360px) */
@media (max-width: 360px) {
    .chat-header {
        font-size: 1em;
        padding: 12px 10px;
        gap: 6px;
    }
    
    .chat-header .logo {
        width: 24px;
        height: 24px;
        padding: 2px;
    }
    
    .chat-header span {
        font-size: 0.85em;
        margin: 0 5px;
    }

    .theme-toggle {
        width: 40px;
        height: 20px;
    }

    .theme-toggle::before {
        width: 16px;
        height: 16px;
        font-size: 8px;
    }

    .theme-toggle.dark::before {
        transform: translateX(18px);
    }
    
    .chat-input {
        padding: 10px;
    }
    
    .chat-input input {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .chat-input button {
        padding: 12px 16px;
        font-size: 0.85em;
    }
}

/* Extra Small Devices (phones, up to 576px) */
@media (max-width: 576px) {
    .chat-header {
        font-size: 1.1em;
        padding: 16px 70px 16px 15px; /* Extra right padding for toggle button */
        gap: 8px;
        min-height: 60px;
        justify-content: flex-start;
    }
    
    .chat-header .logo {
        width: 28px;
        height: 28px;
        padding: 2px;
        flex-shrink: 0;
    }
    
    .chat-header span {
        font-size: 0.9em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        text-align: left;
        margin-left: 8px;
    }

    /* Hide CODEX CHAT text on mobile to prevent overlap */
    .chat-header::after {
        display: none;
    }
    
    /* Hide diamond shape on mobile */
    .chat-header::before {
        display: none;
    }

    .theme-toggle {
        width: 45px;
        height: 22px;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
    }

    .theme-toggle::before {
        width: 18px;
        height: 18px;
        font-size: 9px;
        top: 1px;
        left: 1px;
    }

    .theme-toggle.dark::before {
        transform: translateX(22px);
    }

    .chat-input {
        padding: 12px 15px;
        flex-direction: column;
        gap: 10px;
    }

    .chat-input input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 18px;
        margin-right: 0;
        border-radius: 12px;
    }

    .chat-input button {
        padding: 14px 20px;
        font-size: 0.9em;
        border-radius: 12px;
        width: 100%;
    }

    /* Avatar responsive styling */
    .message-wrapper {
        margin: 8px 10px;
        gap: 8px;
        max-width: 92%;
    }
    
    .avatar {
        width: 28px;
        height: 28px;
    }
    
    .bot-avatar {
        padding: 3px;
    }

    .message {
        font-size: 0.9em;
        padding: 12px 16px;
        border-radius: 16px;
    }
    
    /* User messages - no avatar */
    .user-message-container {
        margin: 8px 10px;
    }
    
    .user-message {
        max-width: 90%;
        border-bottom-right-radius: 6px;
    }
    
    /* Bot messages - with avatar */
    .bot-message {
        max-width: calc(100% - 36px); /* Account for smaller avatar */
        border-bottom-left-radius: 6px;
    }
    
    /* Timestamp responsive styling */
    .timestamp {
        font-size: 0.7em;
        margin-top: 3px;
    }
    
    .user-timestamp {
        margin-right: 6px;
    }
    
    .bot-timestamp {
        margin-left: 6px;
    }
    
    /* Copy Button Mobile Styling */
    .copy-btn {
        padding: 4px 8px;
        font-size: 11px;
        border-radius: 16px;
        margin-top: 4px;
        gap: 4px;
    }
    
    .copy-icon {
        font-size: 12px;
    }
    
    .copy-text {
        font-size: 10px;
    }
    
    .user-message-container .copy-btn {
        margin-right: 6px;
    }
    
    .bot-message-content .copy-btn {
        margin-left: 6px;
    }
    
    /* Always show copy button on mobile (no hover) */
    .copy-btn {
        opacity: 1;
        transform: translateY(0);
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .user-message {
        border-bottom-right-radius: 6px;
    }
    
    .bot-message {
        border-bottom-left-radius: 6px;
    }
    
    .typing-indicator {
        max-width: calc(100% - 36px);
        padding: 10px 14px;
    }
    
    .typing-text {
        font-size: 0.85em;
    }
    
    .typing-dots span {
        width: 6px;
        height: 6px;
    }
}

/* Medium-Small Devices (577px to 650px) - Specific fix for your screen size */
@media (min-width: 577px) and (max-width: 650px) {
    .chat-header {
        padding: 18px 75px 18px 15px; /* More right padding for toggle */
    }
    
    .chat-header .logo {
        width: 30px;
        height: 30px;
    }
    
    .chat-header span {
        font-size: 0.95em;
        margin-left: 10px;
    }
    
    .theme-toggle {
        width: 48px;
        height: 24px;
        right: 15px;
    }
}

/* Small Devices (landscape phones, 576px to 768px) */
@media (min-width: 577px) and (max-width: 768px) {
    .chat-header {
        font-size: 1.2em;
        padding: 18px 70px 18px 18px; /* Extra right padding for toggle */
        gap: 12px;
        position: relative;
        justify-content: flex-start;
    }
    
    .chat-header .logo {
        width: 32px;
        height: 32px;
    }
    
    .chat-header span {
        flex: 1;
        text-align: left;
        margin-left: 8px;
        font-size: 1em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hide CODEX CHAT text on medium screens to prevent overlap */
    .chat-header::after {
        display: none;
    }
    
    /* Hide diamond shape on medium screens */
    .chat-header::before {
        display: none;
    }

    .theme-toggle {
        position: absolute;
        right: 18px;
        top: 50%;
        transform: translateY(-50%);
        width: 50px;
        height: 26px;
    }

    .chat-input {
        padding: 14px 18px;
        flex-direction: row;
    }

    .chat-input input {
        font-size: 0.95em;
        padding: 12px 16px;
        margin-right: 12px;
    }

    .chat-input button {
        padding: 12px 18px;
        font-size: 0.9em;
        min-width: 80px;
    }

    .message {
        max-width: 80%;
        font-size: 0.95em;
        padding: 12px 16px;
        margin: 8px 15px;
    }
    
    .chat-messages {
        padding: 16px;
    }
}

/* Medium Devices (tablets, 768px to 992px) */
@media (min-width: 769px) and (max-width: 992px) {
    .chat-header {
        font-size: 1.35em;
        padding: 22px 20px;
        gap: 14px;
    }
    
    .chat-header .logo {
        width: 38px;
        height: 38px;
    }

    .chat-input {
        padding: 16px 20px;
    }

    .chat-input input {
        font-size: 0.96em;
        padding: 12px 18px;
    }

    .chat-input button {
        padding: 12px 20px;
        font-size: 0.92em;
    }

    .message {
        max-width: 75%;
        font-size: 0.96em;
    }
}

/* Large Devices (desktops, 992px to 1200px) */
@media (min-width: 993px) and (max-width: 1200px) {
    .chat-container {
        max-width: 1000px;
        margin: 0 auto;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }
    
    .message {
        max-width: 70%;
    }
}

/* Extra Large Devices (large desktops, 1200px and up) */
@media (min-width: 1201px) {
    .chat-container {
        max-width: 1200px;
        margin: 0 auto;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.15);
        border-radius: 0 0 15px 15px;
    }
    
    .chat-header {
        border-radius: 0;
    }
    
    .message {
        max-width: 65%;
    }
    
    .chat-messages {
        padding: 25px;
    }
    
    .chat-input {
        padding: 20px 25px;
        border-radius: 0 0 15px 15px;
    }
}

/* Landscape Orientation for Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-header {
        padding: 12px 15px;
        font-size: 1.1em;
    }
    
    .chat-header .logo {
        width: 28px;
        height: 28px;
    }
    
    .chat-input {
        padding: 10px 15px;
    }
    
    .chat-input input, .chat-input button {
        padding: 10px 15px;
    }
    
    .message {
        padding: 8px 12px;
        margin: 4px 10px;
        font-size: 0.88em;
    }
    
    .chat-messages {
        padding: 10px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chat-header .logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .chat-header .logo,
    .chat-input button,
    .message {
        transition: none;
        animation: none;
    }
    
    .chat-header .logo:hover {
        transform: none;
    }
    
    .chat-input button:hover {
        transform: none;
    }
}

/* ========== THEME SYSTEM ========== */

/* Light Mode (Default) */
:root {
    --bg-primary: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    --bg-secondary: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --bg-messages: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --bg-input: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-placeholder: #6c757d;
    --border-color: #e9ecef;
    --border-input: #e9ecef;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --bot-message-bg: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --bot-message-text: #2c3e50;
    --input-bg: #ffffff;
    --scrollbar-track: #f1f1f1;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    --bg-secondary: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    --bg-messages: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    --bg-input: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --text-placeholder: #aaaaaa;
    --border-color: rgba(255, 107, 53, 0.3);
    --border-input: #4d4d4d;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.5);
    --bot-message-bg: linear-gradient(135deg, #3d3d3d 0%, #2d2d2d 100%);
    --bot-message-text: #ffffff;
    --input-bg: #3d3d3d;
    --scrollbar-track: #3d3d3d;
}

/* Apply theme variables */
body, html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    transition: background 0.3s ease;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
    transition: background 0.3s ease;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-messages);
    position: relative;
    transition: background 0.3s ease;
}

.bot-message {
    background: var(--bot-message-bg);
    color: var(--bot-message-text);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border-left: 3px solid #ff6b35;
    box-shadow: 0 2px 8px var(--shadow-light);
    transition: all 0.3s ease;
}

.chat-input {
    display: flex;
    padding: 15px 20px;
    background: var(--bg-input);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px var(--shadow-light);
    transition: all 0.3s ease;
}

.chat-input input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid var(--border-input);
    background-color: var(--input-bg);
    border-radius: 25px;
    outline: none;
    font-size: 0.95em;
    margin-right: 12px;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

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

/* Dark mode specific enhancements */
[data-theme="dark"] .chat-header {
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
}

[data-theme="dark"] .chat-messages::before {
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255, 107, 53, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(247, 147, 30, 0.08) 0%, transparent 50%);
}

[data-theme="dark"] .user-message {
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
}

[data-theme="dark"] .bot-avatar {
    background: linear-gradient(135deg, #3d3d3d 0%, #2d2d2d 100%);
    border-color: #ff6b35;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.2);
}

[data-theme="dark"] .chat-input button {
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
}

[data-theme="dark"] .chat-input button:hover {
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.5);
}

/* Scrollbar theming */
.chat-messages::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    border-radius: 3px;
}

[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #e55a2b 0%, #e0841a 100%);
}

/* Theme transition animations */
* {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease, 
                box-shadow 0.3s ease;
}

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

.typing-indicator {
    background: var(--bot-message-bg);
    color: var(--bot-message-text);
    border-radius: 12px;
    max-width: calc(100% - 42px); /* Account for avatar width + gap */
    border-left: 3px solid #ff6b35;
    box-shadow: 0 2px 8px var(--shadow-light);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-text {
    color: #ff6b35;
    font-weight: 500;
    font-size: 0.9em;
}

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

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #ff6b35;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
    opacity: 0.6;
}

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

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

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

@keyframes typingBounce {
    0%, 80%, 100% { 
        transform: scale(0.8) translateY(0px); 
        opacity: 0.5; 
    }
    40% { 
        transform: scale(1.2) translateY(-6px); 
        opacity: 1; 
        background: #f7931e;
    }
}

/* Dark mode typing indicator */
[data-theme="dark"] .typing-indicator {
    background: var(--bot-message-bg);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.2);
}

[data-theme="dark"] .typing-dots span {
    background: #ff6b35;
    box-shadow: 0 0 4px rgba(255, 107, 53, 0.3);
}

/* Responsive typing indicator */
@media (max-width: 576px) {
    .typing-indicator {
        max-width: 90%;
        padding: 10px 14px;
        margin: 6px 10px;
    }
    
    .typing-text {
        font-size: 0.85em;
    }
    
    .typing-dots span {
        width: 6px;
        height: 6px;
    }
}

/* Remove old media query */

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #e55a2b 0%, #e0841a 100%);
}