/* Reset dan Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #333;
    overflow-x: hidden;
}

#app {
    position: relative;
    height: 100vh;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    background: #fff;
}

.screen.active {
    transform: translateX(0);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Login Screen Styles */
#loginScreen {
    background: linear-gradient(135deg, #2196F3 0%, #21CBF3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateX(0);
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 400px;
}

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

.logo h1 {
    color: #2196F3;
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.logo p {
    color: #666;
    font-size: 0.9rem;
}

.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    background: #f5f5f5;
    border-radius: 10px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.tab-btn.active {
    background: #2196F3;
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form.hidden {
    display: none;
}

.auth-form input {
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: #2196F3;
}

.auth-form button {
    padding: 15px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-form button:hover {
    background: #1976D2;
}

/* Chat Screen Styles */
.chat-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: #2196F3;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

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

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

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

.chat-nav {
    background: white;
    display: flex;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.nav-btn {
    flex: 1;
    padding: 15px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.nav-btn.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
}

.view {
    flex: 1;
    display: none;
    overflow-y: auto;
}

.view.active {
    display: block;
}

/* Chat List */
.chat-list {
    padding: 0.5rem 0;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.3s;
    border-bottom: 1px solid #f0f0f0;
}

.chat-item:hover {
    background: #f8f9fa;
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 15px;
    position: relative;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4CAF50;
    border: 2px solid white;
}

.chat-info {
    flex: 1;
}

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

.chat-last-message {
    color: #666;
    font-size: 0.85rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.chat-time {
    color: #999;
    font-size: 0.75rem;
}

.unread-badge {
    background: #2196F3;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Status View */
.status-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.my-status {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.status-avatar {
    position: relative;
    margin-right: 15px;
}

.status-avatar img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.add-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
}

.status-info {
    display: flex;
    flex-direction: column;
}

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

.status-time {
    color: #666;
    font-size: 0.85rem;
}

/* Groups and Friends Views */
.groups-header,
.friends-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.create-group-btn,
.add-friend-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
}

/* Chat Room Screen */
.chat-room {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
}

.room-header {
    background: #2196F3;
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.room-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.room-info h3 {
    margin: 0;
    font-size: 1rem;
}

.room-info span {
    font-size: 0.8rem;
    opacity: 0.8;
}

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

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

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message.sent {
    align-self: flex-end;
    background: #2196F3;
    color: white;
    border-bottom-right-radius: 5px;
}

.message.received {
    align-self: flex-start;
    background: white;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

.message-input-container {
    background: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #e0e0e0;
}

.attach-btn,
.voice-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.attach-btn:hover,
.voice-btn:hover {
    background: #f0f0f0;
}

#messageInput {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    padding: 12px 16px;
    font-size: 1rem;
    outline: none;
}

#messageInput:focus {
    border-color: #2196F3;
}

.send-btn {
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.3s;
}

.send-btn:hover {
    background: #1976D2;
}

/* Responsive Design */
@media (max-width: 768px) {
    .login-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .room-header {
        padding: 0.75rem;
    }
    
    .chat-header {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .auth-form input,
    .auth-form button {
        padding: 12px;
    }
    
    .nav-btn {
        padding: 12px 8px;
        font-size: 0.9rem;
    }
    
    .chat-item {
        padding: 12px 15px;
    }
    
    .message-input-container {
        padding: 10px 15px;
    }
}