/* style.css */
@import url('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/atom-one-dark.min.css'); /* Changed highlight theme */

:root {
  /* ===== Premium Black & White Theme - Light Mode ===== */
  --bg-color-light: #FDFDFD; /* Slightly off-white */
  --card-bg-light: #FFFFFF;
  --text-primary-light: #18181B; /* Near black */
  --text-secondary-light: #52525B; /* Dark grey */
  --border-color-light: #E4E4E7; /* Light grey border */
  --accent-gradient-light: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%); /* Premium blue gradient */
  --accent-static-light: #0ea5e9; /* Static accent for small elements - blue */
  --user-msg-bg-light: var(--accent-static-light); /* User bubble uses static accent */
  --user-msg-text-light: #FFFFFF;
  --ai-msg-bg-light: transparent; /* Removed background for AI messages */
  --input-bg-light: #F9FAFB; /* Input field background */
  --shadow-color-light: rgba(0, 0, 0, 0.05);
  --shadow-strong-color-light: rgba(0, 0, 0, 0.1);
  --scrollbar-thumb-light: #D4D4D8;
  --code-bg-light: #F4F4F5;

  /* Gaussian Blur Colors - Light */
  --blur-color-1-light: rgba(165, 200, 255, 0.3); /* Soft Blue */
  --blur-color-2-light: rgba(255, 190, 230, 0.3); /* Soft Pink */


  /* ===== Premium Black & White Theme - Dark Mode ===== */
  --bg-color-dark: #09090B; /* Very dark grey / near black */
  --card-bg-dark: #18181B; /* Dark card background */
  --text-primary-dark: #F9FAFB; /* Light grey / off-white */
  --text-secondary-dark: #A1A1AA; /* Lighter grey */
  --border-color-dark: #27272A; /* Dark border */
  --accent-gradient-dark: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%); /* Brighter blue gradient for dark */
  --accent-static-dark: #06b6d4; /* Static accent for dark - cyan */
  --user-msg-bg-dark: var(--accent-static-dark); /* User bubble uses static accent */
  --user-msg-text-dark: #18181B; /* Dark text on light accent */
  --ai-msg-bg-dark: transparent; /* Removed background for AI messages */
  --input-bg-dark: #27272A; /* Input field background */
  --shadow-color-dark: rgba(0, 0, 0, 0.2);
  --shadow-strong-color-dark: rgba(0, 0, 0, 0.3);
  --scrollbar-thumb-dark: #3F3F46;
  --code-bg-dark: #18181B;

  /* Gaussian Blur Colors - Dark */
  --blur-color-1-dark: rgba(243, 196, 9, 0.25); /* Muted Indigo */
  --blur-color-2-dark: rgba(247, 163, 7, 0.2); /* Muted Teal */


  /* ===== General Variables ===== */
  --sidebar-width: 280px;
  --border-radius-small: 6px;
  --border-radius-medium: 10px; /* Login elements */
  --border-radius-large: 16px;
  --border-radius-xl: 20px;   /* Login container */
  --border-radius-bubble: 18px; /* Chat bubbles */
  --transition-fast: 0.2s ease-in-out; /* Slightly slower for smoother feel */
  --transition-medium: 0.3s ease-in-out;
  --font-family: 'Inter', sans-serif;
  --tail-size: 8px;
  --modal-backdrop-opacity: 0.5;

    /* Premium Blue Theme */
    --primary-bg: #0a0e1a;
    --secondary-bg: #1a1f35;
    --accent-blue: #0ea5e9;
    --accent-cyan: #06b6d4;
    --blue-gradient: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 50%, #06b6d4 100%);
    --glass-bg: rgba(30, 58, 138, 0.15);
    --glass-border: rgba(59, 130, 246, 0.3);
    --glass-shadow: 0 8px 32px rgba(15, 23, 42, 0.5);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --button-gradient: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%);
    --card-hover: rgba(59, 130, 246, 0.2);
    --header-height: 80px;
}

/* Apply theme variables based on body class */
body.light-mode {
  background-color: var(--bg-color-light);
  color: var(--text-primary-light);
  --current-bg-color: var(--bg-color-light);
  --current-card-bg: var(--card-bg-light);
  --current-text-primary: var(--text-primary-light);
  --current-text-secondary: var(--text-secondary-light);
  --current-border-color: var(--border-color-light);
  --current-accent-gradient: var(--accent-gradient-light);
  --current-accent-static: var(--accent-static-light);
  --current-user-msg-bg: var(--user-msg-bg-light);
  --current-user-msg-text: var(--user-msg-text-light);
  --current-ai-msg-bg: var(--ai-msg-bg-light);
  --current-input-bg: var(--input-bg-light);
  --current-shadow-color: var(--shadow-color-light);
  --current-shadow-strong: var(--shadow-strong-color-light);
  --current-scrollbar-thumb: var(--scrollbar-thumb-light);
  --current-code-bg: var(--code-bg-light);
  --current-blur-color-1: var(--blur-color-1-light);
  --current-blur-color-2: var(--blur-color-2-light);
  --current-modal-backdrop: rgba(0, 0, 0, var(--modal-backdrop-opacity));
}

body.dark-mode {
  background-color: var(--bg-color-dark);
  color: var(--text-primary-dark);
  --current-bg-color: var(--bg-color-dark);
  --current-card-bg: var(--card-bg-dark);
  --current-text-primary: var(--text-primary-dark);
  --current-text-secondary: var(--text-secondary-dark);
  --current-border-color: var(--border-color-dark);
  --current-accent-gradient: var(--accent-gradient-dark);
  --current-accent-static: var(--accent-static-dark);
  --current-user-msg-bg: var(--user-msg-bg-dark);
  --current-user-msg-text: var(--user-msg-text-dark);
  --current-ai-msg-bg: var(--ai-msg-bg-dark);
  --current-input-bg: var(--input-bg-dark);
  --current-shadow-color: var(--shadow-color-dark);
  --current-shadow-strong: var(--shadow-strong-color-dark);
  --current-scrollbar-thumb: var(--scrollbar-thumb-dark);
  --current-code-bg: var(--code-bg-dark);
  --current-blur-color-1: var(--blur-color-1-dark);
  --current-blur-color-2: var(--blur-color-2-dark);
  --current-modal-backdrop: rgba(10, 10, 15, var(--modal-backdrop-opacity));
}
/* --- Dark Mode Send Button Icon Fix --- */
body.dark-mode .send-btn:not(:disabled) i {
    color: white; /* Use the dark text color meant for the dark gradient button */
  }
/* --- Global Styles & Resets --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-family); }
html { scroll-behavior: smooth; }
body { height: 100vh; width: 100vw; margin: 0; overflow: hidden; transition: background-color var(--transition-medium), color var(--transition-medium); font-size: 15px; }
button { cursor: pointer; border: none; background: none; color: inherit; font-family: inherit; padding: 0; }
a { color: var(--current-accent-static); text-decoration: none; transition: color var(--transition-fast); }
a:hover { filter: brightness(1.2); text-decoration: underline; }
input, textarea { font-family: inherit; font-size: inherit; border: 1px solid var(--current-border-color); border-radius: var(--border-radius-medium); padding: 10px 14px; background-color: var(--current-input-bg); color: var(--current-text-primary); transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast); }
input:focus, textarea:focus { outline: none; border-color: var(--current-accent-static); box-shadow: 0 0 0 3px alpha(var(--current-accent-static), 0.3); }

/* Gradient Button Style */
.primary-gradient-btn {
    background: var(--current-accent-gradient);
    color: var(--current-user-msg-text); /* Assuming light text on gradient */
    border: none;
    transition: filter var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: 0 2px 5px alpha(var(--current-accent-static), 0.2);
}
.primary-gradient-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 10px alpha(var(--current-accent-static), 0.3);
}
body.dark-mode .primary-gradient-btn {
    color: var(--current-user-msg-text); /* Ensure contrast */
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; } /* Make track transparent */
::-webkit-scrollbar-thumb { background: var(--current-scrollbar-thumb); border-radius: 10px; border: 2px solid var(--current-bg-color); } /* Add border matching background */
::-webkit-scrollbar-thumb:hover { background: alpha(var(--current-text-secondary), 0.8); }


/* --- Login Page Styles --- */
.login-modal {
    position: fixed; inset: 0; background-image: url('ximage.jpeg'); background-size: cover; background-position: center;
    /* background-color: #1a1a1a; /* Removed/commented out as background image is used */
    display: flex; align-items: center; justify-content: center; /* Default: Center for mobile/stacked view */
    padding: 5vh 3vw;
    z-index: 1000; opacity: 1; visibility: visible; transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    background-color: rgba(26, 26, 26, 0.8); /* Added a semi-transparent overlay */
  }

.login-page-container {
    display: flex; align-items: stretch; max-width: 850px; width: 90%;
    border-radius: var(--border-radius-xl); box-shadow: 0 12px 35px var(--current-shadow-strong);
    overflow: hidden; max-height: 90vh; background-color: var(--current-card-bg); /* Card has background */
}

.login-branding {
    flex: 1; background: var(--current-accent-gradient); /* Apply gradient */ color: #FFFFFF; /* White text on gradient */
    padding: 50px 35px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
    border-radius: var(--border-radius-xl) 0 0 var(--border-radius-xl); position: relative; overflow: hidden;
}

.login-branding .login-logo { font-size: 2.8rem; margin-bottom: 15px; color: #FFFFFF; }
.login-branding h1 { font-size: 2.4rem; font-weight: 700; margin-bottom: 25px; color: #FFFFFF; }

.login-visuals-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px; /* Space between GIF and text */
    margin-bottom: 30px;
}

/* GIF Slideshow */
.login-gif-slideshow {
    width: 85%; max-width: 300px; aspect-ratio: 4 / 3;
    background-color: rgba(255, 255, 255, 0.1); border-radius: var(--border-radius-medium);
    overflow: hidden; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    position: relative; /* Context for absolute slides */
}
.gif-slide {
    position: absolute; inset: 0; opacity: 0;
    transition: opacity 0.8s ease-in-out; /* Smooth fade */
}
.gif-slide.active { opacity: 1; }
.gif-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  padding: 0;
  transform: scale(1.5); /* Always crop-zoom */
}

/* Animated Text */
.login-branding .animated-text {
    font-size: 1.1rem; height: 25px; overflow: hidden; position: relative; width: 100%;
}
.login-branding .animated-text span {
    position: absolute; width: 100%; left: 0;
    display: block; opacity: 0; transform: translateY(100%);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.login-branding .animated-text span.active { opacity: 1; transform: translateY(0); }
.login-branding .animated-text span.exiting { transform: translateY(-100%); } /* Animate out upwards */

.login-branding .tagline { font-size: 0.9rem; color: rgba(255, 255, 255, 0.9); margin-top: auto; padding-top: 20px;}

/* Login Form Styling */
.login-container {
  flex-basis: 400px; flex-shrink: 0; padding: 50px 40px;
  background-color: var(--current-card-bg);
  border-radius: 0 var(--border-radius-xl) var(--border-radius-xl) 0;
  display: flex; flex-direction: column; justify-content: center; overflow-y: auto;
}
.login-container h2 { margin-bottom: 25px; text-align: center; color: var(--current-text-primary); font-weight: 600; font-size: 1.4rem; }
.social-login p { color: var(--current-text-secondary); font-size: 0.85em; margin-bottom: 12px; text-align: center;}
.social-buttons { display: flex; gap: 15px; margin-bottom: 20px; }
.social-btn { flex: 1; display: flex; align-items: center; justify-content: center; padding: 11px; border-radius: var(--border-radius-medium); text-decoration: none; color: white; font-weight: 500; transition: filter var(--transition-fast), box-shadow var(--transition-fast); gap: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.social-btn:hover { filter: brightness(0.95); box-shadow: 0 2px 5px rgba(0,0,0,0.15); text-decoration: none; }
.google-btn { background-color: #DB4437; }
.facebook-btn { background-color: #4267B2; }
.divider { display: flex; align-items: center; text-align: center; color: var(--current-text-secondary); margin: 25px 0; font-size: 0.85em; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--current-border-color); }
.divider span { padding: 0 15px; }
.input-group { margin-bottom: 20px; }
.input-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 0.85em; color: var(--current-text-secondary); text-align: left; }
.input-group input { width: 100%; padding: 14px 16px; border: 1px solid var(--current-border-color); border-radius: var(--border-radius-medium); font-size: 0.95rem; background-color: var(--current-input-bg); color: var(--current-text-primary); }
.input-group input:focus { outline: none; border-color: var(--current-accent-static); box-shadow: 0 0 0 3px alpha(var(--current-accent-static), 0.3); }
.login-btn { width: 100%; padding: 14px; border-radius: var(--border-radius-medium); font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 10px; /* Gradient applied via class */ }
.login-error { color: #e53935; font-size: 0.9em; text-align: center; min-height: 18px; margin-bottom: 10px;}
.signup-prompt { font-size: 0.9em; color: var(--current-text-secondary); text-align: center; margin-top: 20px; }
.signup-prompt .signup-link { font-weight: 600; color: var(--current-accent-static); }

/* --- App Container --- */
.app-container { display: flex; height: 100vh; overflow: hidden; }

/* --- Sidebar --- */
.sidebar { width: var(--sidebar-width); background-color: var(--current-card-bg); display: flex; flex-direction: column; border-right: 1px solid var(--current-border-color); transition: background-color var(--transition-medium), border-color var(--transition-medium), transform var(--transition-medium); flex-shrink: 0; padding: 12px; gap: 12px; }
.sidebar-header, .sidebar-content, .sidebar-footer { background-color: var(--current-card-bg); border-radius: var(--border-radius-large); padding: 16px; transition: background-color var(--transition-medium); }
.sidebar-header { box-shadow: 0 2px 4px var(--current-shadow-color); }
.new-chat-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px; border-radius: var(--border-radius-medium); font-weight: 600; font-size: 0.95rem; /* Gradient applied via class */ }
.new-chat-btn i { font-size: 1.1em; }
.sidebar-content { flex: 1; overflow-y: auto; box-shadow: 0 2px 4px var(--current-shadow-color); }
.recent-chats h3 { font-size: 0.75rem; text-transform: uppercase; color: var(--current-text-secondary); margin-bottom: 12px; font-weight: 600; letter-spacing: 0.5px; padding-left: 4px; }
.chat-list { display: flex; flex-direction: column; gap: 6px; }
.chat-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: var(--border-radius-medium); cursor: pointer; transition: background-color var(--transition-fast); overflow: hidden; position: relative; }
.chat-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-grow: 1; margin-right: 10px; }
.chat-item:hover { background-color: alpha(var(--current-text-secondary), 0.1); }
.chat-item.active { background: var(--current-accent-gradient); color: var(--current-user-msg-text); font-weight: 500; }
.chat-item.active:hover { filter: brightness(1.1); }
.chat-item .delete-chat-btn { color: var(--current-text-secondary); background: none; border: none; padding: 4px; border-radius: 50%; cursor: pointer; opacity: 0; transition: opacity var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast); flex-shrink: 0; font-size: 0.9em; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.chat-item:hover .delete-chat-btn { opacity: 0.7; }
.chat-item .delete-chat-btn:hover { opacity: 1; color: #e53935; background-color: rgba(229, 57, 53, 0.1); }
.chat-item.active .delete-chat-btn { color: alpha(var(--current-user-msg-text), 0.7); }
.chat-item.active .delete-chat-btn:hover { color: var(--current-user-msg-text); background-color: rgba(255, 255, 255, 0.2); }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; box-shadow: 0 -2px 4px var(--current-shadow-color); }
.user-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-avatar { width: 36px; height: 36px; background: var(--current-accent-gradient); color: var(--current-user-msg-text); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1rem; flex-shrink: 0; border: 2px solid var(--current-card-bg); box-shadow: 0 1px 3px var(--current-shadow-color); }
#current-user { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--current-text-primary); }
.footer-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { background: none; border: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--current-text-secondary); transition: background-color var(--transition-fast), color var(--transition-fast); font-size: 1.1rem; }
.icon-btn:hover { background-color: alpha(var(--current-text-secondary), 0.1); color: var(--current-text-primary); }

/* --- Main Content --- */
.main-content { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; background-color: var(--current-bg-color); transition: background-color var(--transition-medium); position: relative; /* Needed for blur */ }

/* Gaussian Blur Background */
.blur-bg {
    position: absolute;
    width: 300px; /* Size of the blur blob */
    height: 300px;
    border-radius: 50%;
    filter: blur(100px); /* Adjust blur intensity */
    z-index: -1; /* Behind content */
    opacity: 0.7; /* Adjust opacity */
    transition: background-color 1s ease; /* Smooth color transition on theme change */
}
.blur-bg-1 {
    background-color: var(--current-blur-color-1);
    animation: moveBlur1 25s linear infinite alternate;
}
.blur-bg-2 {
    background-color: var(--current-blur-color-2);
    animation: moveBlur2 35s linear infinite alternate;
}

@keyframes moveBlur1 {
    0%   { transform: translate(10vw, 15vh) rotate(0deg) scale(1.2); }
    50%  { transform: translate(60vw, 70vh) rotate(180deg) scale(1.5); }
    100% { transform: translate(20vw, 5vh) rotate(360deg) scale(1.2); }
}
@keyframes moveBlur2 {
    0%   { transform: translate(80vw, 40vh) rotate(0deg) scale(1.4); }
    50%  { transform: translate(30vw, 10vh) rotate(-150deg) scale(1.1); }
    100% { transform: translate(70vw, 80vh) rotate(-360deg) scale(1.4); }
}


.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--current-border-color); background-color: alpha(var(--current-card-bg), 0.8); backdrop-filter: blur(8px); /* Blur effect on header */ flex-shrink: 0; position: sticky; top: 0; z-index: 10; /* Ensure header is above messages & blur */ }
.model-info { display: flex; align-items: center; gap: 12px; }
.model-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--current-border-color); }
.model-details { position: relative; }
.model-details h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 2px; max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--current-text-primary); }
.model-switcher-btn { display: inline-flex; align-items: center; gap: 6px; background-color: alpha(var(--current-text-secondary), 0.1); padding: 4px 10px; border-radius: var(--border-radius-medium); font-size: 0.85rem; font-weight: 500; color: var(--current-text-secondary); transition: background-color var(--transition-fast), color var(--transition-fast); }
.model-switcher-btn:hover { background-color: alpha(var(--current-text-secondary), 0.2); color: var(--current-text-primary); }
.model-switcher-btn i { font-size: 0.75rem; transition: transform var(--transition-fast); }
.model-switcher-btn.active i { transform: rotate(180deg); }
.model-dropdown { position: absolute; top: calc(100% + 8px); left: 0; min-width: 180px; background-color: var(--current-card-bg); border-radius: var(--border-radius-medium); border: 1px solid var(--current-border-color); box-shadow: 0 8px 20px var(--current-shadow-strong); padding: 6px; z-index: 20; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: opacity var(--transition-fast), visibility var(--transition-fast), transform var(--transition-fast); display: flex; flex-direction: column; gap: 4px; }
.model-dropdown.active { opacity: 1; visibility: visible; transform: translateY(0); }
.model-dropdown button { width: 100%; padding: 8px 12px; text-align: left; background-color: transparent; border: none; border-radius: var(--border-radius-small); font-size: 0.9rem; color: var(--current-text-primary); transition: background-color var(--transition-fast); }
.model-dropdown button:hover { background-color: alpha(var(--current-text-secondary), 0.1); }
.model-dropdown button.current-model { background: var(--current-accent-gradient); color: var(--current-user-msg-text); font-weight: 500; }
.model-dropdown button.current-model:hover { filter: brightness(1.1); }

/* Model option styling */
.model-option { display: flex; flex-direction: column; gap: 2px; }
.model-name { font-weight: 500; font-size: 0.9rem; }
.model-desc { font-size: 0.75rem; opacity: 0.8; font-weight: 400; }
.model-dropdown button.current-model .model-desc { opacity: 0.9; }
.header-actions { display: flex; gap: 8px; }

/* Chat Messages Area */
.chat-messages-container { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; }
.chat-messages { width: 100%; max-width: 850px; margin: 0 auto; display: flex; flex-direction: column; gap: 4px; padding-bottom: 20px; }
.welcome-message { text-align: center; max-width: 600px; margin: auto; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; background: alpha(var(--current-card-bg), 0.5); backdrop-filter: blur(5px); border-radius: var(--border-radius-large); }
.welcome-logo { width: 60px; height: 60px; margin-bottom: 20px; opacity: 0.8; }
.welcome-message h1 { font-size: 2rem; font-weight: 700; margin-bottom: 12px; color: var(--current-text-primary); }
.welcome-message h1 .highlight { color: var(--current-accent-static); }
.welcome-message p { color: var(--current-text-secondary); font-size: 1rem; margin-bottom: 25px; }
.quick-suggestions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.quick-suggestions button { background-color: var(--current-card-bg); border: 1px solid var(--current-border-color); padding: 8px 16px; border-radius: var(--border-radius-large); font-size: 0.9rem; font-weight: 500; transition: all var(--transition-fast); box-shadow: 0 1px 3px var(--current-shadow-color); color: var(--current-text-primary); }
.quick-suggestions button:hover { background-color: alpha(var(--current-text-secondary), 0.1); border-color: var(--current-accent-static); box-shadow: 0 3px 6px var(--current-shadow-color); transform: translateY(-1px); color: var(--current-accent-static); }
.message { display: flex; flex-direction: column; max-width: 100%; animation: fadeIn 0.4s ease-out; margin-bottom: 12px; }
.user-message { align-items: flex-end; } .ai-message { align-items: flex-start; }
.message-header { display: none; } /* Avatar/Name hidden */
.message-content-wrapper { display: inline-flex; align-items: flex-end; gap: 8px; max-width: 85%; position: relative; }
.message-content { padding: 10px 16px; border-radius: var(--border-radius-bubble); line-height: 1.5; font-size: 0.98rem; word-wrap: break-word; box-shadow: 0 1px 2px var(--current-shadow-color); position: relative; border: none; margin-top: 0; margin-bottom: var(--tail-size); transition: background-color var(--transition-medium), color var(--transition-medium); }
.user-message .message-content { background-color: var(--current-user-msg-bg); color: var(--current-user-msg-text); margin-right: var(--tail-size); }
.ai-message .message-content { 
    background-color: var(--current-ai-msg-bg); 
    color: var(--current-text-primary); 
    margin-left: var(--tail-size);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.1);
    font-size: 1rem;
    line-height: 1.6;
}

/* Hide chat bubble tails for AI messages for cleaner look */
.ai-message .message-content::after {
    display: none;
}

.message-content::after { content: ''; position: absolute; bottom: calc(0px - var(--tail-size) + 1px); width: 0; height: 0; border: var(--tail-size) solid transparent; transition: border-color var(--transition-medium); }
.user-message .message-content::after { right: calc(0px - var(--tail-size)); border-bottom-color: var(--current-user-msg-bg); border-right-width: 0; }
.ai-message .message-content::after { left: calc(0px - var(--tail-size)); border-bottom-color: var(--current-ai-msg-bg); border-left-width: 0; }
.tts-btn {
    background: var(--blue-gradient);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.tts-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Improve code formatting */
.message-content pre {
    background: rgba(30, 41, 59, 0.05);
    border-radius: 8px;
    margin: 12px 0;
    padding: 12px;
    overflow-x: auto;
    border-left: 3px solid var(--accent-blue);
}

.message-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
}

/* Improve message formatting */
.message-content p {
    margin-bottom: 0.8em;
}

.message-content ul, .message-content ol {
    margin-left: 1.5em;
    margin-bottom: 0.8em;
}

.message-content h1, .message-content h2, .message-content h3, .message-content h4 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    color: var(--accent-blue);
    font-weight: 600;
}

/* Input Area */
.input-area { padding: 12px 24px; background-color: transparent; flex-shrink: 0; }
.input-wrapper { display: flex; align-items: flex-end; background-color: var(--current-card-bg); border: 1px solid var(--current-border-color); border-radius: var(--border-radius-xl); padding: 8px 8px 8px 16px; box-shadow: 0 5px 15px var(--current-shadow-color); transition: all var(--transition-fast); position: relative; }
.input-wrapper:focus-within { border-color: var(--current-accent-static); box-shadow: 0 0 0 3px alpha(var(--current-accent-static), 0.3), 0 5px 15px var(--current-shadow-color); }
#input-text { flex: 1; border: none; outline: none; padding: 10px 0; resize: none; max-height: 150px; font-size: 1rem; line-height: 1.5; overflow-y: auto; background-color: transparent; color: var(--current-text-primary); margin-right: 12px; }
#input-text::placeholder { color: var(--current-text-secondary); opacity: 0.8; }
.input-actions { display: flex; align-items: center; gap: 6px; padding-bottom: 2px; }
.input-actions .icon-btn { width: 40px; height: 40px; color: var(--current-text-secondary); background-color: transparent; border-radius: var(--border-radius-medium); }
.input-actions .icon-btn:hover { background-color: alpha(var(--current-text-secondary), 0.1); color: var(--current-accent-static); }
.input-actions .icon-btn:active { transform: scale(0.95); }
.send-btn { 
    /* Gradient applied via class */
    background: var(--button-gradient);
    color: white;
}
.send-btn:disabled { background: var(--current-border-color) !important; /* Override gradient */ color: var(--current-text-secondary); cursor: not-allowed; opacity: 0.7; filter: none; box-shadow: none; }
.send-btn:disabled:hover { background: var(--current-border-color) !important; }
.attachment-preview-container {margin-bottom: 5px;border-radius: var(--border-radius-medium);background-color: alpha(var(--current-input-bg), 0.5); display: none; flex-wrap: wrap; gap: 8px; margin-top: 8px; padding: 5px; max-height: 100px; overflow-y: auto; }
.attachment-item {padding: 5px; display: flex; align-items: center; justify-content: center; position: relative; width: 50px; height: 50px; border-radius: var(--border-radius-small); overflow: hidden; border: 1px solid var(--current-border-color); background: var(--current-input-bg); flex-shrink: 0; } .attachment-item img { width: 100%; height: 100%; object-fit: cover; } .attachment-item .attachment-icon { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 20px; color: var(--current-text-secondary); } .attachment-item .remove-attachment { position: absolute; top: 2px; right: 2px; background: rgba(0, 0, 0, 0.6); color: white; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; font-size: 9px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity var(--transition-fast); } .attachment-item:hover .remove-attachment { opacity: 1; }
.input-footer { display: flex; justify-content: center; margin-top: 10px; } .input-footer p { font-size: 0.75rem; color: var(--current-text-secondary); text-align: center; }

/* Loading dots */
.loading-dots { display: flex; gap: 5px; padding: 15px 0; } .dot { width: 8px; height: 8px; background-color: var(--current-text-secondary); border-radius: 50%; animation: pulse 1.4s infinite ease-in-out both; } .dot:nth-child(1) { animation-delay: -0.32s; } .dot:nth-child(2) { animation-delay: -0.16s; } @keyframes pulse { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }
.attachment-icon .fa-spinner { /* Style for spinner */
    font-size: 18px;
}
.file-name-preview {
    font-size: 9px; /* Smaller font for preview name */
    color: var(--current-text-secondary);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Modal Styles */
.modal { position: fixed; inset: 0; background-color: var(--current-modal-backdrop); display: flex; align-items: center; justify-content: center; z-index: 1010; visibility: hidden; opacity: 0; transition: visibility 0s linear 0.2s, opacity var(--transition-medium); }
.modal.active { visibility: visible; opacity: 1; transition-delay: 0s; }
.modal-content { background-color: var(--current-card-bg); padding: 24px 30px; border-radius: var(--border-radius-large); width: 90%; max-width: 450px; box-shadow: 0 10px 30px var(--current-shadow-strong); transform: scale(0.95); opacity: 0; transition: transform var(--transition-medium), opacity var(--transition-medium); border: 1px solid var(--current-border-color); }
.modal.active .modal-content { transform: scale(1); opacity: 1; }
.modal-content h3 { margin-bottom: 20px; font-weight: 600; color: var(--current-text-primary); }
.modal-content input { width: 100%; margin-bottom: 20px; background-color: var(--current-input-bg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions button { padding: 10px 20px; border-radius: var(--border-radius-medium); font-weight: 500; transition: all var(--transition-fast); }
.secondary-btn { background: none; border: 1px solid var(--current-border-color); color: var(--current-text-primary); }
.secondary-btn:hover { background-color: alpha(var(--current-text-secondary), 0.1); border-color: var(--current-border-color); }

/* Microphone & Speech Feedback */
.mic-btn.active { color: #e53935; animation: micPulse 1.5s infinite ease-in-out; } @keyframes micPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
.speech-feedback { position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%); background: var(--current-accent-gradient); color: #FFFFFF; padding: 12px 25px; border-radius: 30px; display: none; align-items: center; gap: 15px; min-width: 220px; max-width: 80%; box-shadow: 0 5px 15px var(--current-shadow-strong); z-index: 1005; transition: background-color var(--transition-fast); } .speech-feedback.active { display: flex; } .speech-indicator { display: flex; align-items: flex-end; height: 24px; } .speech-wave { width: 3px; margin: 0 2px; background-color: #FFFFFF; border-radius: 3px; animation: wave 1.2s infinite ease-in-out; } .speech-wave:nth-child(2) { animation-delay: 0.1s; } .speech-wave:nth-child(3) { animation-delay: 0.2s; } .speech-wave:nth-child(4) { animation-delay: 0.3s; } .speech-wave:nth-child(5) { animation-delay: 0.4s; } @keyframes wave { 0%, 100% { height: 5px; } 50% { height: 20px; } }
/* new button */
/* --- Styling for the Galaxy Hub Link Button --- */
.sidebar-galaxy-link-container {
    padding: 5px 10px 10px 10px; /* Add some padding around the button */
    margin-bottom: 10px; /* Space below the button */
    border-bottom: 1px solid var(--border-color); /* Optional separator line */
}

#galaxy-hub-nav-link {
    display: flex;
    align-items: center;
    width: 100%; /* Make it take full width */
    padding: 12px 20px; /* Button padding */
    gap: 10px; /* Space between icon and text */
    border-radius: 10px; /* Match other sidebar items if possible */
    background-color: transparent; /* Default background */
    color: var(--text-color); /* Use theme text color */
    font-weight: 500;
    text-decoration: none;
    border: 1px solid black; /* Optional: add border for definition */
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    box-sizing: border-box; /* Include padding in width */
    cursor: pointer;
}

#galaxy-hub-nav-link i {
    font-size: 1.1em;
    width: 20px; /* Align icon */
    text-align: center;
    color: var(--primary-color); /* Use theme primary color */
}

#galaxy-hub-nav-link:hover,
#galaxy-hub-nav-link:focus { /* Add focus style for accessibility */
    background-color: var(--hover-bg-color); /* Use your theme's hover background */
    color: var(--primary-color); /* Highlight text on hover */
    border-color: var(--border-color); /* Optional: show border on hover */
    outline: none; /* Remove default focus outline if adding border/bg */
}

/* --- Mobile Responsiveness --- */
.mobile-menu-btn { 
  display: none; 
  align-items: center;
  justify-content: center;
  background: var(--current-card-bg);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  color: var(--current-text-primary);
  box-shadow: 0 2px 8px var(--current-shadow-color);
  z-index: 1200;
  position: relative;
  transition: background 0.2s, color 0.2s;
}
.mobile-menu-btn:active, .mobile-menu-btn:focus {
  background: var(--current-accent-static);
  color: #fff;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex !important;
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 1200;
    margin-right: 0;
    margin-left: 0;
    background: var(--current-card-bg);
    color: var(--current-text-primary);
    box-shadow: 0 2px 8px var(--current-shadow-color);
  }
  .header-actions {
    position: relative;
    min-width: 120px;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 8px;
  }
}

/* ======================================== */
/* === START: Mobile Responsiveness Update === */
/* ======================================== */

@media (max-width: 768px) {
    /* --- General Mobile Adjustments --- */
    html {
      font-size: 14.5px; /* Slightly smaller base font for mobile */
    }
  
    body {
      /* Ensure body takes full height for app container layout */
      height: 100vh;
      /* Prevent horizontal scrolling if something overflows unexpectedly */
      overflow-x: hidden;
    }
  
    .app-container {
      flex-direction: column;
      height: 100vh; /* Ensure app container takes full viewport height */
      width: 100vw; /* Ensure app container takes full viewport width */
      overflow: hidden; /* Prevent container itself from scrolling */
    }
  
    /* --- Mobile Sidebar --- */
    .sidebar {
      position: fixed; /* Fixed position for overlay effect */
      top: 0;
      left: 0;
      height: 100%; /* Full height */
      width: min(85vw, 300px); /* Responsive width, max 300px */
      z-index: 1100; /* Ensure sidebar is above everything else */
      transform: translateX(-105%); /* Start fully off-screen */
      transition: transform 0.3s ease-in-out; /* Smooth slide transition */
      border-right: 1px solid var(--current-border-color);
      box-shadow: 4px 0px 15px rgba(0, 0, 0, 0.1); /* Subtle shadow */
      display: flex; /* Keep flex direction */
      flex-direction: column;
      padding: 12px; /* Keep padding */
      
      gap: 12px; /* Keep gap */
      background-color: var(--current-card-bg); /* Ensure background */
      overflow-y: auto; /* Allow sidebar content to scroll if needed */
    }
  
    .sidebar.open {
      transform: translateX(0); /* Slide in */
    }
  
    /* Optional: Add an overlay behind the sidebar when open */
    body::after {
      content: '';
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background-color: rgba(0, 0, 0, 0.4); /* Dimming effect */
      z-index: 1090; /* Below sidebar, above content */
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
      pointer-events: none; /* Allow clicks through initially */
    }
  
    body.sidebar-open::after {
      opacity: 1;
      visibility: visible;
      pointer-events: auto; /* Enable click-to-close */
    }
  
    /* --- Mobile Header --- */
    .chat-header {
      padding: 10px 15px;
      position: sticky; /* Stick to top */
      top: 0;
      z-index: 100; /* Below sidebar overlay */
      background-color: alpha(var(--current-card-bg), 0.9); /* Slightly more solid */
      backdrop-filter: blur(5px); /* Reduce blur slightly if needed */
      border-bottom: 1px solid var(--current-border-color);
    }
  
    .model-avatar { width: 32px; height: 32px; }
    .model-details h2 { font-size: 1rem; max-width: 150px; /* Limit width */ }
    .model-switcher-btn { padding: 3px 8px; font-size: 0.8rem; }
    .header-actions .icon-btn { width: 36px; height: 36px; } /* Ensure consistent button size */
  
    .mobile-menu-btn {
       display: flex; /* Ensure it's displayed now controlled by JS */
       order: -1; /* Place menu button at the start of the header */
       margin-right: 10px; /* Add some space */
    }
  
    /* --- Mobile Main Content & Chat Area --- */
    .main-content {
      height: 100%; /* Fill the app container */
      width: 100%;
      display: flex;
      flex-direction: column;
      overflow: hidden; /* Prevent main content itself from scrolling */
    }
  
    .chat-messages-container {
      flex-grow: 1; /* Allow this container to take up remaining space */
      overflow-y: auto; /* Enable scrolling ONLY for messages */
      padding: 15px 10px; /* Adjust padding */
      -webkit-overflow-scrolling: touch; /* Smoother scrolling on iOS */
    }
  
    .chat-messages {
      max-width: 100%; /* Use full width */
      gap: 10px; /* Adjust message gap */
      padding-bottom: 5px; /* Reduce bottom padding slightly */
    }
  
    /* --- Mobile Welcome & Messages --- */
    .welcome-message {
        margin-top: 20px;
        padding: 25px 15px;
        border-radius: var(--border-radius-medium); /* Slightly smaller radius */
    }
    .welcome-logo { width: 45px; height: 45px; }
    .welcome-message h1 { font-size: 1.4rem; }
    .welcome-message p { font-size: 0.9rem; margin-bottom: 20px;}
    .quick-suggestions { gap: 8px; }
    .quick-suggestions button { font-size: 0.8rem; padding: 6px 10px;}
  
    .message {
      margin-bottom: 12px; /* Slightly more space between messages */
    }
    .message-content-wrapper {
      max-width: 90%; /* Keep max width */
    }
    .message-content {
      padding: 9px 14px;
      font-size: 0.92rem; /* Fine-tune message font size */
      border-radius: var(--border-radius-bubble);
      margin-bottom: var(--tail-size); /* Adjust based on tail size variable if needed */
    }
  
    /* Adjust tail position slightly if needed, ensure they align */
    .user-message .message-content { margin-right: var(--tail-size); }
    .ai-message .message-content { margin-left: var(--tail-size); }
  
    /* Ensure tails scale reasonably */
    .message-content::after {
      border-width: var(--tail-size);
      bottom: calc(0px - var(--tail-size) + 1px);
    }
    .user-message .message-content::after { right: calc(0px - var(--tail-size)); }
    .ai-message .message-content::after { left: calc(0px - var(--tail-size)); }
  
    .tts-btn {
        width: 26px; height: 26px; font-size: 0.85rem;
        /* Align button better with the message bubble bottom */
        margin-bottom: calc(var(--tail-size) + 2px);
        margin-left: 5px; /* Space from AI bubble */
    }
  
    /* Code Block Mobile */
    .code-block-wrapper { margin: 8px 0; } /* Reduce vertical margin */
    .code-block {
      padding: 10px 12px; /* Reduce padding */
      font-size: 0.85em; /* Slightly smaller code font */
    }
    .copy-code-btn {
      top: 6px; right: 6px; /* Adjust position */
      padding: 4px 8px; /* Smaller button */
      font-size: 0.75em;
    }
  
    /* --- Mobile Input Area --- */
    .input-area {
      padding: 10px 10px; /* Adjust padding */
      /* Add padding for safe area (notches, home bars) */
      padding-bottom: calc(30px + env(safe-area-inset-bottom));
      border-top: 1px solid var(--current-border-color);
      background-color: var(--current-card-bg);
      position: sticky; /* Stick to the bottom */
      bottom: 0;
      left: 0;
      width: 100%;
      z-index: 90; /* Above messages, below header if scrolling under */
      flex-shrink: 0; /* Prevent shrinking */
    }
  
    .input-wrapper {
      padding: 6px 8px 6px 12px; /* Adjust padding */
      border-radius: var(--border-radius-large);
    }
  
    #input-text {
      font-size: 0.95rem; /* Keep input font size readable */
      max-height: 100px; /* Limit expansion */
      padding: 8px 0; /* Adjust vertical padding */
    }
  
    .input-actions { gap: 4px; } /* Reduce gap */
    .input-actions .icon-btn {
      width: 38px; height: 38px; /* Slightly larger tap target */
      font-size: 1.1rem;
    }
    .send-btn { /* Ensure send button is easily tappable */
        width: 42px;
        height: 42px;
    }
  
    .attachment-preview-container {
        padding: 4px;
        max-height: 65px; /* Limit preview height */
    }
     .attachment-item {
         width: 45px; height: 45px;
     }
     .remove-attachment {
         width: 18px; height: 18px; font-size: 10px;
     }
     .attachment-icon { font-size: 18px; }
     .file-name-preview { font-size: 8px; }
  
  
    .input-footer p {
      font-size: 0.7rem; /* Smaller disclaimer */
      margin-top: 6px;
    }
  
    /* --- Gaussian Blur Mobile --- */
    .blur-bg {
      /* Option 1: Reduce intensity */
       width: 150px;
       height: 150px;
       filter: blur(50px);
       opacity: 0.4;
      /* Option 2: Disable completely for performance */
      /* display: none; */
    }
  }
  
  /* Refined small mobile styles (optional, add if needed) */
  @media (max-width: 400px) {
      html {
        font-size: 14px; /* Further reduce base font if needed */
      }
      .message-content {
        font-size: 0.9rem;
      }
       .chat-header {
          padding: 8px 10px;
      }
       .model-details h2 { font-size: 0.9rem; max-width: 120px; }
       .input-actions .icon-btn { width: 36px; height: 36px; font-size: 1rem; }
       .send-btn { width: 40px; height: 40px; }
  }
  
  
  /* ====================================== */
  /* === END: Mobile Responsiveness Update === */
  /* ====================================== */
  
  @media (max-width: 880px) { 
      .login-modal {
          justify-content: center; 
          padding: 5vh 3vw; 
        }
      .login-page-container { flex-direction: column; max-width: 450px; width: 95%; }
      .login-branding { border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0; padding: 40px 30px; }
      .login-container { flex-basis: auto; border-radius: 0 0 var(--border-radius-xl) var(--border-radius-xl); padding: 40px 30px; }
  }
  @media (min-width: 881px) { 
      .login-modal {
        justify-content: flex-end; 
        padding-right: 5vw;
        padding-left: 5vw; 
      }
    }
  @media (max-width: 480px) { 
      .login-branding { display: none; }
      .login-page-container {
        max-width: 95%;
        box-shadow: 0 8px 25px var(--current-shadow-strong);
      }
      .login-container {
        border-radius: var(--border-radius-xl);
        padding: 35px 25px; 
        flex-basis: auto;
      }
      .login-container h2 { font-size: 1.2rem; margin-bottom: 20px;}
      .social-buttons { flex-direction: column; gap: 10px; }
      .input-group input, .login-btn, .social-btn { padding: 12px 14px; font-size: 0.9rem;}
      .signup-prompt { font-size: 0.85em; }
  }
