/* ==========================================
   MOOCOW Swarm Command Centre CSS System
   Futuristic Cyberpunk / Glassmorphic Theme
   ========================================== */

:root {
    --bg-base: #040605;
    --bg-sidebar: rgba(10, 15, 12, 0.6);
    --bg-card: rgba(20, 25, 22, 0.4);
    --bg-bubble-user: rgba(134, 184, 63, 0.15);
    --bg-bubble-ai: rgba(30, 35, 32, 0.65);
    
    --color-primary: #86b83f; /* MOOCOW Mint Green */
    --color-primary-glow: rgba(134, 184, 63, 0.35);
    --color-secondary-blue: #3f7bb8;
    --color-secondary-gold: #b89c3f;
    --color-text-main: #f3f5f4;
    --color-text-muted: #8e9591;
    --color-border: rgba(247, 244, 236, 0.07);
    --color-border-glow: rgba(134, 184, 63, 0.2);
    
    --font-header: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-base);
    color: var(--color-text-main);
    font-family: var(--font-body);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* --- Password Gate --- */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(4, 6, 5, 0.78);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.auth-gate.active {
    display: flex;
}

.auth-card {
    width: min(420px, 100%);
    border: 1px solid var(--color-border-glow);
    border-radius: 16px;
    background: rgba(10, 15, 12, 0.94);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52);
    padding: 30px;
}

.auth-mark {
    font-family: var(--font-header);
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 14px;
}

.auth-card h2 {
    font-family: var(--font-header);
    font-size: 26px;
    margin-bottom: 10px;
}

.auth-card p {
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.7;
    margin-bottom: 22px;
}

.auth-form {
    display: flex;
    gap: 10px;
}

.auth-form input {
    min-width: 0;
    flex: 1;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.26);
    color: var(--color-text-main);
    padding: 12px 14px;
    outline: none;
}

.auth-form input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(134, 184, 63, 0.12);
}

.auth-form button {
    border: none;
    border-radius: 10px;
    background: var(--color-primary);
    color: #061006;
    font-weight: 800;
    padding: 0 20px;
    cursor: pointer;
}

.auth-error {
    min-height: 18px;
    margin-top: 12px;
    color: #ff8f8f;
    font-size: 12px;
}

.main-wrapper.auth-locked {
    pointer-events: none;
    filter: blur(8px);
    transform: scale(1.01);
}

/* --- Abstract Animated Tech Background --- */
.tech-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.12;
}

#orb-1 {
    width: 600px;
    height: 600px;
    background-color: var(--color-primary);
    top: -150px;
    right: -100px;
    animation: orbMove 25s infinite alternate ease-in-out;
}

#orb-2 {
    width: 500px;
    height: 500px;
    background-color: var(--color-secondary-blue);
    bottom: -150px;
    left: -100px;
    animation: orbMove 30s infinite alternate-reverse ease-in-out;
}

@keyframes orbMove {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(80px, 80px) scale(1.15); }
}

.grid-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(134, 184, 63, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(134, 184, 63, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: -1;
}

/* --- Main Layout --- */
.main-wrapper {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}

/* --- Sidebar System --- */
.sidebar {
    width: 320px;
    height: 100%;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 32px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 10px var(--color-primary-glow));
}

.logo-text {
    font-family: var(--font-header);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #ffffff 30%, var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--color-text-muted);
    font-family: var(--font-header);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* --- Sidebar Section Title --- */
.section-title {
    font-family: var(--font-header);
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--color-border);
}

/* --- Agent Cards --- */
.agents-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.agent-card {
    background-color: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.agent-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background-color: transparent;
    transition: background-color 0.3s;
}

.agent-card:hover {
    background-color: rgba(30, 35, 32, 0.6);
    border-color: var(--color-border-glow);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.agent-card.active-agent {
    border-color: var(--color-primary-glow);
    background-color: rgba(134, 184, 63, 0.05);
}

.agent-card.active-agent::before {
    background-color: var(--color-primary);
}

.human-participant-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 2px;
}

.participant-card {
    min-height: 54px;
    cursor: default;
}

.participant-card .status-indicator {
    opacity: 0.35;
}

.participant-card.online .status-indicator {
    opacity: 1;
}

.avatar-glow {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
}

/* Specific glows for different roles */
.agent-card:hover .avatar-glow.writer { border-color: var(--color-secondary-blue); box-shadow: 0 0 10px rgba(63, 123, 184, 0.3); }
.agent-card:hover .avatar-glow.video { border-color: var(--color-secondary-gold); box-shadow: 0 0 10px rgba(184, 156, 63, 0.3); }
.agent-card:hover .avatar-glow.antigravity { border-color: var(--color-primary); box-shadow: 0 0 10px var(--color-primary-glow); }

.agent-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-name {
    font-family: var(--font-header);
    font-size: 14px;
    font-weight: 600;
}

.agent-role {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* --- Status Indicators --- */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #586561;
}

.status-indicator.live {
    background-color: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary);
}

.status-indicator.pulse {
    background-color: var(--color-primary);
    animation: indicatorPulse 2s infinite ease-in-out;
}

@keyframes indicatorPulse {
    0% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 var(--color-primary-glow); }
    70% { transform: scale(1.1); opacity: 0.9; box-shadow: 0 0 0 8px transparent; }
    100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 transparent; }
}

/* --- Services Monitor --- */
.services-section {
    background-color: rgba(10, 12, 10, 0.5);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.service-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.status-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.status-badge.online {
    background-color: rgba(134, 184, 63, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(134, 184, 63, 0.3);
}

.status-badge.offline {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text-muted);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.active-model-box {
    margin-top: 4px;
    font-size: 10px;
    color: var(--color-text-muted);
    background-color: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    border-left: 2px solid var(--color-primary);
}

/* --- Workspace Area --- */
.chat-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.workspace-header {
    height: 80px;
    border-bottom: 1px solid var(--color-border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(4, 6, 5, 0.4);
}

.chat-title {
    font-family: var(--font-header);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.room-status-badge {
    font-size: 11px;
    color: var(--color-primary);
    background-color: rgba(134, 184, 63, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    margin-top: 4px;
    display: inline-block;
    border: 1px solid rgba(134, 184, 63, 0.15);
}

/* --- Action Buttons --- */
.action-btn {
    font-family: var(--font-header);
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.trigger-btn {
    background: linear-gradient(135deg, var(--color-primary) 0%, #689030 100%);
    color: #040605;
    padding: 10px 20px;
    box-shadow: 0 4px 15px rgba(134, 184, 63, 0.25);
}

.trigger-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(134, 184, 63, 0.4);
}

.clear-btn {
    width: 100%;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.clear-btn:hover {
    background-color: rgba(255, 87, 87, 0.08);
    color: #ff5757;
    border-color: rgba(255, 87, 87, 0.2);
}

/* --- Messages Window --- */
.chat-messages-container {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages-container::-webkit-scrollbar { width: 6px; }
.chat-messages-container::-webkit-scrollbar-track { background: transparent; }
.chat-messages-container::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.05); border-radius: 10px; }
.chat-messages-container::-webkit-scrollbar-thumb:hover { background: rgba(134, 184, 63, 0.2); }

/* --- Chat Bubbles --- */
.chat-bubble-row {
    display: flex;
    gap: 16px;
    max-width: 80%;
    animation: bubbleEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes bubbleEnter {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.chat-bubble-row.user-bubble {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-bubble-row.ai-bubble {
    align-self: flex-start;
}

.bubble-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    align-self: flex-end;
}

.bubble-content-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bubble-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

.user-bubble .bubble-header {
    flex-direction: row-reverse;
}

.bubble-sender {
    font-family: var(--font-header);
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Vibrant Agent-Specific Color Coding for Legibility */
.user-bubble .bubble-sender {
    color: #a4e04b; /* MOOCOW Mint Light Green */
    text-shadow: 0 0 10px rgba(164, 224, 75, 0.3);
}

.writer-bubble .bubble-sender {
    color: #52a1ff; /* Creative Blue */
    text-shadow: 0 0 10px rgba(82, 161, 255, 0.3);
}

.video-bubble .bubble-sender {
    color: #f5cf5f; /* Cinematic Gold */
    text-shadow: 0 0 10px rgba(245, 207, 95, 0.3);
}

.antigravity-bubble .bubble-sender {
    color: #8ce63c; /* Tech Mint Green */
    text-shadow: 0 0 10px rgba(140, 230, 60, 0.3);
}

.system-bubble .bubble-sender {
    color: #a0a6a2; /* Soft Muted System Gray */
}

.bubble-role-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    display: inline-block;
    vertical-align: middle;
}

/* Glassmorphic Agent Role Badges */
.user-bubble .bubble-role-badge {
    background-color: rgba(164, 224, 75, 0.12);
    color: #a4e04b;
    border: 1px solid rgba(164, 224, 75, 0.2);
}

.writer-bubble .bubble-role-badge {
    background-color: rgba(82, 161, 255, 0.12);
    color: #52a1ff;
    border: 1px solid rgba(82, 161, 255, 0.2);
}

.video-bubble .bubble-role-badge {
    background-color: rgba(245, 207, 95, 0.12);
    color: #f5cf5f;
    border: 1px solid rgba(245, 207, 95, 0.2);
}

.antigravity-bubble .bubble-role-badge {
    background-color: rgba(140, 230, 60, 0.12);
    color: #8ce63c;
    border: 1px solid rgba(140, 230, 60, 0.2);
}

.system-bubble .bubble-role-badge {
    background-color: rgba(255, 255, 255, 0.05);
    color: #a0a6a2;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.bubble-time {
    color: rgba(255, 255, 255, 0.2);
}

.bubble-body {
    background-color: var(--bg-bubble-ai);
    border: 1px solid var(--color-border);
    border-radius: 16px 16px 16px 4px;
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-all;
    white-space: pre-wrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* User Bubble Styles Override */
.user-bubble .bubble-body {
    background-color: var(--bg-bubble-user);
    border-color: var(--color-border-glow);
    border-radius: 16px 16px 4px 16px;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(134, 184, 63, 0.05);
}

/* AI Bubble Highlights based on Sender */
.ai-bubble.writer-bubble .bubble-body {
    border-left: 3px solid var(--color-secondary-blue);
}
.ai-bubble.video-bubble .bubble-body {
    border-left: 3px solid var(--color-secondary-gold);
}
.ai-bubble.antigravity-bubble .bubble-body {
    border-left: 3px solid var(--color-primary);
}

/* Code Highlights inside Bubbles */
.bubble-body code {
    background-color: rgba(0, 0, 0, 0.4);
    font-family: monospace;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--color-primary);
    font-size: 13px;
}

.bubble-body pre {
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.bubble-body pre code {
    background-color: transparent;
    padding: 0;
    color: #a9ff3b;
    font-size: 12px;
}

/* --- Typing Indicator --- */
.typing-indicator {
    padding: 0 32px 16px 32px;
    align-self: flex-start;
}

.typing-bubble {
    background-color: var(--bg-bubble-ai);
    border: 1px solid var(--color-border);
    border-radius: 12px 12px 12px 4px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.typing-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-primary);
}

.dots-container {
    display: flex;
    gap: 4px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-primary);
    animation: dotBounce 1.4s infinite ease-in-out both;
}

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

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

/* --- Input Area --- */
.chat-input-area {
    padding: 24px 32px 32px 32px;
    border-top: 1px solid var(--color-border);
    background-color: rgba(4, 6, 5, 0.6);
}

/* Quick Action Tags */
.quick-tags-container {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.quick-tags-container::-webkit-scrollbar { display: none; }

.quick-tag {
    font-size: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    color: var(--color-text-muted);
}

.quick-tag:hover {
    background-color: rgba(134, 184, 63, 0.08);
    border-color: var(--color-primary-glow);
    color: var(--color-primary);
    transform: translateY(-1px);
}

/* Input Form Box */
.input-form {
    display: flex;
    gap: 16px;
    background-color: rgba(10, 12, 10, 0.8);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 12px 16px;
    transition: all 0.3s;
    position: relative;
}

.input-form:focus-within {
    border-color: var(--color-primary-glow);
    box-shadow: 0 0 15px rgba(134, 184, 63, 0.1);
}

.chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text-main);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 150px;
}

.chat-textarea::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.mention-suggest {
    position: absolute;
    left: 66px;
    right: 66px;
    bottom: calc(100% + 10px);
    display: none;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--color-border-glow);
    border-radius: 12px;
    background: rgba(10, 15, 12, 0.98);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
    padding: 8px;
    z-index: 200;
}

.mention-suggest.active {
    display: block;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 9px;
    cursor: pointer;
    color: var(--color-text-main);
}

.mention-item:hover,
.mention-item.active {
    background: rgba(134, 184, 63, 0.12);
}

.mention-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    overflow: hidden;
}

.mention-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mention-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mention-name {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-role {
    color: var(--color-text-muted);
    font-size: 11px;
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background-color: var(--color-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.send-btn:hover {
    background-color: #9cd44c;
    transform: scale(1.05);
}

.send-icon {
    font-size: 16px;
    color: #040605;
    font-weight: 700;
}

/* --- Mobile LAN Sync Sidebar Component --- */
.mobile-sync-card {
    background-color: rgba(10, 12, 10, 0.5);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

.mobile-sync-card:hover {
    border-color: var(--color-border-glow);
    box-shadow: 0 4px 15px rgba(134, 184, 63, 0.05);
}

.qr-container {
    width: 100%;
    aspect-ratio: 1;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.qr-container img {
    width: 80%;
    height: 80%;
    border-radius: 6px;
    border: 4px solid #0a0f0c; /* Matches custom QR code bgcolor */
    box-shadow: 0 0 15px var(--color-primary-glow);
    animation: qrFadeIn 0.5s ease-out;
}

@keyframes qrFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.qr-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--color-text-muted);
}

.pulse-ring {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    animation: ringPulse 1.5s infinite ease-out;
}

@keyframes ringPulse {
    0% { transform: scale(0.6); opacity: 1; box-shadow: 0 0 0 0 var(--color-primary-glow); }
    100% { transform: scale(1.4); opacity: 0; box-shadow: 0 0 0 8px transparent; }
}

.qr-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
}

.qr-url-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qr-url-label {
    font-size: 9px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
}

.qr-url {
    font-size: 11px;
    font-family: monospace;
    color: var(--color-primary);
    word-break: break-all;
    user-select: all;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 4px 6px;
    border-radius: 4px;
    border: 1px solid rgba(134, 184, 63, 0.1);
}

.qr-hint {
    font-size: 10px;
    color: var(--color-text-muted);
    line-height: 1.4;
    margin-top: 2px;
}

/* Sync Toggle Group & Buttons */
.sync-toggle-group {
    display: flex;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 2px;
    margin-bottom: 4px;
}

.sync-toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 6px;
    font-size: 11px;
    font-family: var(--font-header);
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.sync-toggle-btn.active {
    background-color: rgba(134, 184, 63, 0.12);
    color: var(--color-primary);
    box-shadow: inset 0 0 8px rgba(134, 184, 63, 0.1);
}

.sync-toggle-btn:hover:not(.active) {
    color: var(--color-text-main);
    background-color: rgba(255, 255, 255, 0.02);
}

/* Custom Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(134, 184, 63, 0.3);
}

/* Mobile Responsive Styling (Adaptive Chat Layout) */
@media (max-width: 768px) {
    .main-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        display: none; /* Hide PC sidebar on mobile browsers to let chat fill screen */
    }
    
    .chat-workspace {
        height: 100vh;
        height: 100dvh;
        width: 100vw;
    }
    
    .workspace-header {
        height: calc(70px + env(safe-area-inset-top, 0px));
        padding: env(safe-area-inset-top, 0px) 16px 0 16px;
        display: flex;
        align-items: center;
    }
    
    .chat-title {
        font-size: 15px;
    }
    
    .chat-messages-container {
        padding: 16px;
        gap: 16px;
    }
    
    .chat-bubble-row {
        max-width: 90%;
    }
    
    .bubble-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .bubble-body {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .chat-input-area {
        padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)) 16px;
    }
    
    .quick-tags-container {
        gap: 8px;
        margin-bottom: 10px;
    }
    
    .quick-tag {
        font-size: 11px;
        padding: 4px 10px;
    }
    
    .input-form {
        padding: 8px 12px;
        gap: 12px;
    }
    
    .chat-textarea {
        font-size: 13px;
    }
    
    .send-btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }
    
    .send-icon {
        font-size: 14px;
    }
}

/* --- Profile Drawer System (Sleek Blur Overlay & Sliding Panel) --- */
.profile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 9999;
    display: flex;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.profile-drawer {
    width: 420px;
    height: 100%;
    background: rgba(10, 15, 12, 0.95);
    border-left: 1px solid var(--color-border);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    padding: 30px;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-drawer-overlay.active .profile-drawer {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--color-border);
}

.drawer-header h3 {
    font-family: var(--font-header);
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text-main);
}

.close-drawer-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

.close-drawer-btn:hover {
    color: var(--color-primary);
}

.drawer-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.profile-preview-area {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    padding: 16px;
    border-radius: 16px;
}

.preview-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 15px var(--color-primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    overflow: hidden;
}

.preview-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-meta h4 {
    font-family: var(--font-header);
    font-size: 18px;
    color: var(--color-text-main);
}

.preview-meta span {
    font-size: 12px;
    color: var(--color-text-muted);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.form-group input[type="text"] {
    background: rgba(20, 25, 22, 0.8);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--color-text-main);
    font-family: var(--font-body);
    font-size: 14px;
    transition: all 0.3s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary-glow);
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    background: rgba(20, 25, 22, 0.5);
    border: 1px solid var(--color-border);
    padding: 12px;
    border-radius: 12px;
}

.picker-emoji {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    padding: 6px;
    transition: all 0.2s;
}

.picker-emoji:hover {
    background: rgba(255, 255, 255, 0.05);
}

.picker-emoji.selected {
    background: var(--color-primary-glow);
    border: 1px solid var(--color-primary);
}

.custom-avatar-upload {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 5px;
}

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--color-border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text-muted);
    transition: all 0.3s;
}

.upload-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(134, 184, 63, 0.03);
}

.upload-status {
    font-size: 11px;
    color: var(--color-primary);
    text-align: center;
}

.save-profile-btn {
    margin-top: auto;
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
}

/* Mobile adjustments for Drawer */
@media (max-width: 480px) {
    .profile-drawer {
        width: 100%;
        padding: 20px;
    }
}

/* --- Top Header Avatar Button (Mobile Friendly Profile Trigger) --- */
.header-avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    padding: 0;
}

.header-avatar-btn:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 12px var(--color-primary-glow);
    transform: scale(1.05);
}

.header-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* --- Sleek Input Attachments --- */
.attach-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.attach-btn:hover {
    border-color: var(--color-primary);
    background: rgba(134, 184, 63, 0.05);
    transform: scale(1.03);
}

.attach-icon {
    font-size: 20px;
    color: var(--color-text-muted);
    transition: color 0.3s;
}

.attach-btn:hover .attach-icon {
    color: var(--color-primary);
}

/* --- Attachment Drop-up Menu --- */
.attachment-menu {
    position: absolute;
    bottom: 90px;
    left: 48px; /* Perfectly aligned with the desktop attach button (32px padding + 16px form padding) */
    background: rgba(15, 20, 17, 0.95);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transform: translateY(15px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.attachment-menu.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.menu-item:hover {
    background: rgba(134, 184, 63, 0.08);
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.menu-icon {
    font-size: 22px;
}

.menu-label {
    font-size: 10px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* --- Attached File/Media Renderers --- */
.chat-attached-image {
    max-width: 100%;
    max-height: 280px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.3s;
    display: block;
}

.chat-attached-image:hover {
    transform: scale(1.02);
}

.chat-attached-video {
    max-width: 100%;
    max-height: 280px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    margin-top: 8px;
    background: #000;
    display: block;
}

.chat-attached-audio {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px 16px;
    margin-top: 8px;
    width: 100%;
    max-width: 460px;
}

.chat-attached-audio .audio-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-attached-audio .file-icon {
    font-size: 24px;
}

.chat-attached-audio .file-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-attached-audio .file-size {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-left: auto;
    flex-shrink: 0;
}

.chat-attached-audio audio {
    width: 100%;
}

.chat-attached-file {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px 16px;
    margin-top: 8px;
    width: 100%;
    max-width: 350px;
}

.chat-attached-file .file-icon {
    font-size: 28px;
}

.chat-attached-file .file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-attached-file .file-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-attached-file .file-size {
    font-size: 11px;
    color: var(--color-text-muted);
}

.chat-attached-file .file-download-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary-glow);
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-attached-file .file-download-btn:hover {
    background: var(--color-primary);
    color: #040605;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .attachment-menu {
        left: 28px; /* Perfectly aligned with mobile attach button (16px padding + 12px form padding) */
        bottom: 82px; /* Floats beautifully directly above the plus button */
        flex-direction: column; /* Stacks vertically for space efficiency on mobile screen */
        gap: 8px;
        padding: 8px;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    }
}
