:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --incoming-msg: rgba(30, 41, 59, 0.8);
    --outgoing-msg: #6366f1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.hidden {
    display: none !important;
}

/* Login Screen */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(15, 23, 42, 0.9);
}

.login-content {
    background: rgba(30, 41, 59, 0.6);
    padding: 3rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: fadeInUp 0.5s ease;
}

.login-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-content p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 12px 12px 12px 45px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-main);
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus {
    border-color: var(--primary-color);
    background: rgba(15, 23, 42, 0.8);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* App Container */
#app-container {
    display: flex;
    width: 95vw;
    height: 90vh;
    border-radius: 24px;
    overflow: hidden;
    gap: 20px;
}

/* Sidebar */
.sidebar {
    width: 350px;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-user {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.5);
    padding: 5px 10px;
    border-radius: 20px;
}

.current-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.search-bar {
    padding: 15px 20px;
    position: relative;
}

.search-bar i {
    position: absolute;
    left: 35px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-bar input {
    width: 100%;
    padding: 10px 10px 10px 40px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    outline: none;
}

.users-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 5px;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-item.active {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.user-avatar {
    position: relative;
    margin-right: 15px;
}

.user-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid #1e293b;
    border-radius: 50%;
}

.user-info h4 {
    font-weight: 500;
    margin-bottom: 2px;
}

.user-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Chat Area */
.chat-area {
    flex: 1;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.active-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 15px 25px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.4);
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-user-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.incoming {
    align-self: flex-start;
    background: var(--incoming-msg);
    border-bottom-left-radius: 4px;
    color: var(--text-main);
}

.message.outgoing {
    align-self: flex-end;
    background: var(--outgoing-msg);
    border-bottom-right-radius: 4px;
    color: white;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
    text-align: right;
}

.input-area {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 10px;
    background: rgba(15, 23, 42, 0.4);
}

#message-form {
    flex: 1;
    display: flex;
    gap: 10px;
}

#message-input {
    flex: 1;
    padding: 12px 20px;
    border-radius: 25px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.6);
    color: white;
    outline: none;
}

#message-input:focus {
    border-color: var(--primary-color);
}

.btn-send {
    background: var(--primary-color);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
}

.btn-send:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
    #app-container {
        flex-direction: column;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .sidebar {
        width: 100%;
        height: 70px; /* Collapsed state needs JS logic for full mobile support, keeping simple for now */
        border-radius: 0;
        /* For simple mobile view, users might need to toggle sidebar. 
           In this simple scope, let's just let it be a sidebar on desktop 
           and maybe full width on mobile if selected? 
           For now, just stack them.
        */
        height: 30%;
    }
    .chat-area {
        height: 70%;
        border-radius: 0;
    }
}
