/* Design Tokens */
:root {
    --bg-main: #0b0c10;
    --bg-card: rgba(20, 22, 33, 0.65);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-focus: rgba(139, 92, 246, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-violet: #8b5cf6;
    --accent-blue: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    --my-message-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    
    --glow-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
    --glow-shadow-intense: 0 0 25px rgba(139, 92, 246, 0.3);
    
    --status-online: #10b981;
    --status-offline: #ef4444;
}

/* Reset and Core Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Ambient Background Glow */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(150px);
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
    animation: floatGlow 20s infinite alternate ease-in-out;
}

.bg-glow-1 {
    background: radial-gradient(circle, var(--accent-violet) 0%, transparent 70%);
    top: -200px;
    left: -100px;
}

.bg-glow-2 {
    background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
    bottom: -200px;
    right: -100px;
    animation-delay: -10s;
}

@keyframes floatGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Glassmorphism Base Utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
}

.hidden {
    display: none !important;
}

/* Login Overlay Styles */
.overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: var(--glow-shadow);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.logo-area {
    margin-bottom: 35px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--accent-gradient);
    border-radius: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

.logo-icon svg {
    width: 32px;
    height: 32px;
    transform: rotate(-10deg) translate(-2px, 1px);
}

.logo-area h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-area p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Floating Input Group */
.input-group {
    position: relative;
    margin-bottom: 24px;
    width: 100%;
}

.input-group input {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s;
}

.input-group input:focus {
    border-color: var(--accent-violet);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: var(--glow-shadow-intense);
}

.input-group label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.95rem;
}

.input-group input:focus ~ label,
.input-group input:not(:placeholder-shown) ~ label {
    top: -8px;
    left: 12px;
    font-size: 0.75rem;
    color: var(--accent-violet);
    background: #0f1017;
    padding: 0 6px;
    border-radius: 4px;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: var(--accent-gradient);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s;
}

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

.error-msg {
    color: var(--status-offline);
    font-size: 0.85rem;
    margin-top: 12px;
    min-height: 18px;
    font-weight: 400;
}

/* App Wrapper Design */
.app-wrapper {
    display: flex;
    width: 95vw;
    height: 90vh;
    max-width: 1200px;
    max-height: 800px;
    z-index: 5;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    overflow: hidden;
    animation: zoomIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Sidebar Styling */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-glass);
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    background: rgba(16, 18, 27, 0.8);
}

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

.profile-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    color: white;
    font-size: 1.1rem;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.profile-status {
    font-size: 0.75rem;
    font-weight: 400;
}

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

.btn-icon-only {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-icon-only:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

.btn-icon-only svg {
    width: 20px;
    height: 20px;
}

/* Search Box */
.search-box {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-glass);
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    background: rgba(255,255,255,0.02);
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s;
}

.search-box input:focus {
    border-color: var(--accent-violet);
    background: rgba(255,255,255,0.05);
}

/* Sidebar List */
.sidebar-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.list-title {
    padding: 15px 20px 5px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.users-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

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

.user-item.active {
    background: rgba(139, 92, 246, 0.1);
    border-left: 3px solid var(--accent-violet);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.user-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-meta-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.user-meta-status {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-dot.online {
    background: var(--status-online);
}

.status-dot.offline {
    background: var(--text-muted);
}

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

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

/* Chat Area Styling */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    background: rgba(13, 15, 23, 0.5);
    min-height: 0;
}

.chat-header {
    padding: 15px 25px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
}

.channel-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.channel-avatar {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--accent-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.channel-details h2 {
    font-size: 1.05rem;
    font-weight: 600;
}

.channel-details p {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 400;
}

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

.status-online {
    color: var(--status-online);
}

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

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

/* Messages Stream Container */
.messages-container {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

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

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

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

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

.message-sender {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-violet);
    margin-bottom: 4px;
    padding-left: 6px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
}

.me .message-bubble {
    background: var(--my-message-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.others .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border-left: 3px solid var(--accent-violet);
}

.message-time {
    font-size: 0.65rem;
    align-self: flex-end;
    margin-top: 4px;
    padding-right: 4px;
    color: var(--text-muted);
}

.me .message-time {
    color: rgba(255, 255, 255, 0.6);
}

/* System Message (join/leave notifications) */
.message-system {
    align-self: center;
    max-width: 90%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 400;
    animation: fadeIn 0.4s ease forwards;
}

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

/* Typing Indicator Styling */
.typing-indicator {
    padding: 10px 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    min-height: 36px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    display: inline-block;
    animation: dotBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chat Input Footer Styling */
.chat-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--border-glass);
}

.chat-footer form {
    display: flex;
    gap: 12px;
    position: relative;
}

.chat-footer input {
    flex: 1;
    padding: 16px 20px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s;
}

.chat-footer input:focus {
    border-color: var(--accent-violet);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: var(--glow-shadow);
}

.btn-send {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    border: none;
    background: var(--accent-gradient);
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.btn-send:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

.btn-send:active {
    transform: scale(1) translateY(0);
}

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

.menu-toggle-btn {
    display: none;
    margin-right: 15px;
}

.sidebar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        display: block;
        height: 100%;
        width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        overflow: hidden;
    }

    .overlay-container {
        padding: 0;
    }

    .login-card {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100%;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 30px;
        background: #0f1017; /* Solid premium dark background for full-screen login */
    }

    .app-wrapper {
        position: absolute;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        max-width: 100%;
        max-height: 100%;
    }
    
    .sidebar {
        position: absolute;
        top: 0;
        left: -320px;
        width: 320px;
        height: 100%;
        z-index: 100;
        background: rgba(16, 18, 27, 0.98);
        border-radius: 0;
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-header {
        padding: calc(20px + env(safe-area-inset-top)) 20px 20px;
    }
    
    .profile-info {
        display: flex !important;
    }
    
    .search-box {
        display: block !important;
    }
    
    .list-title {
        display: block !important;
    }
    
    .user-meta {
        display: flex !important;
    }
    
    .avatar {
        margin: 0;
    }
    
    .sidebar-list {
        padding: 10px;
    }
    
    .user-item {
        justify-content: flex-start;
        padding: 10px;
    }
    
    .menu-toggle-btn {
        display: flex;
    }

    .chat-area {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .chat-header {
        padding-top: calc(15px + env(safe-area-inset-top));
    }
    
    .messages-container {
        padding: 15px;
    }
    
    .message-wrapper {
        max-width: 85%;
    }

    .chat-footer {
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
    }
}
