:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bubble-me: #8b5cf6;
    --bubble-stranger: rgba(51, 65, 85, 0.8);
    --font-family: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(56, 189, 248, 0.1) 0px, transparent 50%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    overflow: hidden;
}

#app {
    width: 100%;
    max-width: 1000px; /* Increased from 800px to fit sidebar */
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.screen {
    width: 100%;
    height: 100%;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.hidden {
    display: none;
    opacity: 0;
    transform: translateY(20px);
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transform: translateY(0);
}

.glassmorphism {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Entry Screen */
#entry-screen .card {
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: bounce 2s infinite ease-in-out;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(to right, #8b5cf6, #38bdf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
    margin-bottom: 2rem;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-main);
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.btn {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.4);
}

.secondary-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.secondary-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Chat Screen */
.chat-layout {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    height: 100%;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    height: 100%;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    background: var(--card-bg);
}

.sidebar h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

#rooms-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

#rooms-list li {
    padding: 1rem;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    font-weight: 500;
}

#rooms-list li:hover {
    background: rgba(139, 92, 246, 0.2);
}

#rooms-list li.active {
    background: rgba(139, 92, 246, 0.4);
    border-color: var(--primary-color);
}

[data-theme="light"] #rooms-list li {
    background: rgba(255, 255, 255, 0.5);
}
[data-theme="light"] #rooms-list li:hover {
    background: rgba(139, 92, 246, 0.1);
}
[data-theme="light"] #rooms-list li.active {
    background: rgba(139, 92, 246, 0.2);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.3);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444; /* Default red */
    box-shadow: 0 0 10px #ef4444;
}

.status-dot.connected {
    background: #10b981; /* Green */
    box-shadow: 0 0 10px #10b981;
}

.status-dot.waiting {
    background: #f59e0b; /* Yellow */
    box-shadow: 0 0 10px #f59e0b;
    animation: pulse 1.5s infinite;
}

.messages-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

/* Custom Scrollbar for messages */
.messages-area::-webkit-scrollbar {
    width: 6px;
}
.messages-area::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.message {
    max-width: 75%;
    padding: 1rem;
    border-radius: 18px;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
}

.message-meta {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    opacity: 0.7;
}

.message.me {
    align-self: flex-end;
    background: var(--bubble-me);
    border-bottom-right-radius: 4px;
    color: #ffffff;
}

.message.stranger {
    align-self: flex-start;
    background: var(--bubble-stranger);
    border-bottom-left-radius: 4px;
}

.system-msg {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0.5rem 0;
    text-align: center;
}

.chat-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.3);
}

#chat-form {
    display: flex;
    gap: 1rem;
}

#chat-form input {
    flex: 1;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

#chat-form input:focus {
    border-color: var(--primary-color);
}

#chat-form input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-btn {
    width: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
}

.icon-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* New features */
.online-stats {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: inline-block;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.typing-indicator {
    padding: 0 1.5rem 1.5rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
    animation: fadeIn 0.3s ease;
    align-self: flex-start;
    display: flex;
    align-items: center;
}

.typing-indicator.hidden {
    display: none;
}

.typing-indicator .dot {
    animation: typing 1.4s infinite both;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1;
    margin-left: 1px;
}

.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --primary-color: #7c3aed;
    --primary-hover: #6d28d9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --bubble-me: #7c3aed;
    --bubble-stranger: rgba(203, 213, 225, 0.8);
}

[data-theme="light"] body {
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(56, 189, 248, 0.1) 0px, transparent 50%);
}

[data-theme="light"] .chat-header,
[data-theme="light"] .chat-footer {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .form-group input,
[data-theme="light"] #chat-form input {
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-main);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .secondary-btn {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

[data-theme="light"] .secondary-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .system-msg {
    color: var(--text-muted);
}

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
    color: var(--text-main);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mobile-only {
    display: none;
}

@media (max-width: 992px) {
    .mobile-only {
        display: block;
        padding: 0.5rem;
    }

    .chat-layout {
        position: relative;
        overflow: hidden;
        gap: 0;
    }

    .chat-container {
        width: 100%;
        min-width: 100%;
    }

    .sidebar {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(100%);
        box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: block;
    }
}

@media (max-width: 768px) {
    .logo-icon {
        font-size: 2rem;
    }
    .logo h1 {
        font-size: 1.8rem;
    }
    .subtitle {
        font-size: 0.95rem;
    }
    .form-group input {
        font-size: 1rem;
        padding: 0.8rem;
    }
    .btn {
        font-size: 0.95rem;
        padding: 0.8rem 1rem;
    }
    .secondary-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    .primary-btn.icon-btn {
        padding: 0 1rem;
    }
    .primary-btn.icon-btn svg {
        width: 20px;
        height: 20px;
    }
    #chat-form input {
        font-size: 0.95rem;
        padding: 0.8rem;
    }
    .message {
        font-size: 0.95rem;
        padding: 0.75rem;
    }
    .chat-header h2 {
        font-size: 1.2rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 50vw;
    }
    .theme-toggle {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    .online-stats {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    .sidebar h3 {
        font-size: 1.1rem;
    }
}
