@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================
   KOMUNIKAČNÍ PLATFORMA - STYLOVÁNÍ
   Modern Dark Theme s Glassmorphism efekty
   ============================================ */

/* CSS Variables */
:root {
    /* Colors */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-light: #8b9cf5;
    --primary-hover: #5a6fd6;
    --secondary-color: #764ba2;

    /* Dark Theme */
    --bg-dark: #0f0f1a;
    --bg-card: rgba(25, 25, 40, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-hover: rgba(255, 255, 255, 0.1);

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-glass: rgba(255, 255, 255, 0.15);

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(102, 126, 234, 0.3);

    /* Spacing */
    --header-height: 64px;
    --sidebar-width: 320px;

    /* Animation */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Animated Background Colors */
    --bg-shift-1: #141028;
    --bg-shift-2: #180f24;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: linear-gradient(-45deg, var(--bg-dark), var(--bg-shift-1), var(--bg-dark), var(--bg-shift-2));
    background-size: 400% 400%;
    animation: gradientShift 25s ease infinite;
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    /* Changed from min-height to fixed height */
    overflow: hidden;
    /* Prevent body scroll */
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.login-background {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

.gradient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s ease-in-out infinite, sphereHue 25s ease-in-out infinite;
}

@keyframes sphereHue {
    0% {
        filter: blur(80px) hue-rotate(0deg);
    }

    25% {
        filter: blur(80px) hue-rotate(12deg);
    }

    50% {
        filter: blur(80px) hue-rotate(0deg);
    }

    75% {
        filter: blur(80px) hue-rotate(-12deg);
    }

    100% {
        filter: blur(80px) hue-rotate(0deg);
    }
}

.sphere-1 {
    width: 500px;
    height: 500px;
    background: var(--primary-color);
    top: -200px;
    left: -100px;
    animation-delay: 0s;
}

.sphere-2 {
    width: 400px;
    height: 400px;
    background: var(--secondary-color);
    bottom: -150px;
    right: -100px;
    animation-delay: -7s;
}

.sphere-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -30px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border: 1px solid var(--border-glass);
    border-radius: 28px;
    padding: 48px 40px;
    box-shadow: var(--shadow-lg), var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo {
    display: inline-flex;
    margin-bottom: 24px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.login-header h1 {
    font-size: 28px;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-footer {
    text-align: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 14px 16px;
    padding-left: 48px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all var(--transition-fast);
}

input:not([type="submit"]):focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-glass-hover);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15), 0 0 20px rgba(102, 126, 234, 0.1);
}

input:not([type="submit"]):focus+.input-icon,
input:not([type="submit"]):focus~.input-icon {
    color: var(--primary-color);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* Non-icon inputs */
.form-group>input:not(.input-wrapper input),
.form-group>select,
.form-group>textarea {
    padding-left: 16px;
}

select {
    padding-left: 16px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* Fix for option visibility in dropdowns */
select option {
    background-color: #1a1a2e;
    color: #ffffff;
    padding: 8px;
}

textarea {
    padding-left: 16px;
    resize: vertical;
    min-height: 80px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
    border-color: var(--border-glass);
}

.btn-icon {
    padding: 10px;
    border-radius: 10px;
}

.btn-small {
    padding: 6px;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
    border-color: var(--error);
}

.btn-login {
    padding: 16px;
    font-size: 16px;
    margin-top: 8px;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: slideIn 0.3s ease, fadeOut 0.5s ease 4s forwards;
    pointer-events: auto;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
        pointer-events: none;
    }
}

.alert-success {
    background: rgba(16, 185, 129, 0.9);
    border: 1px solid rgba(16, 185, 129, 0.5);
    color: #ffffff;
}

.alert-error {
    background: rgba(239, 68, 68, 0.9);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #ffffff;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.9);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #ffffff;
}

.alert-info {
    background: rgba(59, 130, 246, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.5);
    color: #ffffff;
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.alert-close:hover {
    opacity: 1;
}

.flash-container {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    max-width: 400px;
    width: calc(100% - 32px);
    pointer-events: none;
}

/* ============================================
   HEADER
   ============================================ */

.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border-image: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--primary-color)) 1;
    border-bottom-width: 1px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Storage Indicator (Admin) */
.storage-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 50px;
    color: var(--text-secondary);
    font-size: 12px;
    transition: all var(--transition-normal);
    cursor: default;
}

.storage-indicator:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-color);
}

.storage-indicator svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.storage-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.storage-bar-bg {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease, background 0.4s ease;
}

.storage-bar-fill.storage-low {
    background: linear-gradient(90deg, #10b981, #34d399);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.storage-bar-fill.storage-mid {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.storage-bar-fill.storage-high {
    background: linear-gradient(90deg, #ef4444, #f87171);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.storage-text {
    white-space: nowrap;
    font-weight: 500;
    font-size: 11px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .storage-indicator {
        display: none;
    }
}

.logo-text {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
}

.logo-text svg {
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 20px 6px 6px;
    background: var(--bg-glass);
    border-radius: 50px;
    border: 1px solid var(--border-glass);
    transition: all var(--transition-normal);
}

.user-info:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.user-avatar.clickable {
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
    border-radius: 50%;
}

.user-avatar.clickable:hover .avatar-overlay {
    opacity: 1;
}

.user-avatar.clickable:hover {
    transform: scale(1.08);
    box-shadow: 0 0 16px rgba(102, 126, 234, 0.4);
}

.user-avatar .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-avatar {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-admin {
    color: var(--error);
}

.role-editor {
    color: var(--warning);
}

.role-scenarista {
    color: #a855f7;
}

.role-daber {
    color: var(--info);
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

.dashboard-page {
    padding-top: var(--header-height);
}

.dashboard-layout {
    display: flex;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
    position: relative;
    /* Ensure z-index works */
}

/* ============================================
   ACTIVITY SIDEBAR (LEFT)
   ============================================ */

.activity-sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin 0.3s ease;
}

.activity-sidebar.closed {
    width: 0;
    opacity: 0;
    overflow: hidden;
    border: none;
    margin: 0;
}

.activity-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.activity-group {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-glass);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.activity-role-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.activity-role-title::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Role-specific color dots */
.activity-group[data-role="admin"] .activity-role-title::before {
    background: var(--error);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}
.activity-group[data-role="admin"] {
    border-color: rgba(239, 68, 68, 0.2);
}

.activity-group[data-role="moderator"] .activity-role-title::before {
    background: #a78bfa;
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.5);
}
.activity-group[data-role="moderator"] {
    border-color: rgba(167, 139, 250, 0.2);
}

.activity-group[data-role="editor"] .activity-role-title::before {
    background: var(--warning);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}
.activity-group[data-role="editor"] {
    border-color: rgba(245, 158, 11, 0.2);
}

.activity-group[data-role="scenarista"] .activity-role-title::before {
    background: #a855f7;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
}
.activity-group[data-role="scenarista"] {
    border-color: rgba(168, 85, 247, 0.2);
}

.activity-group[data-role="daber"] .activity-role-title::before {
    background: var(--info);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}
.activity-group[data-role="daber"] {
    border-color: rgba(59, 130, 246, 0.2);
}

.activity-users-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.activity-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 10px;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.activity-user:hover {
    background: var(--bg-glass-hover);
    transform: translateX(2px);
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--bg-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    position: relative;
    flex-shrink: 0;
}

.user-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* Online/Offline Badge */
.user-avatar-small::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

.user-avatar-small.online::after {
    background: var(--success);
}

.user-avatar-small.offline::after {
    background: var(--text-muted);
    opacity: 0.5;
}

.activity-username {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   CHAT AREA
   ============================================ */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    overflow: hidden;
    min-width: 0;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}

.empty-state svg {
    opacity: 0.3;
}

.empty-state h2 {
    font-size: 24px;
    color: var(--text-secondary);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
    min-height: 0;
    height: 100%;
    /* Force full height */
}

.chat-container.hidden {
    display: none;
}

.chat-container.drag-over {
    outline: 3px dashed var(--primary-color);
    outline-offset: -3px;
    background: rgba(102, 126, 234, 0.08);
}

.chat-header {
    padding: 20px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.chat-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.chat-members {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.member-badge {
    padding: 4px 10px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: opacity 0.2s ease;
}

.messages-container.switching {
    opacity: 0;
}

.message {
    max-width: 70%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    backdrop-filter: blur(8px);
}

.message:hover {
    transform: scale(1.008);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.message-own {
    align-self: flex-end;
    background: var(--primary-gradient);
    border: none;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), var(--shadow-glow);
}

/* Message slide-in animations */
@keyframes msgSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes msgSlideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes msgFadeInStagger {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-animate-in {
    animation: msgSlideInLeft 0.3s ease forwards;
}

.msg-animate-in.message-own {
    animation: msgSlideInRight 0.3s ease forwards;
}

.msg-stagger-in {
    opacity: 0;
    animation: msgFadeInStagger 0.3s ease forwards;
}

/* Typing indicator bouncing dots */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

/* Specific text color for own messages to ensure contrast */
.message-own .message-content,
.message-own .message-author,
.message-own .message-time,
.message-own .message-delete-btn {
    color: #ffffff;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.message-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.message-own .message-delete-btn {
    color: rgba(255, 255, 255, 0.7);
}

.message:hover .message-delete-btn {
    opacity: 1;
}

.message-delete-btn:hover {
    color: var(--error);
}

.message-own .message-delete-btn:hover {
    color: #ffcccc;
}

.message-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message-avatar-default {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar-default svg {
    width: 12px;
    height: 12px;
    opacity: 0.5;
}

.message-author {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
}

.message-own .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-content {
    word-break: break-word;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    font-weight: 400;
}

.message-form {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

.message-form input {
    flex: 1;
    padding-left: 16px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.message-form .mention-container:focus-within input {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3), 0 0 12px rgba(102, 126, 234, 0.15);
    border-color: var(--primary-color);
}

.message-form .btn {
    padding: 14px 20px;
}

.btn:active {
    transform: scale(0.96);
}

.main-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    flex-shrink: 0;
    z-index: 10;
}

.main-header h1 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
}

.dashboard-layout {
    display: flex;
    flex: 1;
    /* Take remaining height */
    overflow: hidden;
    position: relative;
    height: auto;
    min-height: 0;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    width: 100%;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform var(--transition-normal);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.sidebar-close {
    display: none;
}

.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.projects-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.project-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.project-item:hover {
    background: var(--bg-glass);
}

.project-item.active {
    background: var(--bg-glass);
    border-color: var(--primary-color);
}

.project-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.project-icon svg {
    color: white;
}

.project-info {
    flex: 1;
    min-width: 0;
}

.project-name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-creator {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-projects {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* Sidebar Dropdown Menu */
.sidebar-dropdown {
    position: relative;
}

.sidebar-dropdown-trigger {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.sidebar-dropdown-trigger:hover,
.sidebar-dropdown-menu.open ~ .sidebar-dropdown-trigger,
.sidebar-dropdown:hover .sidebar-dropdown-trigger {
    opacity: 1;
}

.sidebar-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 170px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 6px;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: dropdownFadeIn 0.15s ease;
}

.sidebar-dropdown-menu.open {
    display: block;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.sidebar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.sidebar-dropdown-item:hover {
    background: var(--bg-glass-hover);
}

.sidebar-dropdown-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.sidebar-dropdown-danger {
    color: var(--error);
}

.sidebar-dropdown-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-dropdown-danger svg {
    opacity: 0.8;
}

.sidebar-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 8px;
}

/* Project Groups with Rooms */
.project-group {
    margin-bottom: 4px;
}

.project-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.project-header:hover {
    background: var(--bg-glass);
    border-color: var(--border-color);
}

.project-group.expanded .project-header {
    background: var(--bg-glass);
    border-color: var(--border-color);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.project-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.chevron {
    transition: transform var(--transition-fast);
    opacity: 0.5;
}

.project-group.expanded .chevron {
    transform: rotate(180deg);
}

.project-rooms {
    display: none;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 8px;
    margin-bottom: 8px;
}

.project-rooms.expanded {
    display: block;
}

.room-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
}

.room-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.room-item.active {
    background: var(--primary-gradient);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2), var(--shadow-glow);
}

.room-item.has-unread {
    color: #ffffff;
    font-weight: 700;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
    border-left: 3px solid var(--primary-color);
    padding-left: 9px;
}

.room-item.has-unread::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--warning);
    border-radius: 50%;
    margin-left: auto;
    box-shadow: 0 0 5px var(--warning);
    animation: unreadPulse 2s infinite;
}

@keyframes unreadPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

.room-icon {
    opacity: 0.7;
    display: flex;
    align-items: center;
}

.room-name {
    flex: 1;
    font-size: 14px;
}

/* =========================================
   CONTEXT MENU (ZPRAVY)
   ========================================= */
.context-menu {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 160px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transform: scale(0.95);
    transform-origin: top left;
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
    /* Ignore clicks while hidden */
}

.context-menu.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.context-menu-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    transition: background-color 0.2s, color 0.2s;
}

.context-menu-item:hover {
    background: var(--bg-glass-hover);
}

.context-menu-item.context-menu-danger {
    color: var(--error);
}

.context-menu-item.context-menu-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    /* Light red background */
}

/* =========================================
   REPLY INDICATOR & BLOCKS
   ========================================= */
.reply-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border-left: 3px solid var(--primary-color);
    padding: 10px 16px;
    font-size: 13px;
    border-top: 1px solid var(--border-color);
    animation: replySlideUp 0.2s ease;
}

@keyframes replySlideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reply-indicator.hidden {
    display: none;
}

.reply-indicator-icon {
    color: var(--primary-color);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.reply-indicator-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.reply-indicator-label {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.reply-indicator-text {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}

.reply-cancel-btn {
    width: 28px;
    height: 28px;
    padding: 6px;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.reply-cancel-btn:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
}

/* Message Reply Block inside actual messages */
.message-reply-block {
    background: var(--bg-glass);
    border-left: 3px solid var(--primary-color);
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 13px;
    cursor: pointer;
    /* To indicate it could jump to message, even if we just highlight for now */
    transition: background-color 0.2s;
}

.message-reply-block:hover {
    background: var(--bg-glass-hover);
}

.message-reply-author {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 2px;
}

.message-reply-text {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Specific styling for own messages so reply block doesn't clash */
.message-own .message-reply-block {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.message-own .message-reply-author {
    color: rgba(255, 255, 255, 0.9);
}

.message-own .message-reply-text {
    color: rgba(255, 255, 255, 0.8);
}

.room-type-label {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
}

.room-type-label.free {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.room-type-label.editor {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

/* Room type badge in chat header */
.room-type-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.room-type-badge.free {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.room-type-badge.editor {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* No write permission info */
.no-write-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: rgba(245, 158, 11, 0.1);
    border-top: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
    font-size: 14px;
}

.no-write-info.hidden {
    display: none;
}

/* File messages */
.file-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px 4px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-top: 4px;
}

.file-download {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-download a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.file-download a:hover {
    text-decoration: underline;
}

.file-size-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
    opacity: 0.8;
}

.message-own .file-size-label {
    color: rgba(255, 255, 255, 0.7);
}

/* Fix for own messages file links */
.message-own .file-download a {
    color: #ffffff !important;
    text-decoration: underline;
}

.message-own .file-download svg {
    color: #ffffff !important;
}

/* Remove background and padding for file messages in own messages to remove extra gap */
.message-own .file-message {
    background: transparent;
    padding: 0;
    margin-top: 0;
    border-radius: 0;
    gap: 2px;
}

/* Specific styling for messages with files to remove bottom gap */
.message.message-has-file {
    padding-bottom: 4px;
    /* Reduced from 8px */
}

/* Media previews */
.media-preview {
    max-width: 400px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0;
}

.media-preview img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 8px;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.media-preview img:hover {
    transform: scale(1.02);
}

.media-preview video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    background: #000;
}

.media-preview.audio-preview {
    width: 100%;
    max-width: none;
    min-width: 300px;
}

.media-preview audio {
    width: 100%;
    min-width: 300px;
    height: 54px;
    border-radius: 27px;
}

/* Style for audio in webkit browsers */
.media-preview audio::-webkit-media-controls-panel {
    background: var(--bg-glass);
}

/* Form help text */
.form-help {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 10px;
    background: var(--bg-glass);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

/* ============================================
   ADMIN PAGE
   ============================================ */

.admin-page {
    padding-top: var(--header-height);
}

.admin-content {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
    flex: 1;
    overflow-y: auto;
    width: 100%;
}

.admin-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
}

.admin-card-large {
    grid-column: span 1;
}

.card-header {
    padding: 20px 24px;
    background: var(--bg-glass);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.badge {
    padding: 6px 14px;
    background: var(--primary-gradient);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* Users Table */
.users-table-container {
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.users-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.users-table tbody tr {
    transition: background var(--transition-fast);
}

.users-table tbody tr:hover {
    background: var(--bg-glass);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.role-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.role-badge.role-admin {
    background: rgba(239, 68, 68, 0.2);
}

.role-badge.role-editor {
    background: rgba(245, 158, 11, 0.2);
}

.role-badge.role-daber {
    background: rgba(59, 130, 246, 0.2);
}

.role-badge.role-moderator {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.role-badge.role-scenarista {
    background: rgba(236, 72, 153, 0.2);
    color: #f472b6;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.inline-form {
    display: inline;
}

/* ============================================
   MODALS
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 520px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 20px 24px;
    background: var(--bg-glass);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-footer {
    padding: 16px 24px;
    background: var(--bg-glass);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden {
    display: none !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-card-large {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 54px;
        right: 0;
        bottom: 0;
        transform: translateX(100%);
        z-index: 200;
        background: #191928 !important;
        backdrop-filter: none;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: flex;
    }

    .user-details {
        display: none;
    }

    .logo-text span {
        display: none;
    }

    .message {
        max-width: 85%;
    }

    .admin-content {
        padding: 16px;
    }

    .flash-container {
        left: 16px;
        right: 16px;
        max-width: none;
    }
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-glass);
}

/* ============================================
   TABS
   ============================================ */

.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-glass);
    border-radius: 12px;
    margin-bottom: 16px;
}

.tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    background: var(--primary-gradient);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================
   CHECKBOXES
   ============================================ */

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.checkbox-label:hover {
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.checkbox-label span {
    font-size: 14px;
}

/* ============================================
   PERMISSION MATRIX
   ============================================ */

.perm-matrix {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-glass);
}

.perm-matrix-header {
    display: grid;
    grid-template-columns: 1fr 80px 80px;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(102, 126, 234, 0.1);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.perm-matrix-header span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.perm-matrix-header span:first-child {
    justify-content: flex-start;
}

.perm-matrix-row {
    display: grid;
    grid-template-columns: 1fr 80px 80px;
    gap: 4px;
    padding: 8px 14px;
    align-items: center;
    transition: background 0.15s ease;
}

.perm-matrix-row:hover {
    background: var(--bg-glass-hover);
}

.perm-matrix-row-label {
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.perm-matrix-row-label .role-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.perm-matrix-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.perm-matrix-quickaction {
    display: grid;
    grid-template-columns: 1fr 80px 80px;
    gap: 4px;
    padding: 6px 14px;
    background: rgba(102, 126, 234, 0.05);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

.perm-matrix-quickaction span {
    display: flex;
    align-items: center;
    justify-content: center;
}

.perm-matrix-quickaction span:first-child {
    justify-content: flex-start;
    font-weight: 500;
    color: var(--text-secondary);
}

.perm-matrix-scrollable {
    max-height: 200px;
    overflow-y: auto;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    transition: background 0.25s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transition: transform 0.25s ease, background 0.25s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: #ffffff;
}

/* ============================================
   ROLE TAGS
   ============================================ */

.role-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-tag.role-admin {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.role-tag.role-editor {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.role-tag.role-scenarista {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.role-tag.role-daber {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.room-roles-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.room-type-label {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-glass);
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============================================
   ADDITIONAL ROLE BADGE STYLES
   ============================================ */

.role-badge.role-scenarista {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

/* ============================================
   EMPTY ROOMS
   ============================================ */

.empty-rooms {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================
   ROLE SELECT IN TABLE
   ============================================ */

.role-select {
    padding: 6px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.role-select:hover {
    border-color: var(--primary-color);
}

/* ============================================
   ROLE INFO IN ADMIN
   ============================================ */

.role-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.role-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--bg-glass);
    border-radius: 10px;
}

.role-item p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================
   ADMIN CARD FULL WIDTH
   ============================================ */

.admin-card-full {
    grid-column: 1 / -1;
}

/* ============================================
   TEXT MUTED
   ============================================ */

.text-muted {
    color: var(--text-muted);
}

/* Project Icon Image */
.project-icon-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.project-icon-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Sidebar Toggle Desktop */
@media (min-width: 769px) {
    .sidebar {
        width: var(--sidebar-width);
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin 0.3s ease;
        border-left: 1px solid var(--border-color);
        background: var(--bg-card);
        flex-shrink: 0;
    }

    .sidebar.closed {
        width: 0;
        opacity: 0;
        overflow: hidden;
        border: none;
        margin: 0;
    }

    .chat-area {
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: 100%;
    }

    .sidebar-toggle-desktop {
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
}

@media (max-width: 768px) {
    .sidebar-toggle-desktop {
        display: none;
    }
}

/* ============================================
   THEMES - Full Visual System
   Each theme sets: accent colors, background,
   card/glass colors, text, borders, and glow
   ============================================ */

/* --- DARK THEMES --- */

/* Blue (Default) */
body.theme-blue {
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #60a5fa;
    --bg-dark: #0a0e1a;
    --bg-shift-1: #0e1428;
    --bg-shift-2: #101a30;
    --bg-card: rgba(15, 23, 42, 0.85);
    --bg-glass: rgba(59, 130, 246, 0.06);
    --bg-glass-hover: rgba(59, 130, 246, 0.12);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.2);
    --border-color: rgba(59, 130, 246, 0.15);
    --border-glass: rgba(59, 130, 246, 0.2);
}

/* Purple */
body.theme-purple {
    --primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary-color: #a78bfa;
    --bg-dark: #0f0a1a;
    --bg-shift-1: #18102a;
    --bg-shift-2: #140e28;
    --bg-card: rgba(22, 15, 40, 0.85);
    --bg-glass: rgba(139, 92, 246, 0.06);
    --bg-glass-hover: rgba(139, 92, 246, 0.12);
    --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.2);
    --border-color: rgba(139, 92, 246, 0.15);
    --border-glass: rgba(139, 92, 246, 0.2);
}

/* Green */
body.theme-green {
    --primary-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --primary-color: #10b981;
    --primary-hover: #059669;
    --secondary-color: #34d399;
    --bg-dark: #071210;
    --bg-shift-1: #0a1a16;
    --bg-shift-2: #0c1e1a;
    --bg-card: rgba(10, 30, 25, 0.85);
    --bg-glass: rgba(16, 185, 129, 0.06);
    --bg-glass-hover: rgba(16, 185, 129, 0.12);
    --shadow-glow: 0 0 30px rgba(16, 185, 129, 0.2);
    --border-color: rgba(16, 185, 129, 0.15);
    --border-glass: rgba(16, 185, 129, 0.2);
}

/* Orange */
body.theme-orange {
    --primary-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --primary-color: #f59e0b;
    --primary-hover: #d97706;
    --secondary-color: #fbbf24;
    --bg-dark: #1a1008;
    --bg-shift-1: #241a0e;
    --bg-shift-2: #201610;
    --bg-card: rgba(35, 25, 10, 0.85);
    --bg-glass: rgba(245, 158, 11, 0.06);
    --bg-glass-hover: rgba(245, 158, 11, 0.12);
    --shadow-glow: 0 0 30px rgba(245, 158, 11, 0.2);
    --border-color: rgba(245, 158, 11, 0.15);
    --border-glass: rgba(245, 158, 11, 0.2);
}

/* Pink */
body.theme-pink {
    --primary-gradient: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    --primary-color: #ec4899;
    --primary-hover: #db2777;
    --secondary-color: #f472b6;
    --bg-dark: #1a0a14;
    --bg-shift-1: #241020;
    --bg-shift-2: #200e1a;
    --bg-card: rgba(35, 12, 25, 0.85);
    --bg-glass: rgba(236, 72, 153, 0.06);
    --bg-glass-hover: rgba(236, 72, 153, 0.12);
    --shadow-glow: 0 0 30px rgba(236, 72, 153, 0.2);
    --border-color: rgba(236, 72, 153, 0.15);
    --border-glass: rgba(236, 72, 153, 0.2);
}

/* Dark/Monochrome */
body.theme-dark {
    --primary-gradient: linear-gradient(135deg, #4b5563 0%, #1f2937 100%);
    --primary-color: #6b7280;
    --primary-hover: #4b5563;
    --secondary-color: #9ca3af;
    --bg-dark: #000000;
    --bg-shift-1: #0a0a0e;
    --bg-shift-2: #08080c;
    --bg-card: rgba(15, 15, 15, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --shadow-glow: 0 0 20px rgba(107, 114, 128, 0.15);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.12);
}

/* Sunset */
body.theme-sunset {
    --primary-gradient: linear-gradient(135deg, #f97316 0%, #ef4444 50%, #ec4899 100%);
    --primary-color: #f97316;
    --primary-hover: #ea580c;
    --secondary-color: #fb923c;
    --bg-dark: #1a0d08;
    --bg-shift-1: #241410;
    --bg-shift-2: #200e14;
    --bg-card: rgba(30, 15, 10, 0.85);
    --bg-glass: rgba(249, 115, 22, 0.06);
    --bg-glass-hover: rgba(249, 115, 22, 0.12);
    --shadow-glow: 0 0 30px rgba(249, 115, 22, 0.2);
    --border-color: rgba(249, 115, 22, 0.15);
    --border-glass: rgba(249, 115, 22, 0.2);
}

/* Ocean */
body.theme-ocean {
    --primary-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
    --primary-color: #06b6d4;
    --primary-hover: #0891b2;
    --secondary-color: #22d3ee;
    --bg-dark: #050d14;
    --bg-shift-1: #0a1620;
    --bg-shift-2: #10142a;
    --bg-card: rgba(8, 20, 35, 0.85);
    --bg-glass: rgba(6, 182, 212, 0.06);
    --bg-glass-hover: rgba(6, 182, 212, 0.12);
    --shadow-glow: 0 0 30px rgba(6, 182, 212, 0.2);
    --border-color: rgba(6, 182, 212, 0.15);
    --border-glass: rgba(6, 182, 212, 0.2);
}

/* Cyberpunk */
body.theme-cyberpunk {
    --primary-gradient: linear-gradient(135deg, #f0e130 0%, #00ff88 50%, #00e5ff 100%);
    --primary-color: #00ff88;
    --primary-hover: #00cc6a;
    --secondary-color: #00e5ff;
    --bg-dark: #0a0a0f;
    --bg-shift-1: #0e1410;
    --bg-shift-2: #0a1218;
    --bg-card: rgba(12, 12, 20, 0.9);
    --bg-glass: rgba(0, 255, 136, 0.05);
    --bg-glass-hover: rgba(0, 255, 136, 0.1);
    --shadow-glow: 0 0 30px rgba(0, 255, 136, 0.15);
    --border-color: rgba(0, 255, 136, 0.12);
    --border-glass: rgba(0, 255, 136, 0.18);
    --text-primary: #e0ffe0;
}

/* Nord */
body.theme-nord {
    --primary-gradient: linear-gradient(135deg, #5e81ac 0%, #81a1c1 100%);
    --primary-color: #5e81ac;
    --primary-hover: #4c6a8d;
    --secondary-color: #88c0d0;
    --bg-dark: #2e3440;
    --bg-shift-1: #343e4e;
    --bg-shift-2: #303a4a;
    --bg-card: rgba(46, 52, 64, 0.9);
    --bg-glass: rgba(94, 129, 172, 0.08);
    --bg-glass-hover: rgba(94, 129, 172, 0.15);
    --shadow-glow: 0 0 20px rgba(94, 129, 172, 0.15);
    --border-color: rgba(216, 222, 233, 0.1);
    --border-glass: rgba(216, 222, 233, 0.15);
    --text-primary: #eceff4;
    --text-secondary: rgba(216, 222, 233, 0.8);
    --text-muted: rgba(216, 222, 233, 0.4);
}

/* --- LIGHT THEMES --- */

/* Arctic Light */
body.theme-arctic {
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #818cf8;
    --bg-dark: #f0f4f8;
    --bg-shift-1: #e8eefa;
    --bg-shift-2: #eef0ff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(0, 0, 0, 0.04);
    --bg-glass-hover: rgba(0, 0, 0, 0.08);
    --text-primary: #1e293b;
    --text-secondary: rgba(30, 41, 59, 0.7);
    --text-muted: rgba(30, 41, 59, 0.4);
    --border-color: rgba(0, 0, 0, 0.1);
    --border-glass: rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.15);
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --info: #2563eb;
}

/* Lavender Light */
body.theme-lavender {
    --primary-gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    --primary-color: #a855f7;
    --primary-hover: #9333ea;
    --secondary-color: #c084fc;
    --bg-dark: #f5f0ff;
    --bg-shift-1: #f0eaff;
    --bg-shift-2: #faf0f8;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(168, 85, 247, 0.05);
    --bg-glass-hover: rgba(168, 85, 247, 0.1);
    --text-primary: #1e1533;
    --text-secondary: rgba(30, 21, 51, 0.7);
    --text-muted: rgba(30, 21, 51, 0.4);
    --border-color: rgba(168, 85, 247, 0.12);
    --border-glass: rgba(168, 85, 247, 0.18);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 30px rgba(168, 85, 247, 0.15);
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --info: #7c3aed;
}

/* Mint Light */
body.theme-mint {
    --primary-gradient: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
    --primary-color: #14b8a6;
    --primary-hover: #0d9488;
    --secondary-color: #2dd4bf;
    --bg-dark: #f0fdf9;
    --bg-shift-1: #e8f8f6;
    --bg-shift-2: #eafaff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(20, 184, 166, 0.05);
    --bg-glass-hover: rgba(20, 184, 166, 0.1);
    --text-primary: #0f2b26;
    --text-secondary: rgba(15, 43, 38, 0.7);
    --text-muted: rgba(15, 43, 38, 0.4);
    --border-color: rgba(20, 184, 166, 0.12);
    --border-glass: rgba(20, 184, 166, 0.18);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 30px rgba(20, 184, 166, 0.15);
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --info: #0891b2;
}

/* Light theme fix: select options need dark bg */
body.theme-arctic select option,
body.theme-lavender select option,
body.theme-mint select option {
    background-color: #ffffff;
    color: #1e293b;
}

/* Light theme fix: message own text stays white */
body.theme-arctic .message-own,
body.theme-lavender .message-own,
body.theme-mint .message-own {
    color: #ffffff;
}

body.theme-arctic .message-own .message-content,
body.theme-arctic .message-own .message-author,
body.theme-arctic .message-own .message-time,
body.theme-lavender .message-own .message-content,
body.theme-lavender .message-own .message-author,
body.theme-lavender .message-own .message-time,
body.theme-mint .message-own .message-content,
body.theme-mint .message-own .message-author,
body.theme-mint .message-own .message-time {
    color: #ffffff;
}

/* Light theme: modal backgrounds */
body.theme-arctic .modal,
body.theme-lavender .modal,
body.theme-mint .modal {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
}

/* Light theme: mobile sidebar backgrounds */
@media (max-width: 768px) {

    body.theme-arctic .activity-sidebar,
    body.theme-arctic .sidebar {
        background: #f0f4f8 !important;
    }

    body.theme-lavender .activity-sidebar,
    body.theme-lavender .sidebar {
        background: #f5f0ff !important;
    }

    body.theme-mint .activity-sidebar,
    body.theme-mint .sidebar {
        background: #f0fdf9 !important;
    }

    body.theme-arctic .message-form,
    body.theme-lavender .message-form,
    body.theme-mint .message-form {
        background: rgba(255, 255, 255, 0.95) !important;
    }
}

/* ============================================
   ANIMATED BACKGROUND GRADIENT BLOBS
   ============================================ */

body.dashboard-page::before,
body.dashboard-page::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    pointer-events: none;
    z-index: -1;
    will-change: transform, filter;
}

body.dashboard-page::before {
    width: 60vmax;
    height: 60vmax;
    background: var(--primary-color);
    opacity: 0.08;
    top: -20%;
    left: -10%;
    animation: blobDrift1 15s ease-in-out infinite alternate, blobHue 30s ease-in-out infinite;
}

body.dashboard-page::after {
    width: 50vmax;
    height: 50vmax;
    background: var(--secondary-color);
    opacity: 0.06;
    bottom: -20%;
    right: -10%;
    animation: blobDrift2 18s ease-in-out infinite alternate, blobHue 30s ease-in-out infinite reverse;
}

@keyframes blobDrift1 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(15vw, 20vh) scale(1.1);
    }

    66% {
        transform: translate(-10vw, 10vh) scale(0.95);
    }

    100% {
        transform: translate(20vw, -10vh) scale(1.05);
    }
}

@keyframes blobDrift2 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(-20vw, -15vh) scale(1.08);
    }

    66% {
        transform: translate(10vw, -20vh) scale(0.92);
    }

    100% {
        transform: translate(-15vw, 10vh) scale(1.1);
    }
}

@keyframes blobHue {
    0% {
        filter: blur(100px) hue-rotate(0deg);
    }

    25% {
        filter: blur(100px) hue-rotate(15deg);
    }

    50% {
        filter: blur(100px) hue-rotate(0deg);
    }

    75% {
        filter: blur(100px) hue-rotate(-15deg);
    }

    100% {
        filter: blur(100px) hue-rotate(0deg);
    }
}

/* ============================================
   MODAL TABS & LISTS
   ============================================ */

.tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-glass);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    background: var(--bg-card);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-select-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    background: var(--bg-glass);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-select-item {
    padding: 8px;
    border-radius: 6px;
    background: var(--bg-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-select-item:hover {
    background: var(--bg-glass-hover);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

@media (max-width: 1024px) {
    .activity-sidebar {
        display: none;
    }
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

@media (max-width: 1024px) {
    .activity-sidebar {
        display: none;
        /* Hide activity panel on smaller screens for now */
    }
}

/* ============================================
   PHONE RESPONSIVE (max-width: 768px)
   ============================================ */

@media (max-width: 768px) {

    /* --- HEADER --- */
    .main-header {
        padding: 0 12px;
        height: 54px;
    }

    .header-right {
        gap: 4px;
    }

    .header-center {
        position: static;
        transform: none;
    }

    .header-right .btn-icon {
        padding: 8px;
    }

    .user-info {
        padding: 4px 8px;
        gap: 8px;
    }

    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .user-details {
        display: none;
    }

    .logo-text span {
        display: none;
    }

    .logo-text img {
        width: 28px !important;
        height: 28px !important;
    }

    /* Show hamburger menu on mobile */
    .menu-toggle {
        display: flex !important;
    }

    /* Show activity toggle on mobile too */
    .sidebar-toggle-desktop {
        display: flex !important;
        margin-right: 4px !important;
        padding: 8px !important;
    }

    /* --- DASHBOARD LAYOUT --- */
    .dashboard-page {
        padding-top: 54px;
    }

    .dashboard-layout {
        height: calc(100vh - 54px);
        height: calc(100dvh - 54px);
    }

    /* --- ACTIVITY SIDEBAR (LEFT) --- */
    .activity-sidebar {
        display: flex !important;
        position: fixed;
        top: 54px;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid var(--border-color);
        background: #191928 !important;
    }

    .activity-sidebar.closed {
        transform: translateX(-100%);
        width: 280px;
        opacity: 1;
        border: none;
    }

    .activity-sidebar:not(.closed) {
        transform: translateX(0);
    }

    /* --- ROOMS SIDEBAR (RIGHT) --- */
    .sidebar {
        position: fixed;
        top: 54px;
        right: 0;
        bottom: 0;
        width: 300px;
        z-index: 200;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        background: #191928 !important;
        backdrop-filter: none;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.closed {
        transform: translateX(100%);
        width: 300px;
    }

    .sidebar-close {
        display: flex;
    }

    /* --- CHAT AREA --- */
    .chat-area {
        width: 100%;
        min-width: 0;
        height: calc(100vh - 54px);
        height: calc(100dvh - 54px);
        overflow: hidden;
    }

    .chat-container {
        display: flex;
        flex-direction: column;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }

    .messages-container {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 10px;
        gap: 6px;
    }

    .message-form {
        flex-shrink: 0;
        background: #191928;
        border-top: 1px solid var(--border-color);
        z-index: 10;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .chat-header {
        padding: 12px 14px;
        gap: 8px;
    }

    .chat-header h2 {
        font-size: 15px;
    }

    .chat-members {
        display: none;
    }

    /* Messages */
    .messages-container {
        padding: 10px;
        gap: 6px;
    }

    .message {
        max-width: 88%;
        padding: 6px 10px;
        font-size: 14px;
    }

    .message-header {
        gap: 6px;
    }

    .message-author {
        font-size: 12px;
    }

    .message-time {
        font-size: 10px;
    }

    /* Link previews on mobile */
    .link-preview-embed {
        max-width: 100%;
    }

    .link-preview-image {
        max-height: 150px;
    }

    /* --- MESSAGE FORM --- */
    .message-form {
        padding: 8px 10px;
        gap: 6px;
    }

    .message-form input[type="text"] {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
        padding: 10px 14px;
    }

    .message-form .btn {
        padding: 10px;
        flex-shrink: 0;
    }

    /* Mention dropdown */
    .mention-dropdown {
        bottom: 100%;
        max-height: 180px;
        width: calc(100% - 20px);
        left: 10px;
    }

    /* Typing indicator */
    .typing-indicator {
        padding: 2px 10px;
        font-size: 11px;
    }

    /* --- MODALS --- */
    .modal-content {
        width: 95%;
        max-height: 85vh;
        margin: 10px auto;
        padding: 16px;
    }

    .modal-header h2 {
        font-size: 16px;
    }

    /* --- FLASH NOTIFICATIONS --- */
    .flash-container {
        top: calc(54px + 8px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 320px;
        width: calc(100% - 24px);
    }

    /* --- EMPTY STATE --- */
    .empty-state {
        padding: 24px;
    }

    .empty-state h2 {
        font-size: 18px;
    }

    .empty-state svg {
        width: 60px;
        height: 60px;
    }

    /* --- OVERLAY BACKDROP --- */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 54px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
    }

    .mobile-overlay.active {
        display: block;
    }

    /* File messages on mobile */
    .media-preview img,
    .media-preview video {
        max-width: 100%;
    }

    .media-preview audio {
        width: 100%;
    }
}

/* ============================================
   PROFILE MODAL - LARGE AVATAR
   ============================================ */

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.profile-avatar-large:hover {
    transform: scale(1.05);
}

.profile-avatar-large .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 50%;
}

.profile-avatar-large:hover .profile-avatar-overlay {
    opacity: 1;
}

/* ============================================
   USER POPUP CARD (Discord-style)
   ============================================ */

.user-popup-card {
    position: fixed;
    z-index: 300;
    width: 300px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9) translateY(10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

.user-popup-card.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.user-popup-banner {
    height: 70px;
    background: var(--primary-gradient);
    position: relative;
    overflow: hidden;
}

.user-popup-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.3) 100%);
}

.user-popup-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    margin: -36px auto 0 auto;
    border: 4px solid var(--bg-card);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.user-popup-info {
    padding: 14px 24px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.user-popup-name {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.user-popup-role {
    font-size: 11px;
}

.user-popup-status {
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-popup-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.user-popup-status.status-online::before {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.user-popup-status.status-away::before {
    background: var(--warning);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.user-popup-status.status-offline::before {
    background: var(--text-muted);
}

.user-popup-bio {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    width: 100%;
}

/* Upload progress in chat */
.message-uploading {
    opacity: 0.85;
}

.upload-progress-chat {
    min-width: 220px;
    max-width: 320px;
}

.upload-progress-chat-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.upload-progress-chat-info svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.upload-progress-chat-filename {
    color: var(--text-primary, #fff);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.upload-progress-chat-percent {
    color: var(--accent, #6c9fff);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.upload-progress-chat-track {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary, rgba(255,255,255,0.1));
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-chat-fill {
    height: 100%;
    width: 0%;
    background: var(--accent, #6c9fff);
    border-radius: 2px;
    transition: width 0.15s ease;
}