/* ═══════════════════════════════════════════
   Zalo Chat Embed - Theme System
   ═══════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
    /* Colors - Deep Space Theme (Dark - Default) */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2035;
    --bg-surface: #1e2642;
    --bg-hover: #252d48;
    --bg-active: #2a3556;

    /* Accent */
    --accent-primary: #3b82f6;
    --accent-secondary: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    --accent-glow: 0 0 20px rgba(59, 130, 246, 0.3);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-inverse: #0f172a;

    /* Chat Bubbles */
    --bubble-sent: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --bubble-received: #1e293b;
    --quote-bg-sent: rgba(255, 255, 255, 0.15);
    --quote-bg-received: rgba(0, 0, 0, 0.25);

    /* Status */
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Borders */
    --border-subtle: rgba(148, 163, 184, 0.1);
    --border-medium: rgba(148, 163, 184, 0.15);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.15);

    /* Layout */
    --sidebar-width: 360px;
    --header-height: 64px;
    --input-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
    /* Colors - Light Theme */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f7fa;
    --bg-surface: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;

    /* Accent */
    --accent-primary: #0068ff;
    --accent-secondary: #00bcd4;
    --accent-gradient: linear-gradient(135deg, #0068ff 0%, #00bcd4 100%);
    --accent-glow: 0 0 20px rgba(0, 104, 255, 0.15);

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --text-inverse: #ffffff;

    /* Chat Bubbles */
    --bubble-sent: linear-gradient(135deg, #0068ff 0%, #0056d6 100%);
    --bubble-received: #f1f5f9;
    --quote-bg-sent: rgba(255, 255, 255, 0.2);
    --quote-bg-received: rgba(0, 0, 0, 0.05);

    /* Borders */
    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-medium: rgba(0, 0, 0, 0.1);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 30px rgba(0, 104, 255, 0.08);
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

#app {
    height: 100%;
    width: 100%;
    position: relative;
}

/* ─── Screens ─── */
.screen {
    display: none;
    height: 100%;
    width: 100%;
}

.screen.active {
    display: flex;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════ */
.login-container {
    margin: auto;
    text-align: center;
    padding: 40px;
    max-width: 440px;
    width: 100%;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.login-logo {
    margin-bottom: 32px;
}

.logo-icon {
    display: inline-flex;
    margin-bottom: 16px;
    filter: drop-shadow(var(--accent-glow));
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.3));
    }

    50% {
        filter: drop-shadow(0 0 25px rgba(59, 130, 246, 0.5));
    }
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
}

.qr-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: var(--transition-normal);
}

.qr-container.has-qr {
    background: white;
    padding: 16px;
}

.qr-container img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.qr-placeholder {
    text-align: center;
    color: var(--text-tertiary);
}

.qr-placeholder p {
    margin-top: 12px;
    font-size: 13px;
}

/* Spinner */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-medium);
    border-top-color: var(--accent-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

.spinner.small {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Primary Button */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--accent-glow), var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 18px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 24px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-normal);
    margin-top: 12px;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.login-hint {
    color: var(--text-tertiary);
    font-size: 12px;
    margin-top: 16px;
}

/* ═══════════════════════════════════════════
   CHAT SCREEN LAYOUT
   ═══════════════════════════════════════════ */
#chat-screen {
    flex-direction: row;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.sidebar-header-top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
}

.account-selector-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.account-select {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 16px;
    outline: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.account-select:focus {
    border-color: var(--accent-primary);
}

.icon-btn.success:hover {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
    color: white;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.user-details {
    min-width: 0;
}

.user-details h2 {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

.status-badge.connected {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.status-badge.disconnected {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.sidebar-actions {
    display: flex;
    gap: 4px;
    width: 100%;
    justify-content: space-between;
}

/* Icon Button */
.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.icon-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Search */
.search-container {
    padding: 12px 16px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-family);
    outline: none;
    transition: var(--transition-fast);
}

.search-input-wrapper input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-input-wrapper input::placeholder {
    color: var(--text-tertiary);
}

/* ─── Conversation List ─── */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

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

.conversation-item.active {
    background: var(--bg-active);
}

.conversation-item .conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
    color: var(--accent-primary);
}

.conversation-item .conv-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

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

.conv-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.conv-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    margin-left: 8px;
}

.conv-last-msg {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-unread {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 4px;
}

.empty-state small {
    font-size: 12px;
}

/* ─── Chat Main Area ─── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

/* Empty Chat State */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.chat-empty h3 {
    font-size: 20px;
    font-weight: 600;
    margin-top: 16px;
    color: var(--text-secondary);
}

.chat-empty p {
    color: var(--text-tertiary);
    font-size: 14px;
    margin-top: 8px;
    max-width: 300px;
}

/* Active Chat */
.chat-active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    min-height: var(--header-height);
}

.back-btn {
    display: none;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    color: var(--accent-primary);
}

.chat-header-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-info h3 {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    font-size: 12px;
    color: var(--text-tertiary);
}

.chat-header-actions {
    display: flex;
    gap: 4px;
}

.chat-header-group-client {
    margin-left: auto;
    margin-right: 8px;
    display: flex;
    align-items: center;
}

.group-client-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    color: #fbbf24;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.25);
    transition: all var(--transition-fast);
}

.group-client-toggle:hover {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.4);
}

.group-client-toggle input {
    cursor: pointer;
    accent-color: #fbbf24;
    width: 15px;
    height: 15px;
    margin: 0;
}

body.light-theme .group-client-toggle {
    background: #fef3c7;
    color: #b45309;
    border-color: #fde68a;
}

body.light-theme .group-client-toggle input {
    accent-color: #b45309;
}

/* ─── Messages Area ─── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.messages-loading {
    display: flex;
    justify-content: center;
    padding: 20px;
}

/* Message Bubbles */
.message-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.message-group.consecutive {
    margin-top: -6px;
}

.message-group.sent {
    align-items: flex-end;
}

.message-group.received {
    align-items: flex-start;
}

.message-sender {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    padding-left: 4px;
}

.message-sender.clickable-sender {
    cursor: pointer;
    transition: color 0.15s ease;
}

.message-sender.clickable-sender:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.message-bubble {
    /* max-width: 70%; */
    width: fit-content;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
    position: relative;
    animation: msgAppear 0.2s ease-out;
    white-space: pre-wrap;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

@keyframes msgAppear {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

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

.message-group.sent .message-bubble {
    background: var(--bubble-sent);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-group.received .message-bubble {
    background: var(--bubble-received);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    padding: 0 4px;
}

.message-group.sent .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.5);
}

/* Date Separator */
.date-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-tertiary);
    font-size: 12px;
}

.date-separator::before,
.date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

/* ─── Chat Input ─── */
.chat-input-area {
    position: relative;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
}

/* Sticker Picker Popover */
.sticker-picker {
    position: absolute;
    bottom: calc(100% - 4px);
    left: 20px;
    width: 320px;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    padding: 12px;
    animation: slideUp 0.15s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.sticker-picker-header {
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.sticker-picker-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.sticker-grid::-webkit-scrollbar {
    width: 6px;
}

.sticker-grid::-webkit-scrollbar-track {
    background: transparent;
}

.sticker-grid::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.sticker-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.sticker-item:hover {
    background: var(--bg-hover);
    transform: scale(1.08);
}

.sticker-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Custom Sticker Message inside Bubble */
.message-bubble.sticker-message {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.message-bubble.sticker-message img {
    max-width: 120px;
    max-height: 120px;
    display: block;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 4px 4px 4px 16px;
    transition: var(--transition-fast);
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-family);
    resize: none;
    outline: none;
    padding: 8px 0;
    max-height: 120px;
    line-height: 1.5;
}

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

.btn-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: var(--accent-glow);
}

.btn-send:active {
    transform: scale(0.95);
}

/* ═══════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-family);
    outline: none;
    margin-bottom: 12px;
    transition: var(--transition-fast);
}

.modal-body input:focus {
    border-color: var(--accent-primary);
}

.modal-body input::placeholder {
    color: var(--text-tertiary);
}

.contact-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.contact-item .contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--accent-secondary);
    flex-shrink: 0;
}

.contact-item .contact-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.contact-item .contact-info {
    flex: 1;
    min-width: 0;
}

.contact-item .contact-name {
    font-size: 14px;
    font-weight: 500;
}

.contact-item .contact-phone {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease-out;
    max-width: 360px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--accent-primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    #chat-screen {
        position: relative;
    }

    .sidebar {
        position: absolute;
        inset: 0;
        z-index: 10;
        width: 100%;
        transition: var(--transition-normal);
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .chat-main {
        position: absolute;
        inset: 0;
        z-index: 5;
    }

    .back-btn {
        display: flex !important;
    }

    .chat-empty {
        display: none;
    }

    .message-bubble {
        /* max-width: 85%; */
    }

    .chat-input-wrapper textarea,
    .search-input-wrapper input,
    .modal-body input {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        padding: 12px 16px;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-input-area {
        padding: 8px 12px;
    }
}

/* Image Preview Container */
.image-preview-container {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border-medium);
}

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

.preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

.preview-remove:hover {
    background: var(--danger);
}

/* Image Messages */
.message-bubble.image-message {
    padding: 0;
    background: transparent !important;
    max-width: 250px;
    cursor: zoom-in;
    overflow: hidden;
    border-radius: var(--radius-md);
}

.message-bubble.image-message img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: cover;
    border-radius: var(--radius-md);
    display: block;
    transition: var(--transition-fast);
    border: 1px solid var(--border-subtle);
}

.message-bubble.image-message img:hover {
    opacity: 0.9;
}

/* Lightbox Modal */
.lightbox-modal .modal-overlay {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.lightbox-content {
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    animation: zoomIn 0.2s ease-out;
}

@keyframes zoomIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    z-index: 1002;
    padding: 8px;
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    padding: 16px 8px;
    cursor: pointer;
    z-index: 1002;
    transition: var(--transition-fast);
    border-radius: var(--radius-sm);
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.15);
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

/* Sender Name and Group Tags */
.message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 3px;
    margin-left: 12px;
}

.group-tag {
    display: inline-flex;
    align-items: center;
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    margin-right: 4px;
    font-weight: 600;
    border: 1px solid rgba(37, 99, 235, 0.3);
}

.group-client-tag {
    display: inline-flex;
    align-items: center;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 4px;
    font-weight: 600;
    border: 1px solid rgba(245, 158, 11, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.light-theme .group-client-tag {
    background: #fef3c7;
    color: #b45309;
    border-color: #fde68a;
}

/* Album Grid Layout */
.message-bubble.album-message {
    padding: 4px;
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    max-width: 320px;
    border-radius: var(--radius-md);
    display: grid;
    gap: 4px;
    cursor: pointer;
    overflow: hidden;
}

.album-img-wrapper {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.album-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: var(--transition-fast);
}

.album-img-wrapper img:hover {
    transform: scale(1.05);
}

/* Album Grids */
.album-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.album-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.album-grid-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

/* More Overlay */
.album-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* Recalled Messages and Recall Button */
.message-bubble-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}

.message-group.sent .message-bubble-wrapper {
    flex-direction: row-reverse;
}

.btn-recall-msg,
.btn-react-msg {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s, background-color 0.2s;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-recall-msg:hover,
.btn-react-msg:hover {
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
}

.message-group:hover .btn-recall-msg,
.message-group:hover .btn-react-msg {
    opacity: 1;
}

/* Reactions */
.message-reactions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.message-group.sent .message-reactions {
    justify-content: flex-end;
}

.message-group.received .message-reactions {
    justify-content: flex-start;
}

.reaction-pill {
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 2px 6px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.reaction-pill:hover {
    border-color: var(--border-medium);
    background: var(--bg-surface);
}

.reaction-count {
    font-weight: 600;
}

.reaction-picker-popup {
    animation: scaleIn 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
    from { transform: scale(0.9) translateY(5px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.message-bubble.recalled-message {
    color: var(--text-tertiary) !important;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: transparent !important;
    font-style: italic;
}

.message-group.sent .message-bubble.recalled-message {
    border-color: rgba(255, 255, 255, 0.2);
}

/* ─── File Previews & Attachments ─── */
.preview-item.file-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    padding: 6px;
    border: 1px dashed var(--border-medium);
}

.preview-file-icon {
    font-size: 20px;
    margin-top: 2px;
    line-height: 1;
}

.preview-file-ext {
    font-size: 8px;
    font-weight: 700;
    color: var(--accent-secondary);
    text-transform: uppercase;
    margin-top: 2px;
}

.preview-file-name {
    font-size: 8px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-tertiary);
    margin-top: 1px;
    text-align: center;
}

.file-attachment-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    min-width: 220px;
    max-width: 320px;
    margin: 2px 0;
}

.message-group.sent .file-attachment-card {
    background: rgba(255, 255, 255, 0.08);
}

.file-icon {
    font-size: 20px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-name:hover {
    text-decoration: underline;
    color: var(--accent-secondary);
}

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

.file-download-btn {
    font-size: 16px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px;
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-download-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

/* ─── Privacy Settings Switches ─── */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 16px;
    min-width: 0;
}

.setting-info label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.setting-desc {
    font-size: 12px;
    color: var(--text-tertiary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
    flex-shrink: 0;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-medium);
    transition: .3s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

input:checked+.slider:before {
    transform: translateX(22px);
    background-color: white;
}

.settings-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 0;
    color: var(--text-secondary);
}

/* ─── Friend Requests List ─── */
.friend-requests-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.friend-request-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.friend-request-item:hover {
    border-color: var(--border-medium);
    background: var(--bg-hover);
}

.request-avatar-wrapper {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.request-avatar-fallback {
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.request-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.request-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.request-msg {
    font-size: 11px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.request-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-action-accept,
.btn-action-reject {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-action-accept {
    background: var(--accent-primary);
    color: white;
}

.btn-action-accept:hover {
    opacity: 0.9;
    box-shadow: var(--accent-glow);
}

.btn-action-reject {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}

.btn-action-reject:hover {
    background: var(--bg-active);
    color: var(--text-primary);
}

/* Image Caption Styling */
.image-caption {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    word-break: break-word;
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

.message-group.sent .image-caption {
    background: rgba(0, 0, 0, 0.15);
}

/* ─── Blocked / Unauthorized Screen ─── */
.blocked-screen {
    display: none;
    height: 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #111827 0%, #030712 100%);
    position: relative;
    overflow: hidden;
}

.blocked-screen.active {
    display: flex;
}

.blocked-screen::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(239, 68, 68, 0.05);
    border-radius: 50%;
    filter: blur(80px);
    top: 20%;
    left: 30%;
    animation: float-bg 6s ease-in-out infinite;
}

.blocked-screen::after {
    content: '';
    position: absolute;
    width: 250px;
    height: 250px;
    background: rgba(59, 130, 246, 0.03);
    border-radius: 50%;
    filter: blur(80px);
    bottom: 20%;
    right: 30%;
    animation: float-bg 8s ease-in-out infinite reverse;
}

@keyframes float-bg {

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

    50% {
        transform: translateY(-20px) scale(1.05);
    }
}

.blocked-container {
    background: rgba(17, 24, 39, 0.7);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 24px;
    padding: 48px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(239, 68, 68, 0.05);
    animation: blockedScaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

@keyframes blockedScaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.blocked-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    margin-bottom: 24px;
    color: #ef4444;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.blocked-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #f1f5f9;
}

.blocked-message {
    color: #94a3b8;
    font-size: 15px;
    line-height: 1.6;
}

/* ─── Video Message Styles ─── */
.message-bubble.video-message {
    padding: 0;
    background: #0d0d0c;
    overflow: hidden;
    max-width: 320px;
    display: inline-flex;
    flex-direction: column;
    width: fit-content;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
}

.message-bubble.video-message video {
    display: block;
    width: 100%;
    max-width: 320px;
    max-height: 240px;
    object-fit: cover;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

/* ─── Custom Context Menu ─── */
.context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 6px 0;
    min-width: 190px;
    animation: contextScaleIn 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(15px);
}

@keyframes contextScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 13.5px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    gap: 10px;
}

.context-menu-item:hover {
    background: var(--bg-hover);
    color: white;
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ff6b6b;
}

.context-menu-item .ctx-icon {
    font-size: 15px;
    width: 20px;
    text-align: center;
}

/* ─── Reply Preview Container ─── */
.reply-preview-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(59, 130, 246, 0.08);
    border-left: 4px solid var(--accent-primary);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    animation: replySlideDown 0.25s ease-out;
}

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

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

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

.reply-preview-title {
    color: var(--text-tertiary);
    font-size: 12px;
}

.reply-preview-sender {
    font-weight: 600;
    color: var(--accent-primary);
    margin-left: 4px;
}

.reply-preview-text {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.reply-cancel-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    transition: color 0.15s;
}

.reply-cancel-btn:hover {
    color: var(--danger);
}

/* ─── Quoted message inside bubble layout ─── */
.quoted-message-container {
    padding: 6.5px 11px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 12.5px;
    max-width: 100%;
    min-width: min(350px, 100%);
    box-sizing: border-box;
    white-space: normal;
}

.quoted-message-container.has-thumb {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

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

.quoted-thumb-wrapper {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.quoted-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Quote scroll target highlight flash animation */
@keyframes bubble-flash {
    0% {
        filter: brightness(1);
        transform: scale(1);
    }

    30% {
        filter: brightness(1.25);
        transform: scale(1.03);
    }

    70% {
        filter: brightness(1.25);
        transform: scale(1.03);
    }

    100% {
        filter: brightness(1);
        transform: scale(1);
    }
}

.message-group.highlight-flash .message-bubble {
    animation: bubble-flash 1.0s ease-in-out;
}

/* Sent bubble quotes (Blue background, white text) */
.message-group.sent .quoted-message-container {
    background: var(--quote-bg-sent);
    border-left: 3px solid rgba(255, 255, 255, 0.95);
}

.message-group.sent .quoted-sender {
    font-weight: 600;
    color: #ffffff;
    /* Bright white sender */
    margin-bottom: 2px;
}

.message-group.sent .quoted-text {
    color: rgba(255, 255, 255, 0.9);
    /* Highly readable light text */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Received bubble quotes (Light gray/dark slate background) */
.message-group.received .quoted-message-container {
    background: var(--quote-bg-received);
    border-left: 3px solid var(--accent-primary);
}

.message-group.received .quoted-sender {
    font-weight: 600;
    color: var(--accent-primary);
    /* Blue sender */
    margin-bottom: 2px;
}

.message-group.received .quoted-text {
    color: var(--text-secondary);
    /* Muted gray text */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Video Info Bar ─── */
.video-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.4);
    font-size: 11px;
    color: var(--text-secondary);
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

.video-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.video-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.video-action-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

.video-action-link:hover {
    color: var(--accent-secondary);
}

.video-action-link.view {
    color: #38bdf8;
    /* Sleek sky blue for viewing */
}

.video-action-link.view:hover {
    color: #7dd3fc;
}



/* ─── Share Message Modal Styles ─── */
.share-preview-card {
    background: var(--bg-tertiary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--accent-primary);
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    max-height: 80px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.share-list {
    max-height: 350px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.share-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.share-list-item:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-subtle);
}

.share-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.share-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
    overflow: hidden;
}

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

.share-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-share-send {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-share-send:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-share-send:active {
    transform: translateY(0);
}

.btn-share-send:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-share-send.shared {
    background: var(--bg-tertiary) !important;
    color: var(--text-tertiary) !important;
    cursor: default;
    border: 1px solid var(--border-subtle);
    transform: none !important;
}

.share-search-box {
    margin-bottom: 16px;
}

.share-search-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.share-search-box input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 150, 255, 0.15);
}