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

:root {
    --primary: #07c160;
    --primary-dark: #06ad56;
    --bg: #ededed;
    --white: #fff;
    --text: #333;
    --text-light: #999;
    --border: #e5e5e5;
    --danger: #fa5151;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

.auth-container {
    width: 90%;
    max-width: 400px;
    background: var(--white);
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: var(--shadow);
}

.auth-logo { text-align: center; margin-bottom: 30px; }
.logo-icon { font-size: 48px; margin-bottom: 10px; }
.auth-logo h1 { font-size: 24px; color: var(--text); }
.auth-logo p { color: var(--text-light); font-size: 14px; margin-top: 5px; }

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

.auth-tabs .tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-size: 16px;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .2s;
}

.auth-tabs .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.auth-form { display: none; }
.auth-form.active { display: block; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--text-light); }
.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color .2s;
}
.form-group input:focus { border-color: var(--primary); }

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all .2s;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px 8px; }

.auth-message {
    margin-top: 16px;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    display: none;
}
.auth-message.error { background: #fef0f0; color: var(--danger); }
.auth-message.success { background: #f0f9eb; color: var(--primary); }

/* Main App */
.main-app {
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--white);
    position: relative;
}

.page { display: none; flex: 1; overflow-y: auto; padding-bottom: 60px; }
.page.active { display: block; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.page-header h2 { font-size: 18px; font-weight: 600; }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    border: none;
    background: none;
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
    position: relative;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 22px; margin-bottom: 2px; }

.badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 24px);
    background: var(--danger);
    color: var(--white);
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Conversation List */
.conversation-list, .friend-list { }
.conv-item, .friend-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: background .15s;
    border-bottom: 1px solid #f5f5f5;
}
.conv-item:hover, .friend-item:hover { background: #f9f9f9; }
.conv-item .avatar, .friend-item .avatar {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 12px;
    flex-shrink: 0;
}
.conv-info, .friend-info { flex: 1; min-width: 0; }
.conv-info .name, .friend-info .name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}
.conv-info .preview {
    font-size: 13px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-meta { text-align: right; flex-shrink: 0; }
.conv-meta .time { font-size: 12px; color: var(--text-light); }
.conv-meta .unread {
    display: inline-block;
    background: var(--danger);
    color: var(--white);
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    line-height: 18px;
    text-align: center;
    margin-top: 4px;
}

/* Friend Requests */
.friend-requests {
    background: #fff8e6;
    padding: 12px 20px;
    border-bottom: 1px solid #ffe58f;
}
.friend-requests h4 { font-size: 14px; margin-bottom: 8px; color: #d48806; }
.request-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
}
.request-item .avatar { width: 36px; height: 36px; border-radius: 6px; margin-right: 10px; }
.request-item .name { flex: 1; font-size: 14px; }
.request-actions { display: flex; gap: 8px; }
.request-actions button {
    padding: 4px 12px;
    border-radius: 4px;
    border: none;
    font-size: 13px;
    cursor: pointer;
}
.btn-accept { background: var(--primary); color: var(--white); }
.btn-reject-req { background: #f5f5f5; color: var(--text-light); }

/* Profile */
.profile-card {
    display: flex;
    align-items: center;
    padding: 24px 20px;
    background: var(--white);
    margin-bottom: 10px;
}
.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    margin-right: 16px;
}
.profile-info h3 { font-size: 20px; margin-bottom: 4px; }
.profile-info p { color: var(--text-light); font-size: 14px; }

.menu-list { background: var(--white); }
.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    font-size: 15px;
}
.menu-item .arrow { color: var(--text-light); font-size: 18px; }

/* Chat Room */
.chat-room {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background: var(--bg);
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
}
.btn-back {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 0 8px;
    color: var(--text);
}
.chat-peer-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    margin-right: 10px;
}
.chat-header span { flex: 1; font-size: 16px; font-weight: 500; }

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.msg-item {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
}
.msg-item.mine { flex-direction: row-reverse; }
.msg-item .msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    flex-shrink: 0;
}
.msg-item:not(.mine) .msg-avatar { margin-right: 8px; }
.msg-item.mine .msg-avatar { margin-left: 8px; }

.msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 15px;
    word-break: break-word;
    line-height: 1.4;
}
.msg-item:not(.mine) .msg-bubble { background: var(--white); }
.msg-item.mine .msg-bubble { background: #95ec69; }
.msg-item.pending .msg-bubble { opacity: 0.75; }
.msg-item.failed .msg-bubble { background: #ffebeb; }
.msg-bubble img { max-width: 200px; border-radius: 4px; cursor: pointer; }
.msg-bubble video { max-width: 240px; border-radius: 4px; }
.msg-status {
    display: block;
    font-size: 11px;
    color: rgba(0,0,0,.35);
    margin-top: 4px;
    text-align: right;
}
.msg-status.fail { color: var(--danger); }
.msg-uploading {
    padding: 20px 30px;
    color: var(--text-light);
    font-size: 13px;
}
.msg-time { font-size: 11px; color: var(--text-light); margin-top: 4px; text-align: center; }

.chat-input-bar {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--white);
    border-top: 1px solid var(--border);
    gap: 8px;
}
.chat-input-bar input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 15px;
    outline: none;
}
.btn-send {
    padding: 8px 16px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}
.modal-content {
    background: var(--white);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; }
.btn-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 20px; }

.search-results { margin-top: 12px; }
.search-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}
.search-item .avatar { width: 40px; height: 40px; border-radius: 6px; margin-right: 10px; }
.search-item .name { flex: 1; }
.search-item button {
    padding: 6px 14px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}
.empty-state p { font-size: 16px; margin-bottom: 8px; }
.empty-state span { font-size: 13px; }

/* Video Call */
.call-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #1a1a1a;
    z-index: 500;
}
.call-container { width: 100%; height: 100%; position: relative; }
.remote-video { width: 100%; height: 100%; }
.remote-video video { width: 100%; height: 100%; object-fit: cover; }
.local-video {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 120px;
    height: 160px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,.3);
}
.local-video video { width: 100%; height: 100%; object-fit: cover; }
.call-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--white);
}
.call-info img { width: 80px; height: 80px; border-radius: 12px; margin-bottom: 12px; }
.call-info p { margin: 4px 0; }
.call-actions {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
}
.call-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.call-btn.accept { background: var(--primary); }
.call-btn.reject { background: var(--danger); color: var(--white); }

.incoming-call .call-modal { text-align: center; padding: 30px; }
.incoming-call img { width: 72px; height: 72px; border-radius: 12px; margin-bottom: 12px; }
.incoming-call .call-actions { position: static; transform: none; justify-content: center; margin-top: 20px; }

/* Admin Styles */
.admin-layout {
    display: flex;
    min-height: 100vh;
}
.admin-sidebar {
    width: 220px;
    background: #001529;
    color: #fff;
    flex-shrink: 0;
}
.admin-sidebar .logo {
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.admin-sidebar nav a {
    display: block;
    padding: 14px 20px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    transition: all .2s;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active {
    color: #fff;
    background: var(--primary);
}
.admin-main { flex: 1; background: #f0f2f5; }
.admin-header {
    background: var(--white);
    padding: 16px 24px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.admin-content { padding: 24px; }

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.stat-card .label { color: var(--text-light); font-size: 14px; }
.stat-card .value { font-size: 28px; font-weight: 600; margin-top: 8px; color: var(--primary); }

.data-table {
    width: 100%;
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    border-collapse: collapse;
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.data-table th { background: #fafafa; font-weight: 600; }
.data-table tr:hover { background: #fafafa; }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.status-badge.active { background: #f0f9eb; color: var(--primary); }
.status-badge.disabled { background: #fef0f0; color: var(--danger); }

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}
.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 4px;
    cursor: pointer;
}
.pagination button.active { background: var(--primary); color: var(--white); border-color: var(--primary); }

.admin-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
}
.admin-login-box {
    width: 400px;
    background: var(--white);
    padding: 40px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.admin-login-box h2 { text-align: center; margin-bottom: 30px; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.toolbar input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 240px;
}

@media (max-width: 768px) {
    .admin-sidebar { display: none; }
    .stat-cards { grid-template-columns: 1fr 1fr; }
}
