* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.page {
    width: 100%;
    height: 100vh;
    display: none;
    justify-content: center;
    align-items: center;
}

.page.active {
    display: flex;
}

/* Login & Register Styles */
.login-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 40px;
    width: 400px;
    max-width: 90%;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header img {
    width: 50px;
    margin-bottom: 10px;
}

.login-header h2 {
    color: #25d366;
}

.login-form .form-group {
    margin-bottom: 15px;
}

.login-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: #25d366;
}

.error-message {
    background: #ff4444;
    color: white;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    text-align: center;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #25d366;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #128c7e;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.register-link {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    color: #666;
}

.register-link a {
    color: #25d366;
    text-decoration: none;
    cursor: pointer;
}

.register-link a:hover {
    text-decoration: underline;
}

/* Main App Styles */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    background: #fff;
}

.sidebar {
    width: 400px;
    min-width: 300px;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.sidebar-header {
    padding: 15px;
    background: #25d366;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #128c7e;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    transition: opacity 0.3s;
}

.btn-icon:hover {
    opacity: 0.8;
}

.search-bar {
    padding: 10px;
    background: #f8f9fa;
}

.search-bar input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: #f0f0f0;
}

.conversation-item.active {
    background: #e9f0f5;
}

.conversation-item .avatar {
    width: 50px;
    height: 50px;
}

.conversation-info {
    flex: 1;
}

.conversation-info h4 {
    margin-bottom: 5px;
}

.conversation-info .last-message {
    color: #666;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-info .time {
    color: #999;
    font-size: 12px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
}

.chat-header {
    padding: 15px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-user-info h3 {
    margin: 0;
}

.chat-user-info span {
    font-size: 12px;
    color: #25d366;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #e5ddd5;
    background-image: url('https://web.whatsapp.com/img/bg-chat-tile-dark_f5667f7dbe9a4b0b9f5a59cde32fc0ad.png');
}

.message {
    max-width: 70%;
    margin-bottom: 10px;
    padding: 10px 15px;
    border-radius: 10px;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

.message.sent {
    background: #dcf8c6;
    margin-left: auto;
}

.message.received {
    background: white;
    margin-right: auto;
}

.message .time {
    font-size: 11px;
    color: #999;
    float: right;
    margin-left: 10px;
}

.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
}

.chat-input {
    padding: 15px;
    background: #f0f2f5;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

.chat-input input:focus {
    outline: none;
    border-color: #25d366;
}

.btn-send {
    padding: 10px 20px;
    background: #25d366;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-send:hover {
    background: #128c7e;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 5px;
    color: white;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: #25d366;
}

.toast.error {
    background: #ff4444;
}

.toast.info {
    background: #2196F3;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        min-width: unset;
    }
    
    .chat-area {
        display: none;
    }
    
    .chat-area.active {
        display: flex;
    }
}