/* ============================================
   VNVC Chat - Design System & Styles
   Modern dark theme with glassmorphism
   ============================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors - Dark (default) */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --bg-hover: #1f2937;
    --bg-active: #253141;

    --border-primary: rgba(48, 54, 61, 0.6);
    --border-light: rgba(48, 54, 61, 0.3);

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-orange: #d29922;
    --accent-purple: #bc8cff;

    --glass-bg: rgba(22, 27, 34, 0.85);
    --glass-border: rgba(48, 54, 61, 0.5);

    /* Sizing */
    --sidebar-width: 320px;
    --header-height: 60px;
    --input-height: 60px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-med: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f6f8fa;
    --bg-hover: #eaeef2;
    --bg-active: #dce3ea;

    --border-primary: rgba(0, 0, 0, 0.12);
    --border-light: rgba(0, 0, 0, 0.06);

    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8b949e;

    --accent-blue: #0969da;
    --accent-green: #1a7f37;
    --accent-red: #cf222e;
    --accent-orange: #9a6700;
    --accent-purple: #8250df;

    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 148, 158, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 148, 158, 0.5);
}

/* --- Spinner --- */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border-primary);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Buttons --- */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* --- Theme Toggle in Sidebar --- */
.sidebar-theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: 38px;
    padding: 0 1rem;
    border-top: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.sidebar-theme-toggle:hover {
    background: var(--bg-hover);
}
.sidebar-theme-toggle svg {
    color: var(--text-muted);
    flex-shrink: 0;
}
.sidebar-theme-toggle span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Light theme: adjust own-message bubble */
[data-theme="light"] .message-group.own .message-body,
[data-theme="light"] .message-continuation.own .message-body {
    background: rgba(9, 105, 218, 0.1);
    border-color: rgba(9, 105, 218, 0.15);
}

[data-theme="light"] .message-group:not(.own) .message-body,
[data-theme="light"] .message-continuation:not(.own) .message-body {
    background: #fff;
    border-color: var(--border-primary);
}

/* Light theme: login button */
[data-theme="light"] .google-login-btn {
    border: 1px solid var(--border-primary);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.login-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
}

.login-bg-orb-1 {
    width: 500px;
    height: 500px;
    background: var(--accent-blue);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.login-bg-orb-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-purple);
    bottom: -10%;
    right: -5%;
    animation-delay: -7s;
}

.login-bg-orb-3 {
    width: 300px;
    height: 300px;
    background: var(--accent-green);
    top: 40%;
    right: 30%;
    animation-delay: -14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -40px) scale(1.05);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.login-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(24px);
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: cardIn 0.6s ease-out;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-logo {
    margin-bottom: 2rem;
}

.login-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 85px;
    height: 85px;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15), rgba(188, 140, 255, 0.15));
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: var(--radius-lg);
    color: var(--accent-blue);
    margin-bottom: 1rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.login-features {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-feature-icon {
    font-size: 1.1rem;
}

.google-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    background: #fff;
    color: #3c4043;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-med);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.google-login-btn:hover {
    background: #f7f8f8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    transform: translateY(-1px);
}

.login-note {
    margin-top: 1.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}


/* ============================================
   CHAT PAGE LAYOUT
   ============================================ */
.chat-page {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    transition: min-width var(--transition-slow), width var(--transition-slow);
    z-index: 10;
    overflow: hidden;
}

.sidebar.collapsed {
    min-width: 0;
    width: 0;
    border-right: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    height: var(--header-height);
    border-bottom: 1px solid var(--border-primary);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15), rgba(188, 140, 255, 0.15));
    border-radius: var(--radius-sm);
    color: var(--accent-blue);
}

.sidebar-brand-text {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-search {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-search svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
}

.sidebar-search input::placeholder {
    color: var(--text-muted);
}

/* Room list */
.sidebar-rooms {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.room-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    position: relative;
}

.room-item:hover {
    background: var(--bg-hover);
}

.room-item.active {
    background: var(--bg-active);
    border-left-color: var(--accent-blue);
}

.room-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.12), rgba(188, 140, 255, 0.12));
    border-radius: var(--radius-sm);
    color: var(--accent-blue);
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.room-info {
    flex: 1;
    min-width: 0;
}

.room-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.15rem;
}

.room-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.room-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.room-unread {
    display: none;
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: 50%;
}

/* Online users section */
.sidebar-section {
    border-top: 1px solid var(--border-primary);
    padding: 0;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 38px;
    padding: 0 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
}

.online-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.online-count {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
}

.online-users {
    padding: 0.5rem;
    max-height: 120px;
    overflow-y: auto;
}

.online-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 38px;
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.online-user-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}

.online-user-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-green);
    border-radius: 50%;
    flex-shrink: 0;
}

/* User profile footer */
.sidebar-footer {
    border-top: 1px solid var(--border-primary);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    flex: 1;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-actions {
    display: flex;
    gap: 0.15rem;
    flex-shrink: 0;
}


/* ============================================
   CHAT MAIN AREA
   ============================================ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Empty state */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    position: relative;
}

/* Show sidebar button on empty screen */
.show-sidebar-btn {
    display: none;
    position: absolute;
    top: 1rem;
    left: 1rem;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.show-sidebar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.sidebar-hidden .show-sidebar-btn {
    display: inline-flex;
}

.chat-empty-icon {
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: 1.5rem;
}

.chat-empty h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.chat-empty p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Active chat container */
.chat-active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Chat header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    height: var(--header-height);
    min-height: var(--header-height);
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-room-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-member-count {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: color var(--transition-fast);
}
.chat-member-count:hover {
    color: var(--accent-blue);
    text-decoration: none;
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Show menu button when sidebar is collapsed on desktop */
.sidebar-hidden .mobile-menu-btn {
    display: flex;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

/* Date separator */
.message-date-separator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-date-separator::before,
.message-date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

/* Message groups */
.message-group {
    display: flex;
    gap: 0.6rem;
    padding: 0.35rem 0;
    animation: msgIn 0.2s ease-out;
    max-width: 75%;
}

/* Own messages - right aligned with bubble */
.message-group.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-group.own .message-header {
    flex-direction: row-reverse;
}

.message-group.own .message-content-col {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
}

.message-group.own .message-body {
    background: rgba(88, 166, 255, 0.12);
    border: 1px solid rgba(88, 166, 255, 0.15);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
}

/* Other users - left aligned with bubble */
.message-group:not(.own) .message-body {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    padding: 0.5rem 0.75rem;
    border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar-col {
    flex-shrink: 0;
    width: 36px;
    padding-top: 0.15rem;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.message-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
}

.message-content-col {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.15rem;
}

.message-sender {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.message-body {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-group.own .message-sender {
    color: var(--accent-blue);
}

/* Continuation message (same sender) */
.message-continuation {
    display: flex;
    gap: 0.6rem;
    padding: 0.1rem 0;
    animation: msgIn 0.2s ease-out;
    max-width: 75%;
}

.message-continuation.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-continuation.own .message-body {
    background: rgba(88, 166, 255, 0.12);
    border: 1px solid rgba(88, 166, 255, 0.15);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
}

.message-continuation:not(.own) .message-body {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    padding: 0.5rem 0.75rem;
    border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}

.message-continuation .message-avatar-col {
    visibility: hidden;
}

.message-continuation:hover .message-hover-time {
    opacity: 1;
}

.message-hover-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--transition-fast);
    width: 36px;
    text-align: center;
    padding-top: 0.3rem;
    flex-shrink: 0;
}

/* Chat input */
.chat-input-area {
    padding: 0.75rem 1.25rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.5rem;
    transition: border-color var(--transition-fast);
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent-blue);
}

.chat-input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.4rem 0.5rem;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.chat-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent-blue);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.send-btn:hover {
    background: #4090e8;
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.chat-input-hint {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.3rem 0.5rem 0;
}


/* ============================================
   MEMBERS PANEL
   ============================================ */
.members-panel {
    width: 280px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    z-index: 15;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
}

.members-panel.open {
    transform: translateX(0);
}

.members-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: var(--header-height);
    border-bottom: 1px solid var(--border-primary);
}

.members-panel-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.members-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.member-item:hover {
    background: var(--bg-hover);
}

.member-info {
    flex: 1;
    min-width: 0;
}
.member-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.member-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.member-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.member-status.online {
    background: var(--accent-green);
}
.member-status.offline {
    background: var(--text-muted);
    opacity: 0.4;
}

.member-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.member-delete-btn:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
    background: rgba(248, 81, 73, 0.1);
}
/* Admin actions in members panel */
.members-admin-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.members-admin-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.members-admin-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

/* Add member form in members panel */
.members-add-form {
    display: none;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.members-add-form.open {
    display: block;
}

.members-add-form input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

.members-add-form input:focus {
    border-color: var(--accent-blue);
}

/* Whitelist email dropdown */
.whitelist-dropdown {
    display: none;
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    top: 100%;
    max-height: 180px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 25;
}

.whitelist-dropdown.open {
    display: block;
}

.whitelist-dropdown-item {
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.whitelist-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.whitelist-dropdown-empty {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Admin panel dropdown: match input width exactly */
#adminMemberDropdown {
    left: 0;
    right: 0;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.member-item:hover {
    background: var(--bg-hover);
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.member-status.online {
    background: var(--accent-green);
}

.member-status.offline {
    background: var(--text-muted);
    opacity: 0.4;
}


/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    font-size: 0.85rem;
    color: var(--text-primary);
    animation: toastIn 0.3s ease-out;
    max-width: 360px;
}

.toast.toast-error {
    border-left: 3px solid var(--accent-red);
}

.toast.toast-success {
    border-left: 3px solid var(--accent-green);
}

.toast.toast-info {
    border-left: 3px solid var(--accent-blue);
}

.toast.removing {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}


/* ============================================
   ADMIN PAGE
   ============================================ */
.admin-page {
    overflow-y: auto;
    height: 100vh;
}

.admin-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

.admin-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.admin-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.admin-back-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.admin-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    flex: 1;
}

.admin-user {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: 0;
}

.admin-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    margin-bottom: -1px;
}

.admin-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.admin-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* Panels */
.admin-panel {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.admin-panel-header {
    margin-bottom: 1.25rem;
}

.admin-panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.admin-panel-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Form */
.admin-form-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.admin-input,
.admin-select {
    flex: 1;
    min-width: 150px;
    padding: 0.55rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.admin-input:focus,
.admin-select:focus {
    border-color: var(--accent-blue);
}

.admin-input::placeholder {
    color: var(--text-muted);
}

.admin-select {
    flex: 0;
    min-width: 100px;
    cursor: pointer;
    appearance: auto;
}

.admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.admin-btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

.admin-btn-primary:hover {
    background: #4090e8;
}

.admin-btn-danger {
    background: none;
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.admin-btn-danger:hover {
    background: rgba(248, 81, 73, 0.1);
}

/* Table */
.admin-table-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    padding: 0.65rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
}

.admin-table td {
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.loading-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

.role-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.role-badge.admin {
    background: rgba(188, 140, 255, 0.15);
    color: var(--accent-purple);
}

.role-badge.user {
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent-blue);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.online::before {
    background: var(--accent-green);
}

.status-badge.offline::before {
    background: var(--text-muted);
    opacity: 0.5;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease-out;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-primary);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    flex: 1;
}


/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        width: 0;
        min-width: 0;
    }

    .sidebar.mobile-open {
        width: 100%;
        min-width: 100%;
    }

    /* Always show menu button on mobile */
    .mobile-menu-btn {
        display: flex;
    }

    /* Always show the show-sidebar button on empty screen on mobile */
    .show-sidebar-btn {
        display: inline-flex;
    }

    /* Members panel: hidden by default on mobile, full-width overlay when open */
    .members-panel {
        display: none;
        width: 100%;
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        transform: none;
        z-index: 25;
    }
    .members-panel.open {
        display: flex;
    }

    .admin-form-row {
        flex-direction: column;
    }

    .admin-select {
        min-width: 100%;
    }

    .admin-table-wrapper {
        overflow-x: auto;
    }
}

/* Tablet: members panel hidden by default, overlay when open */
@media (max-width: 1024px) {
    .members-panel {
        display: none;
        width: 100%;
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        transform: none;
        z-index: 25;
    }
    .members-panel.open {
        display: flex;
    }
}