@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #020617;
    --bg-surface: #0b1120;
    --bg-card: rgba(15, 23, 42, 0.75);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(16, 185, 129, 0.3);

    --primary: #10b981;
    --primary-hover: #059669;
    --primary-dark: #047857;
    --primary-glow: rgba(16, 185, 129, 0.35);

    --secondary: #3b82f6;
    --secondary-hover: #2563eb;
    --secondary-glow: rgba(59, 130, 246, 0.3);

    --danger: #ef4444;
    --accent: #f97316;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --bubble-mine: linear-gradient(135deg, #059669 0%, #047857 100%);
    --bubble-theirs: rgba(30, 41, 59, 0.85);

    --radius-xl: 20px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Ambient Radial Glow */
body::before {
    content: '';
    position: fixed;
    top: -120px;
    left: 20%;
    width: 650px;
    height: 650px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, rgba(37, 99, 235, 0.08) 50%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -150px;
    right: 15%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.09) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Header */
.app-header {
    flex-shrink: 0;
    position: relative;
    z-index: 30;
    backdrop-filter: blur(20px);
    background: rgba(2, 6, 23, 0.88);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
    flex-shrink: 0;
}

.app-logo-img {
    height: 28px;
    width: auto;
    display: block;
}

.room-badge {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.room-badge.private {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.35);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    flex-shrink: 0;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

/* Notification Permission Bar */
.notification-banner {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), rgba(37, 99, 235, 0.15));
    border-bottom: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: #e2e8f0;
    z-index: 29;
}

.notification-banner-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    outline: none;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
    text-decoration: none;
}

.btn-secondary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 12px var(--secondary-glow);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.45);
    text-decoration: none;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    backdrop-filter: blur(8px);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.18);
    text-decoration: none;
}

.btn-sm {
    padding: 0.32rem 0.65rem;
    font-size: 0.8rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    color: #34d399;
}

/* Main Layout with Sidebar */
.app-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    z-index: 10;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    width: 290px;
    background: rgba(11, 17, 32, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 25;
}

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

.sidebar-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.room-nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
}

.room-nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    text-decoration: none;
}

.room-nav-item.active {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: #34d399;
    font-weight: 600;
}

.room-nav-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.room-nav-info {
    flex: 1;
    overflow: hidden;
}

.room-nav-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-nav-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 0.85rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent;
    overflow: hidden;
    min-height: 0;
}

.public-banner {
    flex-shrink: 0;
    background: rgba(16, 185, 129, 0.07);
    border-bottom: 1px solid rgba(16, 185, 129, 0.18);
    padding: 0.45rem 1rem;
    font-size: 0.8rem;
    color: #a7f3d0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Smart Scroll Down Button */
.scroll-bottom-btn {
    position: absolute;
    bottom: 80px;
    right: 1.5rem;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.45rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    gap: 0.35rem;
    z-index: 20;
    animation: fadeIn 0.2s ease-out;
}

.scroll-bottom-btn:hover {
    border-color: var(--primary);
    color: #34d399;
}

/* Message Bubble Rows */
.message-row {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    position: relative;
    animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.message-row.theirs {
    align-self: flex-start;
}

.message-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.35rem;
}

.message-row.mine .message-meta {
    justify-content: flex-end;
}

/* Quoted Reply inside Bubble */
.reply-quote {
    background: rgba(0, 0, 0, 0.25);
    border-left: 3px solid var(--primary);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.45rem;
    font-size: 0.8rem;
}

.reply-quote-sender {
    font-weight: 700;
    color: #34d399;
    margin-bottom: 0.15rem;
}

.reply-quote-text {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-bubble-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    max-width: 100%;
}

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

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    word-break: break-word;
    font-size: 0.93rem;
    line-height: 1.5;
    position: relative;
    backdrop-filter: blur(12px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: default;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    -webkit-touch-callout: none;
}

.message-bubble.is-pressing {
    transform: scale(0.97);
    filter: brightness(1.1);
}

.message-bubble.context-active {
    box-shadow: 0 0 0 2px var(--primary), 0 8px 24px rgba(16, 185, 129, 0.35) !important;
}

.btn-msg-more {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.18s, background 0.15s, color 0.15s, transform 0.1s;
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    padding: 0;
}

.message-row:hover .btn-msg-more {
    opacity: 1;
}

.btn-msg-more:hover {
    background: #1e293b;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

@media (hover: none) {
    .btn-msg-more {
        opacity: 0.45;
    }
}

.message-row.mine .message-bubble {
    background: var(--bubble-mine);
    color: #fff;
    border-bottom-right-radius: 4px;
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.25);
}

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

/* System pairing message */
.message-row.system {
    align-self: center;
    max-width: 90%;
    margin: 0.4rem 0;
}

.message-row.system .message-bubble {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
    font-size: 0.85rem;
    text-align: center;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
}

/* Image & Video Attachments */
.message-image {
    max-width: 100%;
    max-height: 380px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: block;
    margin-top: 0.4rem;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-video {
    max-width: 100%;
    max-height: 380px;
    border-radius: var(--radius-md);
    display: block;
    margin-top: 0.4rem;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-caption {
    margin-top: 0.4rem;
    font-size: 0.92rem;
    line-height: 1.45;
}

/* File Attachment Card */
.file-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.file-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}

.file-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.file-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.file-btn {
    flex: 1;
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-align: center;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: background 0.2s;
    text-decoration: none;
}

.file-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    text-decoration: none;
}

.file-btn-primary {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
    color: #a7f3d0;
}

.file-btn-primary:hover {
    background: rgba(16, 185, 129, 0.35);
    color: #fff;
}

/* Audio Voice Message Player */
.voice-player {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0;
    min-width: 200px;
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}

.voice-play-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.voice-track-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.voice-progress-bar {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.voice-progress-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 9999px;
    transition: width 0.1s linear;
}

.voice-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    opacity: 0.85;
}

/* Easy Inline Copy for Emails, Links and Codes */
.inline-copyable {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-inline-copy {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.75;
    padding: 0 0.15rem;
    transition: opacity 0.2s, transform 0.1s;
    color: inherit;
}

.btn-inline-copy:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Reactions Counters Container (WhatsApp / Telegram style overlapping bottom edge) */
.reactions-container {
    display: none;
    align-items: center;
    gap: 3px;
    position: absolute;
    bottom: -11px;
    z-index: 5;
    user-select: none;
    -webkit-user-select: none;
}

.reactions-container:not(:empty) {
    display: inline-flex;
}

.message-row.mine .reactions-container {
    right: 12px;
}

.message-row.theirs .reactions-container {
    left: 12px;
}

.message-row.has-reactions {
    margin-bottom: 0.85rem;
}

.reaction-pill {
    background: #0b1120;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9999px;
    padding: 2px 7px;
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.15s, border-color 0.15s;
    user-select: none;
    color: var(--text-primary);
}

.reaction-pill:hover {
    transform: scale(1.15);
    background: #1e293b;
    border-color: var(--primary);
}

.reaction-pill .count {
    font-weight: 700;
    color: #a7f3d0;
    font-size: 0.72rem;
}

/* Double-Tap Heart Pop Animation */
.heart-pop {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 2.6rem;
    pointer-events: none;
    z-index: 30;
    animation: heartPopAnim 0.75s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes heartPopAnim {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    40% {
        transform: translate(-50%, -50%) scale(1.35);
        opacity: 1;
    }
    75% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -85%) scale(0.9);
        opacity: 0;
    }
}

/* Floating Message Context Menu (Long-press / Right-click / More options) */
.msg-context-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 6, 23, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
}

.msg-context-menu {
    position: fixed;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(16, 185, 129, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0.6rem;
    z-index: 1001;
    display: none;
    flex-direction: column;
    gap: 0.45rem;
    animation: ctxPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    width: 270px;
    max-width: calc(100vw - 32px);
}

@keyframes ctxPopIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.msg-context-reactions {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0.2rem 0.25rem 0.35rem;
    gap: 0.25rem;
}

.reaction-quick-btn {
    background: transparent;
    border: none;
    font-size: 1.55rem;
    line-height: 1;
    padding: 0.35rem;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reaction-quick-btn:hover,
.reaction-quick-btn:active {
    transform: scale(1.35) translateY(-3px);
    background: rgba(255, 255, 255, 0.1);
}

.msg-context-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.1rem 0;
}

.msg-context-actions {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.msg-context-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.msg-context-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.msg-context-action-btn .ctx-icon {
    font-size: 1.1rem;
    width: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Active Reply & Attachment Bar above input */
.active-context-bar {
    background: rgba(11, 17, 32, 0.95);
    border-top: 1px solid var(--border-subtle);
    padding: 0.45rem 1rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.82rem;
}

.active-context-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Emoji / Stickers Popover */
.emoji-popover {
    position: absolute;
    bottom: 60px;
    left: 1rem;
    background: #0b1120;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    padding: 0.75rem;
    width: 320px;
    display: none;
    flex-direction: column;
    z-index: 60;
    backdrop-filter: blur(20px);
}

.emoji-popover-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0.65rem;
    padding-bottom: 0.35rem;
    gap: 0.5rem;
}

.emoji-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-family: inherit;
    text-align: center;
}

.emoji-tab-btn.active {
    color: #34d399;
    background: rgba(16, 185, 129, 0.15);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.35rem;
    max-height: 210px;
    overflow-y: auto;
}

.stickers-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-height: 210px;
    overflow-y: auto;
    padding: 0.2rem;
}

.sticker-item-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sticker-item-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.08);
    border-color: var(--primary);
}

.sticker-item-img {
    width: 62px;
    height: 62px;
}

/* WhatsApp-style floating sticker in message feed */
.message-row.sticker {
    background: transparent !important;
}

.message-row.sticker .message-bubble {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0.25rem !important;
    backdrop-filter: none !important;
}

.sticker-img {
    width: 140px;
    height: 140px;
    display: block;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.4));
    transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.sticker-img:hover {
    transform: scale(1.08);
}

.emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.1s;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
}

/* Chat Footer & Input Area */
.chat-footer {
    flex-shrink: 0;
    padding: 0.55rem 0.85rem;
    position: relative;
    border-top: 1px solid var(--border-subtle);
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(20px);
}

.dropzone-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(5, 150, 105, 0.9);
    backdrop-filter: blur(10px);
    border: 3px dashed #fff;
    border-radius: var(--radius-xl);
    z-index: 50;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.input-bar {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 0.4rem 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.input-bar textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    resize: none;
    height: 38px;
    max-height: 120px;
    padding: 0.45rem 0.25rem;
    line-height: 1.4;
}

/* Voice Recording Mode UI */
.recording-bar {
    display: none;
    flex: 1;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.5rem;
}

.record-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--danger);
    font-weight: 700;
    font-size: 0.9rem;
}

.record-pulse {
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}

.record-timer {
    font-variant-numeric: tabular-nums;
    font-size: 0.92rem;
    color: #fff;
    font-weight: 600;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-content {
    background: #0b1120;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    max-width: 420px;
    width: 100%;
    padding: 1.75rem;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    position: relative;
    animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover { color: #fff; }

.qr-box {
    background: #fff;
    padding: 1.15rem;
    border-radius: var(--radius-lg);
    display: inline-block;
    margin: 1.15rem auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.form-group {
    margin-bottom: 1.15rem;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 200;
    pointer-events: none;
}

.toast {
    background: rgba(15, 23, 42, 0.95);
    color: #fff;
    border: 1px solid var(--border-subtle);
    padding: 0.7rem 1.15rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    font-size: 0.88rem;
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto;
    animation: toastSlide 0.25s ease-out;
}

@keyframes toastSlide {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive Rules */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 24;
        display: none;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .message-row { max-width: 92%; }
    .btn-text-hide { display: none; }
    .room-badge { max-width: 120px; font-size: 0.76rem; }
    .app-header { padding: 0.5rem 0.75rem; }
    .chat-messages { padding: 0.75rem 0.5rem; }
    .chat-footer { padding: 0.5rem 0.65rem; }
    .toast-container { right: 1rem; bottom: 1.5rem; }
    .emoji-popover { left: 0.5rem; width: 280px; }
}
