:root {
    --bg-color: #081229;
    --card-bg: rgba(16, 28, 56, 0.7);
    --card-border: rgba(100, 150, 255, 0.15);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --accent-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --message-bg: rgba(30, 45, 80, 0.6);
    --my-message-bg: rgba(14, 165, 233, 0.8);
    --sys-message-color: #7dd3fc;
    --glass-blur: 16px;
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    margin: 0;
}

#app {
    width: 100%;
    height: 100vh;
}

/* Background Decorations */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: var(--accent-color);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.shape-3 {
    width: 500px;
    height: 500px;
    background: rgba(14, 165, 233, 0.25);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.shape-4 {
    width: 300px;
    height: 300px;
    background: rgba(139, 92, 246, 0.15);
    bottom: 10%;
    left: 10%;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, 50px) scale(1.1); }
    100% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Glassmorphism Common */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    position: relative;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Login Screen */
.login-card {
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: slideUp 0.6s ease-out;
}

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

.brand h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

input {
    width: 100%;
    padding: 1rem 1.2rem;
    background: rgba(16, 28, 56, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
}

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

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

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--primary-color);
}

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

/* Chat Screen */
.chat-container {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    border-radius: 0;
    border: none;
    display: flex;
    overflow: hidden;
    animation: fadeIn 0.5s ease-in;
}

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

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(16, 28, 56, 0.4);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
}

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

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.badge {
    background: var(--success-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

#users-list {
    list-style: none;
    overflow-y: auto;
    padding: 1rem;
    flex: 1;
}

#users-list::-webkit-scrollbar {
    width: 6px;
}
#users-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.user-item {
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    transition: var(--transition);
}

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

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Chat Main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    padding: 1.2rem 2rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 45, 80, 0.4);
}

.chat-header-info h2 {
    font-size: 1.2rem;
}

.chat-header-info p {
    font-size: 0.85rem;
    color: var(--success-color);
    margin-top: 0.2rem;
}

.text-btn {
    background: transparent;
    color: var(--danger-color);
    width: auto;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.text-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Messages Area */
.messages-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.messages-area::-webkit-scrollbar {
    width: 8px;
}
.messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Message Styles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    align-self: flex-start;
    animation: slideIn 0.3s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes slideIn {
    to { opacity: 1; transform: translateY(0); }
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.message-bubble {
    padding: 1rem 1.2rem;
    background: var(--message-bg);
    border-radius: 16px 16px 16px 4px;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Chat Images */
.chat-image {
    max-width: 400px;
    width: 100%;
    height: auto;
    display: block;
}

/* My Messages */
.message.mine {
    align-self: flex-end;
}

.message.mine .message-meta {
    flex-direction: row-reverse;
}

.message.mine .message-bubble {
    background: var(--my-message-bg);
    border-radius: 16px 16px 4px 16px;
}

/* System Messages */
.sys-message {
    align-self: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--sys-message-color);
    max-width: 100%;
}

/* Input Area */
.message-input-area {
    padding: 1.5rem 2rem;
    background: rgba(16, 28, 56, 0.4);
    border-top: 1px solid var(--card-border);
    display: flex;
    gap: 1rem;
}

.message-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
}

.send-btn {
    width: auto;
    padding: 0 1.5rem;
    border-radius: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
    .sidebar {
        display: none;
    }
    .messages-area {
        padding: 0.8rem;
        gap: 1rem;
    }
    .message {
        max-width: 90%;
    }
    .chat-image {
        max-width: 260px;
    }
    .message-input-area {
        padding: 0.8rem;
        gap: 0.5rem;
    }
    .message-input-area input {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
    .chat-header {
        padding: 0.8rem 1rem;
    }
    .login-card {
        margin: 0 1rem;
        padding: 2rem;
    }
    .close-modal {
        top: 10px;
        right: 20px;
        font-size: 30px;
    }
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.close-modal:hover,
.close-modal:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}
