/* CSS Variables */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --light: #f1f5f9;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--dark) 0%, #1a1a2e 100%);
    color: var(--light);
    min-height: 100dvh;
    line-height: 1.6;
    overflow: hidden;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Login Screen */
.login-screen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--dark) 0%, #1a1a2e 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.5s ease-out;
}

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

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--gray-light);
    font-size: 1rem;
}

/* Forms */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group input {
    padding: 0.875rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-group input::placeholder {
    color: var(--gray);
}

/* Room Suggestions */
.room-input-wrapper {
    position: relative;
}

.room-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    align-items: center;
}

.suggestion-label {
    font-size: 0.75rem;
    color: var(--gray);
}

.room-chip {
    padding: 0.375rem 0.875rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    color: var(--primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.room-chip:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.btn-full {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.btn-send {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 0;
}

/* Login Features */
.login-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    text-align: center;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.feature span {
    font-size: 1.5rem;
}

.feature p {
    font-size: 0.75rem;
    color: var(--gray-light);
}

/* Chat Screen Layout */
.chat-screen {
    display: flex;
    height: 100dvh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(30, 41, 59, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.room-info {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 20px;
    font-weight: 600;
    color: var(--primary);
}

.users-section {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.users-section h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-light);
    margin-bottom: 1rem;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
}

.users-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
}

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

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

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.user-status {
    font-size: 0.75rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.typing-indicator {
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    color: var(--gray-light);
    font-style: italic;
    min-height: 48px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--dark);
}

/* Chat Header */
.chat-header {
    padding: 1rem 1.5rem;
    background: rgba(30, 41, 59, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-info {
    flex: 1;
}

.header-info h2 {
    font-size: 1.125rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--gray-light);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

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

.welcome-message {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-light);
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.welcome-message h3 {
    color: var(--white);
    margin-bottom: 0.5rem;
}

/* Message Styles */
.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

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

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.system {
    align-self: center;
    max-width: 100%;
}

.message.system .message-content {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--primary);
    font-style: italic;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.message.own .message-avatar {
    background: linear-gradient(135deg, var(--secondary), var(--accent));
}

.message-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
}

.message.own .message-content {
    background: var(--primary);
    color: white;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: 4px;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
}

.message.own .message-header {
    flex-direction: row-reverse;
}

.message-author {
    font-weight: 600;
    font-size: 0.9375rem;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
}

.message-text {
    line-height: 1.5;
    word-wrap: break-word;
}

.message.private .message-content {
    background: rgba(236, 72, 153, 0.1);
    border: 1px solid rgba(236, 72, 153, 0.3);
}

.message.private.own .message-content {
    background: rgba(236, 72, 153, 0.2);
}

/* Input Area */
.input-area {
    padding: 1rem 1.5rem;
    background: rgba(30, 41, 59, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.message-form {
    width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    padding: 0.5rem;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

#message-input {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem;
    color: var(--white);
    font-size: 0.9375rem;
}

#message-input:focus {
    outline: none;
}

.input-hints {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--gray);
}

/* Emoji Modal */
.emoji-modal {
    position: fixed;
    bottom: 100px;
    right: 2rem;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
}

.emoji {
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
    text-align: center;
}

.emoji:hover {
    transform: scale(1.3);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    animation: toastSlide 0.3s ease-out;
    max-width: 300px;
}

@keyframes toastSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

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

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        height: 100dvh;
        z-index: 100;
    }

    .sidebar.open {
        left: 0;
    }

    .message {
        max-width: 90%;
    }

    .login-container {
        padding: 1.5rem;
    }

    .emoji-modal {
        right: 1rem;
        left: 1rem;
        bottom: 80px;
    }

    .emoji-grid {
        grid-template-columns: repeat(9, 1fr);
    }
}

/* Dark/Light Theme Variables */
.light-theme {
    --dark: #f8fafc;
    --dark-light: #e2e8f0;
    --light: #0f172a;
    --gray: #64748b;
    --gray-light: #475569;
}