/* Telegram Clone CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #0088cc;
    --primary-dark: #006699;
    --secondary-color: #f5f5f5;
    --text-color: #333;
    --text-light: #666;
    --border-color: #ddd;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ecf0f1;
    --message-bg: #e3f2fd;
    --message-sent: #0088cc;
    --message-received: #ffffff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
}

/* Auth Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.5s ease-out;
}

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

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 10px;
}

.auth-header p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-light);
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Chat Interface */
.chat-container {
    display: flex;
    height: 100vh;
    background: white;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar, .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.user-details {
    display: flex;
    flex-direction: column;
}

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

.user-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

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

.search-bar {
    padding: 15px 20px;
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    font-size: 0.9rem;
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-bar i {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.conversation-item.active {
    background: rgba(0, 136, 204, 0.2);
}

.conversation-details {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.conversation-preview {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.conversation-time {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
}

.unread-badge {
    background: var(--primary-color);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7rem;
    min-width: 18px;
    text-align: center;
}

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

.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.welcome-content {
    text-align: center;
    color: var(--text-light);
}

.welcome-content i {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-content h2 {
    margin-bottom: 10px;
    color: var(--text-color);
}

.chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-details {
    display: flex;
    flex-direction: column;
}

.chat-name {
    font-weight: 600;
    font-size: 1rem;
}

.chat-status {
    font-size: 0.8rem;
    color: var(--text-light);
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    animation: messageSlide 0.3s ease-out;
}

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

.message.sent {
    align-self: flex-end;
    background: var(--message-sent);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received {
    align-self: flex-start;
    background: var(--message-received);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-content {
    margin-bottom: 4px;
    line-height: 1.4;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    opacity: 0.7;
}

.message-time {
    margin-left: auto;
}

.message-input-container {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.message-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 25px;
    padding: 8px;
}

.message-input textarea {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    outline: none;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.9rem;
    max-height: 100px;
}

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

.send-btn:hover {
    background: var(--primary-dark) !important;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease-in;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-light);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.search-users input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.user-item:hover {
    background: var(--secondary-color);
}

.user-item-details {
    flex: 1;
}

.user-item-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.user-item-username {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .auth-card {
        padding: 30px 20px;
    }
    
    .message {
        max-width: 85%;
    }
}

/* Loading and Error States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-light);
}

.error {
    background: var(--danger-color);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
    text-align: center;
}

.success {
    background: var(--success-color);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
    text-align: center;
}

/* File Upload */
.file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 136, 204, 0.1);
    border-radius: 8px;
    margin: 8px 0;
    font-size: 0.8rem;
}

.file-preview i {
    color: var(--primary-color);
}

.file-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    margin-left: auto;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--message-received);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 70%;
    align-self: flex-start;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}
