/* Modern Chat App CSS - Dark Theme */
:root {
    --primary-gradient: linear-gradient(135deg, #1e1e2f 0%, #2a2a40 100%);
    --secondary-gradient: linear-gradient(135deg, #00ADB5 0%, #00C9CC 100%);
    --accent-gradient: linear-gradient(135deg, #FF6B6B 0%, #FF8E8E 100%);
    --message-sent: linear-gradient(135deg, #00ADB5 0%, #007F87 100%);
    --message-received: linear-gradient(135deg, #2a2a40 0%, #3a3a50 100%);
    --sidebar-bg: rgba(30, 30, 47, 0.95);
    --chat-bg: rgba(42, 42, 64, 0.85);
    --input-bg: rgba(58, 58, 80, 0.9);
    --text-primary: #ffffff;
    --text-secondary: #b8b8b8;
    --text-accent: #00ADB5;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-primary: 0 20px 40px rgba(0, 0, 0, 0.4);
    --shadow-secondary: 0 8px 20px rgba(0, 0, 0, 0.3);
    --border-radius: 20px;
    --border-radius-small: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
    color: var(--text-primary);
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(0, 173, 181, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 107, 107, 0.1) 0%, transparent 50%),
        var(--primary-gradient);
    z-index: -1;
    animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(2deg) scale(1.02); }
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    transition: var(--transition);
}

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

.app-logo {
    font-size: 2rem;
    font-weight: 800;
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
}

.user-section {
    background: var(--input-bg);
    border-radius: var(--border-radius-small);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.user-section h3 {
    margin-bottom: 1rem;
    color: var(--text-accent);
    font-size: 1rem;
    font-weight: 600;
}

.username-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.username-input:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(0, 173, 181, 0.2);
}

.username-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--secondary-gradient);
    border: none;
    border-radius: var(--border-radius-small);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.username-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-secondary);
}

.stats-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-small);
    border: 1px solid var(--border-color);
}

.stat-icon {
    font-size: 1.2rem;
}

.stat-info h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-info span {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--chat-bg);
    backdrop-filter: blur(20px);
}

.chat-header {
    padding: 1.5rem 2rem;
    background: rgba(30, 30, 47, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.connection-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.connection-indicator.connected {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.connection-indicator.disconnected {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

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

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

/* Messages Area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    margin-bottom: 1.5rem;
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    animation-fill-mode: forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message.system {
    justify-content: center;
}

.message-bubble {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    position: relative;
    transition: var(--transition);
    cursor: pointer;
}

.message-bubble:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-secondary);
}

.message.sent .message-bubble {
    background: var(--message-sent);
    color: white;
    border-bottom-right-radius: 8px;
}

.message.received .message-bubble {
    background: var(--message-received);
    border-bottom-left-radius: 8px;
    border: 1px solid var(--border-color);
}

.message.system .message-bubble {
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #ffc107;
    text-align: center;
    font-style: italic;
    max-width: 50%;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

.username {
    font-weight: 600;
}

.timestamp {
    opacity: 0.6;
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Typing Indicator */
.typing-indicator {
    padding: 1rem 2rem;
    min-height: 50px;
    display: flex;
    align-items: center;
    font-style: italic;
    color: var(--text-secondary);
    background: rgba(30, 30, 47, 0.5);
    border-top: 1px solid var(--border-color);
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 0.5rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-accent);
    animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0ms; }
.typing-dot:nth-child(2) { animation-delay: 200ms; }
.typing-dot:nth-child(3) { animation-delay: 400ms; }

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Message Input */
.message-input-container {
    padding: 1.5rem 2rem;
    background: rgba(30, 30, 47, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
}

.message-input-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    background: var(--input-bg);
    border-radius: 25px;
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.message-input-wrapper:focus-within {
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(0, 173, 181, 0.2);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    overflow-y: auto;
}

.message-input::placeholder {
    color: var(--text-secondary);
}

.send-button {
    background: var(--secondary-gradient);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: white;
    font-size: 1.1rem;
}

.send-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-secondary);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-header {
        margin-bottom: 1rem;
    }
    
    .user-section {
        margin-bottom: 1rem;
    }
    
    .stats-section {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .stat-item {
        flex: 1;
        padding: 0.75rem;
    }
    
    .main-chat {
        height: calc(100vh - 200px);
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .chat-title h1 {
        font-size: 1.2rem;
    }
    
    .messages-container {
        padding: 1rem;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .message-input-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .sidebar {
        padding: 0.75rem;
    }
    
    .user-section {
        padding: 1rem;
    }
    
    .stat-item {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .message-bubble {
        max-width: 90%;
        padding: 0.75rem 1rem;
    }
    
    .message-input-wrapper {
        padding: 0.5rem 1rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--text-accent);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Utility Classes */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

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

.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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