* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0f0f14;
    --bg-card: #1a1a24;
    --bg-input: #252532;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --error: #ef4444;
    --border: #2d2d3a;
}

.wrong-url-warning {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.wrong-url-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    max-width: 480px;
}

.wrong-url-box h2 { color: var(--error); margin-bottom: 16px; }
.wrong-url-box ol { margin: 12px 0 0 20px; line-height: 1.8; }
.wrong-url-box code { background: var(--bg-input); padding: 2px 8px; border-radius: 4px; }
.wrong-url-box a { color: var(--accent); }

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    background-image: 
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
}

/* Auth Page */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header p {
    color: var(--text-muted);
    margin-top: 8px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-form.hidden {
    display: none;
}

.auth-form input {
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

.auth-form input::placeholder {
    color: var(--text-muted);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-form button {
    padding: 14px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-form button:hover {
    background: var(--accent-hover);
}

.auth-form button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.auth-message {
    min-height: 24px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.auth-message.success {
    color: var(--success);
}

.auth-message.error {
    color: var(--error);
}

/* Chat Layout */
.chat-wrapper {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-info {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#current-user {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.logout-btn {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
}

.logout-btn:hover {
    text-decoration: underline;
}

.add-chat-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.add-chat-row {
    display: flex;
    gap: 8px;
}

.add-chat-row input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
}

.add-chat-row input:focus {
    outline: none;
    border-color: var(--accent);
}

.add-chat-row button {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    flex-shrink: 0;
}

.add-chat-row button:hover {
    background: var(--accent-hover);
}

.add-chat-msg {
    font-size: 0.8rem;
    margin-top: 8px;
    min-height: 18px;
}

.add-chat-msg.success { color: var(--success); }
.add-chat-msg.error { color: var(--error); }

.chat-list-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    max-height: 180px;
    overflow-y: auto;
}

.chat-list-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

#chat-list {
    list-style: none;
}

#chat-list li {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.2s;
}

#chat-list li:hover {
    background: var(--bg-input);
}

#chat-list li.active {
    background: var(--accent);
    color: white;
}

.online-users {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.online-users h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

#users-list {
    list-style: none;
}

#users-list li {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

#users-list li::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h3 {
    font-size: 1.25rem;
}

.status {
    font-size: 0.85rem;
}

.status.connected {
    color: var(--success);
}

.status.disconnected {
    color: var(--text-muted);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.own {
    align-self: flex-end;
}

.message .sender {
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 4px;
}

.message.own .sender {
    color: var(--text-muted);
}

.message .bubble {
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.message.own .bubble {
    background: var(--accent);
    border-color: var(--accent);
}

.message .time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-form {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

.chat-form input {
    flex: 1;
    padding: 14px 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

.chat-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-form button {
    padding: 14px 24px;
    background: var(--accent);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-form button:hover {
    background: var(--accent-hover);
}
