/**
 * Chat Container and Message Styles
 * Witit - AI Image Generator
 */

/* Dynamic input section height - tracked by ResizeObserver in main.js */
:root {
    --input-section-height: 120px; /* Fallback for older browsers */
}

/* Chat Container */
.chat-container {
    flex: 1;
    min-height: 0;                /* Allow flex item to shrink and scroll properly */
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.chat-content {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;                      /* Fill available space for scrolling */
    justify-content: flex-end;    /* Anchor messages to bottom (iMessage style) */
    /* Dynamic padding based on actual input section height */
    padding-bottom: var(--input-section-height);
}

/* Spacer pushes messages to bottom when there are few messages.
   This pseudo-element grows to fill available space ABOVE messages,
   ensuring they appear just above the input bar instead of centered. */
.chat-content.has-messages::before {
    content: '';
    flex: 1 1 auto;   /* Grows to fill available space */
    min-height: 0;    /* Allows shrinking when messages overflow (scrolling) */
}

/* Use flex-start when has-messages since spacer handles positioning */
.chat-content.has-messages {
    justify-content: flex-start;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1; /* Take up available space for centering */
    text-align: center;
    padding: 40px;
}

/* Thread empty state - minimal height since header shows persona */
.empty-state.thread-empty {
    min-height: auto;
    padding: 20px;
}

/* When empty state is shown, center it in container */
.chat-content:has(.empty-state) {
    justify-content: center;      /* Center empty state vertically */
}

/* Fallback for browsers that don't support :has() */
.chat-content.has-empty-state {
    justify-content: center;      /* Center empty state vertically */
}

.empty-logo {
    width: 180px;
    height: auto;
    margin-bottom: 24px;
    animation: logoGlow 3s ease-in-out infinite, breathe 4s ease-in-out infinite;
}

/* Performance: Reduce empty logo animations on mobile */
@media (max-width: 768px) {
    .empty-logo {
        animation: breathe 4s ease-in-out infinite;  /* Keep only subtle breathe */
    }
}

@media (prefers-reduced-motion: reduce) {
    .empty-logo {
        animation: none !important;
    }
}

.empty-title {
    font-size: 20px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

.empty-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.4);
    max-width: 400px;
}

/* Messages */
.message {
    margin-bottom: 4px;
    position: relative;
    animation: messageSlideIn 0.3s ease-out forwards;
}

/* Remove margin from last message for tighter spacing to input */
.chat-content > .message:last-child,
.chat-content > .typing-indicator:last-child {
    margin-bottom: 0;
}

/* User Message Animation */
.message-user {
    animation: messageSlideIn 0.3s ease-out forwards;
}

/* AI Message Animation */
.message-ai {
    animation: messageSlideIn 0.35s ease-out forwards;
}

/* Message Completion Bounce - when streaming ends */
.message-ai.completed {
    animation: completionBounce 0.3s ease-out;
}

/* Performance: Skip animations for bulk-loaded messages (history) */
.message.no-animate,
.message.no-animate.message-user,
.message.no-animate.message-ai {
    animation: none !important;
}

/* Inline Action Buttons (Edit under user, Retry under AI) */
.user-actions,
.ai-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-top: 6px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.user-actions {
    justify-content: flex-end;
    align-items: center;
    order: -1;
    margin-top: 0;
}

.ai-actions {
    justify-content: flex-start;
    align-items: center;
}

.friend-message-meta .ai-actions {
    margin-top: 0;
}

.message:hover .user-actions,
.message:hover .ai-actions {
    opacity: 1;
}

.inline-action-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 4px 8px;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 10px;
    border-radius: 6px;
}

.inline-action-btn:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
}

.inline-action-btn.retry:hover {
    color: #00d4ff;
    background: rgba(0, 212, 255, 0.1);
}

.inline-action-btn.edit:hover {
    color: #ffc107;
    background: rgba(255, 193, 7, 0.1);
}

/* Listen (TTS) button styles */
.inline-action-btn.listen:hover {
    color: #a855f7;
    background: rgba(168, 85, 247, 0.1);
}

.inline-action-btn.listen.loading {
    opacity: 0.6;
    pointer-events: none;
    color: rgba(255, 255, 255, 0.5);
}

.inline-action-btn.listen.playing {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.inline-action-btn.listen.playing:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Info button styles (admin debug) */
.inline-action-btn.info:hover {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
}

.inline-action-btn svg {
    width: 12px;
    height: 12px;
}

.inline-action-btn span {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Message Images Grid */
.message-images {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.message-images.hidden {
    display: none;
}

.ai-content .message-images {
    margin-left: 0;
}

/* Toggle Images Button */
.message-toggle {
    margin-left: 48px;
    margin-top: 8px;
}

.toggle-images-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.toggle-images-btn:hover {
    color: rgba(255, 255, 255, 0.7);
}

.toggle-images-btn svg {
    width: 14px;
    height: 14px;
}

.ai-content .message-toggle {
    margin-left: 0;
    margin-top: 8px;
}

/* User Message Bubble (Right Side, iMessage Style) */
.message-user {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-user-bubble {
    max-width: 80%;
    width: fit-content;
    padding: 12px 16px;
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    border-radius: 18px 18px 4px 18px;
    font-size: 14px;
    line-height: 1.5;
    color: white;
    transition: all 0.2s ease;
}

.message-user-bubble:hover {
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.2);
}

.message-user-bubble .persona-mention {
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 6px;
    border-radius: 4px;
    margin: 0 1px;
}

/* AI Response Container */
.message-ai {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-start;
}

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

.ai-avatar img {
    width: 100%;
    height: 100%;
    max-width: 36px;
    max-height: 36px;
    object-fit: cover;
}

/* Default Wit avatar (witit-chat.webp) */
.ai-avatar:not(.persona-avatar) {
    padding: 4px;
}

.ai-avatar:not(.persona-avatar) img {
    object-fit: contain;
}

/* Persona avatars - full cover */
.ai-avatar.persona-avatar {
    padding: 0;
    background: transparent;
}

.ai-avatar.persona-avatar img {
    object-fit: cover;
    border-radius: 50%;
    max-width: 36px;
    max-height: 36px;
}

/* SVG placeholder avatars (persona-friend.svg, persona-utility.svg) */
.ai-avatar.persona-avatar img[src$=".svg"] {
    object-fit: contain;
    padding: 6px;
    background: rgba(255, 255, 255, 0.06);
}

.ai-content {
    flex: 1;
    min-width: 0;
}

.persona-name-tag {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
}

/* Message Response (Markdown Content) */
.message-response {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px 18px 18px 18px;
    font-size: 14px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.2s ease;
}

.message-response:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.message-response h1,
.message-response h2,
.message-response h3 {
    color: white;
    margin: 16px 0 8px 0;
}

.message-response h1:first-child,
.message-response h2:first-child,
.message-response h3:first-child {
    margin-top: 0;
}

.message-response h1 { font-size: 18px; }
.message-response h2 { font-size: 16px; }
.message-response h3 { font-size: 14px; }

.message-response p {
    margin: 8px 0;
}

.message-response ul,
.message-response ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-response li {
    margin: 4px 0;
}

.message-response code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

.message-response pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-response pre code {
    background: none;
    padding: 0;
}

.message-response table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.message-response th,
.message-response td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    text-align: left;
}

.message-response th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.message-response blockquote {
    border-left: 3px solid rgba(0, 212, 255, 0.5);
    margin: 12px 0;
    padding-left: 16px;
    color: rgba(255, 255, 255, 0.7);
}

.message-response strong {
    color: white;
}

.message-response hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 16px 0;
}

/* Streaming Cursor */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: rgba(0, 212, 255, 0.8);
    margin-left: 2px;
    animation: blink 0.8s ease-in-out infinite, cursorGlow 2s ease-in-out infinite;
    vertical-align: text-bottom;
}

/* Typing Indicator (iMessage style) */
.typing-indicator {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.typing-indicator .ai-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.typing-indicator .ai-avatar:not(.persona-avatar) {
    padding: 4px;
}

.typing-indicator .ai-avatar.persona-avatar {
    padding: 0;
    background: transparent;
}

.typing-indicator .ai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.typing-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.typing-name {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px 18px 18px 18px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        background: rgba(255, 255, 255, 0.4);
    }
    30% {
        transform: translateY(-6px);
        background: rgba(0, 212, 255, 0.8);
    }
}

/* Legacy Message Prompt (for loading states) */
.message-prompt {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #00d4ff 0%, #ff00aa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar svg {
    width: 18px;
    height: 18px;
    color: white;
}

.message-text {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 15px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

/* Responsive */
@media (max-width: 900px) {
    .message-images {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .message-images {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Inline Generated Images (persona-sent images in chat) */
.inline-generated-image {
    margin: 16px 0;
    max-width: 400px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.inline-generated-image img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.inline-generated-image img:hover {
    transform: scale(1.02);
    filter: brightness(1.1);
}

/* Persona Reaction Messages */
.message-ai.persona-reaction {
    margin-top: 16px;
    animation: messageSlideIn 0.35s ease-out forwards;
}

/* Responsive inline images */
@media (max-width: 600px) {
    .inline-generated-image {
        max-width: 100%;
    }
}

/* ==========================================
   Active Personas Bar (Chat Room) - iMessage Style
   ========================================== */

.active-personas-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 20px 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    flex-shrink: 0; /* Don't shrink in flex container */
}

.active-personas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.active-personas-list {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 0;
}

.active-personas-list-inner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.active-persona-avatar {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid rgba(30, 30, 35, 0.95);
    background: #2a2a2e;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: -12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.active-persona-avatar:first-child {
    margin-left: 0;
}

.active-persona-avatar:hover {
    transform: scale(1.08);
    z-index: 1;
    border-color: rgba(0, 212, 255, 0.6);
}

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

.active-persona-avatar .persona-initial {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 20px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    background: linear-gradient(135deg, #00d4ff 0%, #ff00aa 100%);
}

/* Kick button (X) on hover */
.active-persona-avatar .kick-btn {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid rgba(30, 30, 35, 0.95);
    color: white;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.active-persona-avatar:hover .kick-btn {
    opacity: 1;
}

.active-persona-avatar .kick-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Remove the old tooltip, now using name label below */
.active-persona-avatar::after {
    display: none;
}

/* Persona names label - iMessage style */
.active-personas-names {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================
   System Messages (entered/left chat)
   ========================================== */

.system-message {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 16px;
    margin: 16px 0;
    animation: messageSlideIn 0.3s ease-out forwards;
}

.system-message-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 8px 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
}

.system-message-content .persona-mini-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.system-message-content .persona-mini-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.system-message-content strong {
    color: rgba(255, 255, 255, 0.7);
}

/* Entered chat - cyan tint */
.system-message.entered .system-message-content {
    border-color: rgba(0, 212, 255, 0.2);
    background: rgba(0, 212, 255, 0.05);
}

/* Left chat - red tint */
.system-message.left .system-message-content {
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.05);
}

/* Wit Creation Notice - shown when images are created in Wit chat */
.wit-creation-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(136, 0, 255, 0.1) 100%);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 12px;
    margin: 8px 0;
}

.wit-creation-notice .notice-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wit-creation-notice .notice-icon svg {
    width: 22px;
    height: 22px;
    stroke: rgb(0, 212, 255);
}

.wit-creation-notice .notice-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wit-creation-notice .notice-text strong {
    color: white;
    font-size: 15px;
    font-weight: 600;
}

.wit-creation-notice .notice-text span {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
}

.wit-creation-notice .notice-text a {
    color: rgb(0, 212, 255);
    text-decoration: none;
    font-weight: 500;
}

.wit-creation-notice .notice-text a:hover {
    text-decoration: underline;
}

/* Group chat empty state intro */
.group-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.group-intro-avatars {
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-intro-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(30, 30, 35, 0.95);
    background: #2a2a2e;
    overflow: hidden;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   Image Consent Flow
   ========================================== */

/* Consent Popup Modal - Floating above input */
.consent-modal-overlay {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    animation: consentSlideUp 0.3s ease-out forwards;
}

@keyframes consentSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.consent-modal {
    background: rgba(30, 30, 35, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 20px 24px;
    min-width: 320px;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
}

.consent-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.consent-modal-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

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

.consent-modal-info {
    flex: 1;
    min-width: 0;
}

.consent-modal-title {
    font-size: 15px;
    font-weight: 600;
    color: white;
    margin-bottom: 2px;
}

.consent-modal-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.consent-modal-prompt {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
    max-height: 80px;
    overflow-y: auto;
}

.consent-modal-prompt::before {
    content: '"';
    color: rgba(0, 212, 255, 0.6);
    font-size: 18px;
    font-weight: 600;
    margin-right: 4px;
}

.consent-modal-prompt::after {
    content: '"';
    color: rgba(0, 212, 255, 0.6);
    font-size: 18px;
    font-weight: 600;
    margin-left: 4px;
}

.consent-modal-actions {
    display: flex;
    gap: 10px;
}

.consent-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.consent-btn-allow {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.consent-btn-allow:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    transform: scale(1.02);
}

.consent-btn-deny {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.consent-btn-deny:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

/* Consent System Messages */
.system-message.consent {
    margin: 20px 0;
}

.system-message.consent .system-message-content {
    padding: 10px 18px;
    font-size: 13px;
}

/* Waiting state - animated dots */
.system-message.consent.waiting .system-message-content {
    border-color: rgba(255, 193, 7, 0.3);
    background: rgba(255, 193, 7, 0.08);
    color: rgba(255, 193, 7, 0.9);
}

.consent-waiting-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 6px;
}

.consent-waiting-dots span {
    width: 4px;
    height: 4px;
    background: rgba(255, 193, 7, 0.8);
    border-radius: 50%;
    animation: consentDotPulse 1.4s ease-in-out infinite;
}

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

.consent-waiting-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes consentDotPulse {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Approved state - green checkmark */
.system-message.consent.approved .system-message-content {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.08);
    color: rgba(34, 197, 94, 0.9);
}

.system-message.consent.approved .consent-icon {
    color: #22c55e;
}

/* Denied state - red X */
.system-message.consent.denied .system-message-content {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
    color: rgba(239, 68, 68, 0.9);
}

.system-message.consent.denied .consent-icon {
    color: #ef4444;
}

.consent-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.consent-icon svg {
    width: 100%;
    height: 100%;
}

/* Mobile adjustments for consent modal */
@media (max-width: 480px) {
    .consent-modal-overlay {
        left: 16px;
        right: 16px;
        transform: none;
        bottom: 90px;
    }

    .consent-modal {
        min-width: auto;
        max-width: none;
        width: 100%;
    }
}

/* ============================================
   USER GROUP CHAT STYLES
   ============================================ */

/* User group chat header */
.chat-header.user-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(6, 6, 10, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.user-group-header .header-avatar-stack {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.user-group-header .header-avatar-stack:hover {
    transform: scale(1.05);
}

.user-group-header .header-info {
    flex: 1;
    cursor: pointer;
}

.user-group-header .header-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.user-group-header .header-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.user-group-header .header-settings {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.user-group-header .header-settings:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Persona guest message styling (AI responses in user groups) */
.message.message-persona-guest {
    margin-left: 12px;
}

.message.message-persona-guest .message-bubble {
    border: 1px solid transparent;
    background: linear-gradient(#1a1a2e, #1a1a2e) padding-box,
                linear-gradient(135deg, #00d4ff, #ff00aa) border-box;
    border-radius: 16px;
}

.persona-badge {
    font-size: 10px;
    background: linear-gradient(135deg, #00d4ff, #ff00aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-left: 4px;
    font-weight: 600;
}

/* Member panel slide-out */
.member-panel {
    position: fixed;
    right: -320px;
    top: 0;
    bottom: 0;
    width: 300px;
    background: rgba(10, 10, 14, 0.98);
    backdrop-filter: blur(12px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transition: right 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

.member-panel.open {
    right: 0;
}

.member-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.member-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.member-panel-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.member-panel-close:hover {
    color: #fff;
}

.member-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.member-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.member-name {
    flex: 1;
    font-size: 14px;
    color: #fff;
}

.member-item .online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

.member-panel-actions {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.member-panel-actions .btn-secondary,
.member-panel-actions .btn-danger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.member-panel-actions .btn-secondary {
    background: rgba(0, 212, 255, 0.1);
    color: #00d4ff;
}

.member-panel-actions .btn-secondary:hover {
    background: rgba(0, 212, 255, 0.2);
}

.member-panel-actions .btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.member-panel-actions .btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Group settings dropdown */
.group-settings-dropdown {
    background: rgba(20, 20, 28, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    min-width: 180px;
    z-index: 300;
}

.group-settings-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    text-align: left;
}

.group-settings-dropdown button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.group-settings-dropdown button.danger {
    color: #ef4444;
}

.group-settings-dropdown button.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Add member modal */
.add-member-modal {
    max-width: 320px;
    width: 90%;
}

.add-member-modal .friend-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}

.friend-add-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 8px;
    margin: 0 8px;
}

.friend-add-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.friend-add-item .friend-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.friend-add-item .friend-name {
    font-size: 14px;
    color: #fff;
}

/* User group empty state */
.empty-state.user-group-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    height: 100%;
}

.user-group-empty .group-intro-avatars {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.user-group-empty .group-intro-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(6, 6, 10, 0.98);
}

.user-group-empty .empty-hint {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.5;
}

/* System messages in user groups (member joined/left) */
.message-system {
    text-align: center;
    padding: 8px 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

/* Friend select grid styles moved to modal.css (unified-select-*) */
