/* css/style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0084ff;
    --primary-dark: #0073e6;
    --bg-light: #f5f5f5;
    --bg-white: #ffffff;
    --text-dark: #1a1a1a;
    --text-gray: #666666;
    --border: #e0e0e0;
    --message-in: #f0f0f0;
    --message-out: #0084ff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.5;
}

/* Auth Page */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
    background: var(--bg-white);
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
    text-align: center;
}

.auth-card h1 {
    font-size: 32px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    color: var(--text-gray);
    margin-bottom: 30px;
    font-size: 14px;
}

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

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s;
    outline: none;
}

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

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

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

.btn-block {
    width: 100%;
}

.auth-note {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-gray);
}

.alert {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

/* Main App Layout */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-white);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 20px;
}

.user-details {
    flex: 1;
}

.user-details .username {
    font-weight: 600;
    display: block;
    font-size: 16px;
}

.profile-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
}

.logout-btn {
    color: var(--text-gray);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--bg-light);
}

/* Chats List */
.chats-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    cursor: pointer;
}

.chat-item:hover {
    background: var(--bg-light);
}

.chat-item.active {
    background: rgba(0,132,255,0.05);
    border-left: 3px solid var(--primary);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.chat-preview {
    font-size: 13px;
    color: var(--text-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
}

.chat-header {
    padding: 16px 20px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.chat-user {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.chat-avatar.large {
    width: 48px;
    height: 48px;
    font-size: 20px;
}

.chat-user-info {
    flex: 1;
}

.chat-status {
    font-size: 12px;
    color: var(--text-gray);
}

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

.message {
    display: flex;
    width: 100%;
}

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

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

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message-in .message-bubble {
    background: var(--bg-white);
    color: var(--text-dark);
}

.message-out .message-bubble {
    background: var(--message-out);
    color: white;
}

.message-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
}

.message-out .message-time {
    text-align: right;
}

/* Message Input */
.message-input-area {
    padding: 16px 20px;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
}

#message-form {
    display: flex;
    gap: 12px;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

#message-input:focus {
    border-color: var(--primary);
}

.send-btn {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

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

/* Empty States */
.empty-state, .empty-chat, .no-chat-selected {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-gray);
}

.empty-state-large {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-large h2 {
    margin-bottom: 12px;
    color: var(--text-dark);
}

.small {
    font-size: 12px;
    margin-top: 8px;
}

/* Profile Page */
.profile-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.profile-header {
    max-width: 500px;
    margin: 0 auto 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-btn, .logout-link {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    font-size: 14px;
}

.profile-card {
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-white);
    border-radius: 24px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: var(--shadow);
}

.profile-avatar.large {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    font-size: 48px;
}

.profile-name {
    font-size: 28px;
    margin-bottom: 8px;
}

.profile-fullname {
    color: var(--text-gray);
    margin-bottom: 24px;
    font-size: 16px;
}

.profile-info {
    text-align: left;
    margin: 24px 0;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.info-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    width: 100px;
    font-weight: 600;
    color: var(--text-gray);
}

.info-value {
    flex: 1;
    color: var(--text-dark);
}

.profile-note {
    margin-top: 20px;
    color: var(--text-gray);
    font-size: 14px;
}

.not-found {
    text-align: center;
}

.not-found-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .chat-area {
        height: 60vh;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .profile-card {
        margin: 20px;
        padding: 30px 20px;
    }
    
    .info-row {
        flex-direction: column;
    }
    
    .info-label {
        width: auto;
        margin-bottom: 4px;
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        padding: 12px 16px;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .chat-item {
        padding: 12px 16px;
    }
    
    .chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .message-bubble {
        max-width: 90%;
    }
}