/* ==========================================================================
   Chatterbox AI - Premium Modern Styling
   CSS Variables, Glassmorphism, Responsive UI
   ========================================================================== */

:root {
    /* Base configuration */
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --transition-speed: 0.3s;
    --border-radius: 16px;
    --border-radius-lg: 24px;

    /* Variables overridden by themes */
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);

    --text-main: #2d3748;
    --text-muted: #718096;
    --input-bg: rgba(255, 255, 255, 0.8);
    --sidebar-bg: rgba(255, 255, 255, 0.4);
    --hover-bg: rgba(255, 255, 255, 0.5);

    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-color: #667eea;

    --msg-mine-bg: var(--accent-gradient);
    --msg-mine-text: #ffffff;
    --msg-mine-radius: 18px 18px 4px 18px;

    --msg-yours-bg: rgba(255, 255, 255, 0.9);
    --msg-yours-text: #2d3748;
    --msg-yours-radius: 18px 18px 18px 4px;
}

body.dark-mode {
    --bg-gradient: linear-gradient(135deg, #09101a 0%, #172439 100%);
    --glass-bg: rgba(16, 24, 39, 0.5);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

    --text-main: #f7fafc;
    --text-muted: #a0aec0;
    --input-bg: rgba(16, 24, 39, 0.7);
    --sidebar-bg: rgba(16, 24, 39, 0.4);
    --hover-bg: rgba(255, 255, 255, 0.05);

    --accent-gradient: linear-gradient(135deg, #8ba4f9 0%, #9b72c9 100%);
    --accent-color: #8ba4f9;

    --msg-mine-bg: var(--accent-gradient);
    --msg-mine-text: #ffffff;

    --msg-yours-bg: rgba(30, 41, 59, 0.8);
    --msg-yours-text: #f7fafc;
}

/* ========================================= */
/* Global Resets & Typography                */
/* ========================================= */

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

body {
    font-family: var(--font-main);
    background: var(--bg-gradient);
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background var(--transition-speed), color var(--transition-speed);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
    opacity: 0.5;
}

/* ========================================= */
/* Animations & Layout                       */
/* ========================================= */

.hidden {
    display: none !important;
}

.slide-in {
    animation: slideIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.slide-up {
    animation: slideUp 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideIn {
    0% {
        transform: scale(0.95);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes slideUp {
    0% {
        transform: translateY(30px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

#app-container {
    width: 100%;
    height: 100%;
    max-width: 1400px;
    padding: 2vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--border-radius-lg);
    transition: all var(--transition-speed);
}

.primary-gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* ========================================= */
/* Login Section                             */
/* ========================================= */

#auth-section {
    width: 100%;
    max-width: 450px;
    padding: 40px;
    text-align: center;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.logo-icon {
    font-size: 48px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.input-group {
    position: relative;
    margin-bottom: 15px;
}

.input-group .material-icons {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 14px 15px 14px 45px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    color: var(--text-main);
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.primary-btn {
    background: var(--accent-gradient);
    color: white;
    margin-top: 20px;
}

.primary-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 25px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--glass-border);
}

.divider span {
    padding: 0 10px;
}

.google-btn {
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

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

.google-logo {
    width: 20px;
}

.error-msg {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: -5px;
    margin-bottom: 10px;
    text-align: left;
}


/* ========================================= */
/* Chat UI Application                       */
/* ========================================= */

.flex-container {
    display: flex;
    width: 100%;
    height: calc(100vh - 4vw);
    max-height: 900px;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 25px 20px 15px;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.group-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.group-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin-bottom: 5px;
    transition: background 0.2s;
    border: 1px solid transparent;
}

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

.group-item.active {
    background: var(--hover-bg);
    border-color: var(--glass-border);
    border-left: 4px solid var(--accent-color);
}

.emoji-container {
    font-size: 24px;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--glass-bg);
    border-radius: 50%;
    margin-right: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.group-info h3 {
    font-size: 15px;
    margin-bottom: 3px;
}

.group-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-color);
}

#user-name {
    font-size: 14px;
    font-weight: 500;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--hover-bg);
    color: var(--text-main);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--glass-bg);
    /* Extra distinct layer */
}

.chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.current-group h2 {
    font-size: 18px;
    margin-bottom: 5px;
}

.badge {
    font-size: 11px;
    padding: 3px 8px;
    background: var(--accent-gradient);
    color: white;
    border-radius: 12px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.ai-icon {
    font-size: 18px;
    color: var(--accent-color);
}

.glass-select {
    padding: 8px 12px;
    border-radius: 20px;
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    outline: none;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background: var(--accent-gradient);
}

input:checked+.slider:before {
    transform: translateX(16px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Messages */
.messages-container {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-mine {
    align-self: flex-end;
}

.message-yours {
    align-self: flex-start;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--text-muted);
}

.message-mine .message-header {
    flex-direction: row-reverse;
}

.message-bubble {
    padding: 12px 18px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    position: relative;
}

.message-mine .message-bubble {
    background: var(--msg-mine-bg);
    color: var(--msg-mine-text);
    border-radius: var(--msg-mine-radius);
}

.message-yours .message-bubble {
    background: var(--msg-yours-bg);
    color: var(--msg-yours-text);
    border-radius: var(--msg-yours-radius);
    border: 1px solid var(--glass-border);
}

.translation-box {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dotted rgba(255, 255, 255, 0.3);
    font-size: 14px;
    font-style: italic;
}

.message-yours .translation-box {
    border-top: 1px dotted rgba(0, 0, 0, 0.1);
}

/* Input Area */
.chat-input-area {
    padding: 20px 30px;
    border-top: 1px solid var(--glass-border);
    background: transparent;
}

#message-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-wrapper {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 5px 20px;
    display: flex;
    align-items: center;
}

#message-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 12px 0;
    color: var(--text-main);
    font-size: 15px;
    outline: none;
}

.primary-icon-btn {
    background: var(--accent-gradient);
    color: white;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.glow-effect:hover {
    box-shadow: 0 0 15px var(--accent-color);
}

/* Typing Indicator */
.typing-indicator {
    padding: 0 30px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 12px;
}

.dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent-color);
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .flex-container {
        height: 100vh;
        border-radius: 0;
        padding: 0;
    }

    .sidebar {
        display: none;
        /* In a real app we'd toggle this */
    }

    .header-actions .setting-group label {
        display: none;
        /* Hide text on mobile */
}

#messages {
  height: 600px;
  overflow-y: auto;
  padding: 20px;
}

.message-bubble {
  background: #6c63ff;
  color: white;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 10px;
  max-width: 60%;
}