/* Global Design System & Variables */
:root {
    --bg-gradient: radial-gradient(circle at top left, #1e1b4b, #0f172a, #020617);
    --glass-bg: rgba(30, 41, 59, 0.45);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.03);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    
    --success: #10b981;
    --error: #f43f5e;
    --warning: #f59e0b;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-primary);
    background: var(--bg-gradient);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Typography */
h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-normal);
    padding: 0.75rem 1.5rem;
    outline: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-block {
    width: 100%;
}

/* Authentication Page Styles */
.auth-body {
    padding: 1rem;
}

.auth-container {
    width: 100%;
    max-width: 440px;
    perspective: 1000px;
}

.auth-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: cardEntry 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardEntry {
    from {
        opacity: 0;
        transform: translateY(30px) rotateX(-5deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

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

.logo-container {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 50%;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.auth-header h1 {
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #ffffff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-form .form-group {
    margin-bottom: 1.5rem;
}

.auth-form label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.auth-form input[type="text"] {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-fast);
}

.auth-form input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

.arrow {
    margin-left: 0.5rem;
    transition: transform var(--transition-fast);
}

.btn-primary:hover .arrow {
    transform: translateX(3px);
}

/* Chat Page Layout */
.chat-body {
    width: 100vw;
    height: 100vh;
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
}

.chat-app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
}

/* Sidebar Styling */
.chat-sidebar {
    width: 320px;
    background: rgba(15, 23, 42, 0.8);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

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

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-badge {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.user-list {
    list-style: none;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    cursor: default;
    border: 1px solid transparent;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
}

.user-avatar-dot {
    position: relative;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.user-item.self .user-avatar-dot {
    background: var(--primary-gradient);
}

.online-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: var(--success);
    border: 2px solid #0f172a;
    border-radius: 50%;
}

.user-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.user-item.self .user-item-name {
    color: var(--text-primary);
    font-weight: 600;
}

.user-item.self .user-item-name::after {
    content: " (You)";
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 15, 30, 0.4);
}

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

.user-avatar-placeholder {
    font-size: 1.5rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.current-user-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.status-online {
    font-size: 0.7rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.status-online::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

.btn-logout {
    color: var(--text-secondary);
    transition: var(--transition-fast);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    color: var(--error);
    background: rgba(244, 63, 94, 0.1);
}

/* Chat Main Layout */
.chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.4);
}

.chat-header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
}

.header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-container-small {
    font-size: 1.75rem;
}

.room-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.connected .status-text {
    color: var(--text-secondary);
}

.status-text {
    color: var(--text-muted);
}

/* Message Area Styling */
.message-area-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
}

.message-area {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 100%;
    justify-content: flex-end;
}

/* Message Item styles */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    animation: msgFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.message-wrapper.self {
    align-self: flex-end;
}

.msg-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    margin-left: 0.5rem;
}

.message-wrapper.self .msg-sender {
    align-self: flex-end;
    margin-right: 0.5rem;
    margin-left: 0;
}

.msg-bubble {
    padding: 0.85rem 1.25rem;
    border-radius: 18px;
    font-size: 0.925rem;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
}

.message-wrapper.other .msg-bubble {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

.message-wrapper.self .msg-bubble {
    background: var(--primary-gradient);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.msg-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
    align-self: flex-end;
    margin-top: 0.25rem;
    margin-right: 0.5rem;
}

.message-wrapper.self .msg-meta {
    align-self: flex-start;
    margin-left: 0.5rem;
    margin-right: 0;
}

/* System Notifications */
.message-wrapper.system {
    align-self: center;
    max-width: 100%;
    margin: 0.5rem 0;
}

.system-bubble {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Chat Footer & Input Form */
.chat-footer {
    padding: 1.5rem 2rem;
    background: rgba(15, 23, 42, 0.7);
    border-top: 1px solid var(--glass-border);
}

.message-form .input-container {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 0.35rem 0.35rem 0.35rem 1.25rem;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
}

.message-form .input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.message-form input[type="text"] {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.6rem 0;
}

.message-form input[type="text"]::placeholder {
    color: var(--text-muted);
}

.btn-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    padding: 0;
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.btn-send:hover {
    transform: scale(1.05);
}

.btn-send svg {
    transform: translate(1px, -1px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .chat-sidebar.active {
        transform: translateX(0);
    }
    
    .message-wrapper {
        max-width: 85%;
    }
}

/* Custom Features Styles (Channels, Reactions, Typing) */
.sidebar-section {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.channel-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.channel-item {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.75rem;
    margin: 0.25rem 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.channel-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.channel-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
    font-weight: 600;
    border-color: rgba(99, 102, 241, 0.2);
}

/* Reactions */
.message-wrapper {
    position: relative;
}

.msg-reactions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
}

.reaction-badge:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.reaction-badge.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    color: var(--primary);
}

/* Quick Reaction Picker Hover */
.reaction-picker-trigger {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 10;
}

.message-wrapper.other .reaction-picker-trigger {
    right: -40px;
}

.message-wrapper.self .reaction-picker-trigger {
    left: -40px;
}

.message-wrapper:hover .reaction-picker-trigger {
    opacity: 1;
}

.reaction-picker-btn {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.reaction-picker-btn:hover {
    background: var(--primary-gradient);
    color: white;
}

.emoji-dropdown {
    position: absolute;
    bottom: 34px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 6px;
    display: flex;
    gap: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.emoji-dropdown span {
    cursor: pointer;
    padding: 4px;
    font-size: 1.1rem;
    transition: transform var(--transition-fast);
    border-radius: 4px;
}

.emoji-dropdown span:hover {
    transform: scale(1.25);
    background: rgba(255, 255, 255, 0.1);
}

