:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-chat: #0b1120;
    --bg-input: #1e293b;
    --border-color: #334155;
    --border-light: #475569;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.15);
    --msg-mine: #2563eb;
    --msg-other: #1e293b;
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ========================================================
   1. Auth / Login Styling
   ======================================================== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: radial-gradient(circle at 50% 0%, #1e293b 0%, #0f172a 75%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.auth-footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

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

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

.input-wrapper input {
    padding-left: 2.75rem !important;
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 44px;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
    min-height: 44px;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

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

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

.btn-secondary:hover {
    background-color: var(--border-light);
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success);
    color: #ffffff;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
    min-height: 34px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
    min-width: 40px;
    min-height: 40px;
    touch-action: manipulation;
}

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

/* Back button on mobile */
.btn-back-mobile {
    display: none;
    margin-right: 0.5rem;
    color: var(--text-primary);
}

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.alert-info {
    background-color: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

/* Badges & Pills */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-info { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.badge-secondary { background: var(--bg-card-hover); color: var(--text-secondary); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.35rem;
}

.status-dot.online { background-color: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background-color: var(--text-muted); }

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pill.active { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.status-pill.disabled { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* ========================================================
   2. Admin Layout & Components
   ======================================================== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.admin-sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.25s ease;
    z-index: 50;
}

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

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--primary);
}

.mobile-sidebar-close {
    display: none;
    font-size: 1.5rem;
}

.mobile-menu-btn {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--primary);
    color: #ffffff;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: #ffffff;
    flex-shrink: 0;
}

.user-info .name {
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background-color: var(--bg-main);
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.content-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.content-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.users-icon { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.rooms-icon { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.messages-icon { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dashboard-grid, .grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-action {
    font-size: 0.875rem;
    color: var(--primary);
    text-decoration: none;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-cell-name { font-weight: 600; }
.user-cell-user { font-size: 0.75rem; color: var(--text-muted); }

.checkbox-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: var(--bg-main);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.checkbox-item:hover {
    background-color: var(--bg-card);
}

.member-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.pill {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.rooms-list-scroll {
    max-height: 520px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.room-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.room-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.room-title {
    font-weight: 700;
    font-size: 0.9375rem;
    margin-right: 0.5rem;
}

.member-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

/* ========================================================
   3. Main Chat Interface
   ======================================================== */
.chat-app {
    display: flex;
    height: 100vh;
    background-color: var(--bg-chat);
    position: relative;
    overflow: hidden;
}

.chat-sidebar {
    width: 320px;
    border-right: 1px solid var(--border-color);
    background-color: var(--bg-card);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
}

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

.chat-brand {
    font-weight: 700;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

.room-threads-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.thread-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    border: 1px solid transparent;
}

.thread-item:hover {
    background-color: var(--bg-card-hover);
}

.thread-item.active {
    background-color: var(--primary-light);
    border-color: rgba(59, 130, 246, 0.4);
}

.thread-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

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

.thread-name-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.thread-name {
    font-weight: 600;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.thread-preview {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.15rem;
}

.unread-badge {
    background-color: var(--primary);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
    margin-left: 0.5rem;
}

/* Chat Main Pane */
.chat-main-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-chat);
    height: 100%;
    min-width: 0;
}

.chat-room-header {
    height: 64px;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-room-title-group {
    display: flex;
    align-items: center;
    min-width: 0;
}

.chat-room-title-group h3 {
    font-size: 1.125rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-status-indicator {
    display: inline-flex;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.header-actions-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Block Notification Banner */
.block-banner {
    background-color: var(--danger-light);
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.5rem 1.5rem;
    font-size: 0.8125rem;
    color: #fca5a5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Message Scroll Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-date-separator {
    text-align: center;
    margin: 1rem 0;
    position: relative;
}

.message-date-separator span {
    background-color: var(--bg-card);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-row {
    display: flex;
    gap: 0.75rem;
    max-width: 75%;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-card-hover);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    align-self: flex-end;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
}

.message-row.mine .message-bubble {
    background-color: var(--msg-mine);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.message-row.other .message-bubble {
    background-color: var(--msg-other);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

.message-sender-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 0.25rem;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 0.35rem;
}

.message-row.other .message-meta {
    color: var(--text-muted);
}

/* Media in Messages */
.message-media-img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: block;
    margin-top: 0.25rem;
    object-fit: cover;
}

.message-media-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    margin-top: 0.25rem;
}

.message-media-voice {
    width: 240px;
    max-width: 100%;
    margin-top: 0.25rem;
}

.typing-indicator-bar {
    padding: 0.25rem 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
    min-height: 24px;
}

/* Input Bar */
.chat-input-bar {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.chat-input-actions {
    display: flex;
    gap: 0.25rem;
}

.chat-input-field {
    flex: 1;
}

.chat-input-field input {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0.75rem 1.25rem;
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    flex-shrink: 0;
}

/* ========================================================
   4. Modals & Media Controls (Camera / Voice)
   ======================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    padding: 1rem;
}

.modal-backdrop.active {
    display: flex;
}

.modal-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.camera-preview-video {
    width: 100%;
    height: 320px;
    background-color: #000;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.camera-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* Voice Recording Bar */
.voice-recording-overlay {
    display: none;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
}

.voice-recording-overlay.active {
    display: flex;
}

.recording-pulse {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--danger);
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.recording-timer {
    font-weight: 700;
    color: #f87171;
    font-size: 0.875rem;
}

/* ========================================================
   5. Toast Notifications
   ======================================================== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 260px;
    max-width: 360px;
    pointer-events: auto;
    animation: slideIn 0.3s ease-out;
}

.toast-title {
    font-weight: 700;
    font-size: 0.875rem;
}

.toast-body {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

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

/* ========================================================
   6. Mobile Responsiveness (Overhaul & Breakpoints)
   ======================================================== */
@media (max-width: 1024px) {
    .dashboard-grid, .grid-2-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Chat App Mobile View - Master/Detail Slide Pattern */
    .chat-app {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
    }

    .chat-sidebar {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 10;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .chat-main-pane {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 20;
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Active room slide-in */
    .chat-app.chat-view-active .chat-sidebar {
        transform: translateX(-30%);
        pointer-events: none;
    }

    .chat-app.chat-view-active .chat-main-pane {
        transform: translateX(0);
    }

    .btn-back-mobile {
        display: inline-flex;
    }

    .message-row {
        max-width: 88%;
    }

    .chat-input-bar {
        padding: 0.65rem 0.75rem;
        gap: 0.5rem;
    }

    .chat-input-actions .btn-icon {
        padding: 0.35rem;
        min-width: 36px;
        min-height: 36px;
    }

    .messages-container {
        padding: 1rem 0.75rem;
    }

    /* Admin Panel Mobile Drawer */
    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 280px;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

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

    .mobile-sidebar-close {
        display: inline-flex;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .main-content {
        padding: 1.25rem 1rem;
    }

    .content-header h1 {
        font-size: 1.35rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1rem;
    }

    /* Auth & Modals on mobile */
    .auth-card {
        padding: 1.5rem 1.25rem;
    }

    .toast-container {
        top: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* ========================================================
   WebRTC Calling, View-Once & Admin Data Management Styling
   ======================================================== */
.call-modal-box {
    text-align: center;
    padding: 2.5rem 1.5rem;
    position: relative;
    max-width: 380px;
    background: #0f172a;
    border: 1px solid var(--border-color);
}

.call-avatar {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.4);
}

.call-actions-row {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.btn-call-circle {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease;
}
.btn-call-circle:hover {
    transform: scale(1.08);
}

.call-floating-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 360px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.call-window-header {
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    cursor: move;
    user-select: none;
}

.call-video-container {
    position: relative;
    width: 100%;
    min-height: 200px;
    max-height: 320px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 4px;
    width: 100%;
    height: 100%;
    padding: 4px;
}

.remote-video-tile {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: #111;
}

.call-pip-video {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 90px;
    height: 65px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--primary);
    box-shadow: var(--shadow);
    z-index: 10;
}

.call-controls-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

/* View-Once Protected Lightbox */
.view-once-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    user-select: none;
    -webkit-user-select: none;
}

.view-once-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

#view-once-canvas {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.view-once-btn.opened {
    opacity: 0.6;
    cursor: default;
}

/* Message Context Menu */
.message-context-menu {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    overflow: hidden;
    min-width: 180px;
}
.message-context-menu button {
    display: block;
    width: 100%;
    padding: 0.65rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    text-align: left;
    font-size: 0.875rem;
    cursor: pointer;
    font-family: inherit;
}
.message-context-menu button:hover {
    background: var(--bg-card-hover);
    color: var(--danger);
}

.message-deleted-text {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Admin Tabs Layout */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.admin-tab-btn {
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.admin-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.admin-tab-pane {
    display: none;
}
.admin-tab-pane.active {
    display: block;
}

/* ============================================================
   MODALS & LIGHTBOXES (Base & Animations)
   ============================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeInModal 0.2s ease-out;
}

.modal-backdrop.active {
    display: flex !important;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    padding: 1.5rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: scaleInModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.camera-preview-video {
    width: 100%;
    max-height: 360px;
    background: #000;
    border-radius: var(--radius);
    object-fit: cover;
}

.camera-controls {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* ============================================================
   INCOMING CALL MODAL
   ============================================================ */
.call-modal-box {
    max-width: 360px;
    text-align: center;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 2.5rem 1.5rem;
    border-radius: 24px;
    box-shadow: 0 0 50px rgba(59, 130, 246, 0.25);
    position: relative;
    overflow: hidden;
}

.call-ring-glow {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.4);
    filter: blur(20px);
    animation: ringPulse 1.8s infinite ease-out;
    z-index: 0;
}

@keyframes ringPulse {
    0% { transform: translateX(-50%) scale(0.8); opacity: 0.8; }
    70% { transform: translateX(-50%) scale(1.6); opacity: 0; }
    100% { transform: translateX(-50%) scale(1.8); opacity: 0; }
}

.call-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
}

.call-actions-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2.5rem;
    margin-top: 1rem;
    position: relative;
    z-index: 1;
}

.btn-call-circle {
    width: 60px;
    height: 60px;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    border: none !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    cursor: pointer;
}

.btn-call-circle:hover {
    transform: scale(1.12);
}

.btn-call-circle.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.4);
}

.btn-call-circle.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.4);
}

/* ============================================================
   ACTIVE FLOATING CALL WINDOW (Desktop & Tablet)
   ============================================================ */
.call-floating-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    min-height: 290px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(12px);
    transition: box-shadow 0.2s;
}

.call-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(30, 41, 59, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: move;
    user-select: none;
}

.call-video-container {
    position: relative;
    flex: 1;
    min-height: 220px;
    background: #020617;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.call-video-grid {
    width: 100%;
    height: 100%;
    min-height: 220px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 4px;
    padding: 4px;
    background: #020617;
}

.remote-video-tile {
    width: 100%;
    height: 100%;
    min-height: 160px;
    object-fit: cover;
    background: #000;
    border-radius: 8px;
}

.call-pip-video {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 100px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #3b82f6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
    background: #000;
    z-index: 10;
}

.call-controls-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.call-controls-bar .btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.call-controls-bar .btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ============================================================
   MOBILE RESPONSIVENESS (Screens <= 768px)
   ============================================================ */
@media (max-width: 768px) {
    .call-floating-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        z-index: 99999 !important;
        display: none;
        flex-direction: column !important;
    }

    .call-window-header {
        padding: 1rem 1.25rem;
        background: #0f172a;
        cursor: default;
    }

    .call-video-container {
        flex: 1;
        min-height: 0;
        max-height: none;
    }

    .call-video-grid {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .remote-video-tile {
        min-height: 0;
        height: 100%;
    }

    .call-pip-video {
        bottom: 100px;
        right: 16px;
        width: 110px;
        height: 85px;
        border-radius: var(--radius);
    }

    .call-controls-bar {
        padding: 1.25rem 1rem;
        background: #0f172a;
        gap: 1.5rem;
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }

    .call-controls-bar .btn-icon {
        width: 52px;
        height: 52px;
        font-size: 1.35rem;
    }

    .call-modal-box {
        width: 90vw;
        max-width: 340px;
        margin: auto;
    }
}

