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

:root {
    --primary: #0088cc;
    --primary-dark: #006699;
    --bg-main: #ffffff;
    --bg-secondary: #f4f4f5;
    --bg-chat: #e5ddd5;
    --text-primary: #000000;
    --text-secondary: #707579;
    --border: #e0e0e0;
    --msg-out: #effdde;
    --msg-in: #ffffff;
    --hover: #f4f4f5;
    --shadow: rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

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

.auth-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    width: 100%;
    max-width: 400px;
}

.auth-container h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 8px;
    font-size: 32px;
    font-weight: 600;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab.active {
    color: var(--primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.form {
    display: none;
}

.form.active {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 136, 204, 0.1);
}

button[type="submit"] {
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

button[type="submit"]:hover {
    background: var(--primary-dark);
}

.error {
    color: #e53935;
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    min-height: 20px;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    background: var(--bg-main);
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: var(--bg-main);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 20px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
}

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

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.search-box {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 20px;
    font-size: 14px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 4px 12px var(--shadow);
}

.search-results.active {
    display: block;
}

.search-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-item:hover {
    background: var(--hover);
}

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

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

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

.chat-item.active {
    background: var(--bg-secondary);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

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

.chat-name {
    font-weight: 500;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

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

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.chat-placeholder h3 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-window.hidden {
    display: none;
}

.chat-header {
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 64px;
}

.back-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
}

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

.chat-header-name {
    font-weight: 600;
    font-size: 16px;
}

.chat-header-status {
    font-size: 13px;
    opacity: 0.9;
}

.chat-header-status.online {
    color: #4caf50;
}

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

.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 1px 2px var(--shadow);
}

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

.message.in {
    align-self: flex-start;
    background: var(--msg-in);
    border-bottom-left-radius: 4px;
}

.message-content {
    margin-bottom: 4px;
    word-wrap: break-word;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

.message-status {
    display: inline-flex;
}

.message-status svg {
    width: 16px;
    height: 16px;
}

.message-status.read svg {
    color: var(--primary);
}

.message-actions {
    position: absolute;
    top: -8px;
    right: 8px;
    background: white;
    border-radius: 8px;
    padding: 4px;
    display: none;
    gap: 4px;
    box-shadow: 0 2px 8px var(--shadow);
}

.message:hover .message-actions {
    display: flex;
}

.message-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.message-action-btn:hover {
    background: var(--hover);
    color: var(--primary);
}

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

.reply-preview {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    margin-bottom: 8px;
    display: none;
}

.reply-preview.active {
    display: block;
}

.reply-preview-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 2px;
}

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

.reply-close {
    position: absolute;
    top: 4px;
    right: 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-secondary);
}

.message-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.message-input textarea {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    max-height: 120px;
}

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

.message-input button {
    background: var(--primary);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-input button:hover {
    background: var(--primary-dark);
}

/* Profile Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 24px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
    font-weight: 600;
    margin: 0 auto 24px;
}

.profile-field {
    margin-bottom: 20px;
}

.profile-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
}

.profile-field input,
.profile-field textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
}

.profile-field textarea {
    resize: vertical;
    min-height: 80px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

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

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        height: 100%;
    }
    
    .sidebar.hidden-mobile {
        transform: translateX(-100%);
    }
    
    .back-btn {
        display: block;
    }
    
    .message {
        max-width: 85%;
    }
}.search-box { position: relative; }
.search-results { position: absolute; top: 100%; left: 16px; right: 16px; margin-top: 8px; border-radius: 8px; z-index: 50; }
.chat-item { cursor: pointer; }
.chat-item.active { background: #e3f2fd; }
.message-reply { background: #e3f2fd; border-left: 3px solid var(--primary); padding: 6px 8px; border-radius: 6px; margin-bottom: 6px; font-size: 13px; color: var(--primary); }
.message-actions { opacity: 0; transition: 0.2s; }
.message:hover .message-actions { opacity: 1; }
