@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

/* --- App Container (Mobile App Layout) --- */
.app-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    background: #fff;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

@media (min-width: 600px) {
    .app-container {
        height: 90vh;
        border-radius: 20px;
    }
}

/* --- Views --- */
.main-views {
    flex: 1;
    position: relative;
    overflow: hidden;
}
.view-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    flex-direction: column;
    background: #f8fafc;
}
.view-panel.active {
    display: flex;
}
.view-header {
    background: #fff;
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
    z-index: 10;
}
.view-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

/* --- Lists --- */
.list-container {
    flex: 1;
    overflow-y: auto;
}
.list-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.2s;
}
.list-item:hover { background: #f8fafc; }
.avatar-md {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;
    background: #e2e8f0;
}
.item-info {
    flex: 1;
    overflow: hidden;
}
.item-title {
    font-size: 1rem;
    font-weight: 500;
    color: #1e293b;
    margin-bottom: 4px;
}
.item-subtitle {
    font-size: 0.85rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}
.status-dot {
    width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1;
}
.status-dot.online { background: #22c55e; }

.badge {
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

/* --- Add Friend Section --- */
.add-friend-section {
    padding: 15px 20px;
    display: flex;
    gap: 10px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}
.add-friend-section input {
    flex: 1; padding: 10px 15px; border: 1px solid #cbd5e1; border-radius: 20px; outline: none;
}
.add-friend-section button {
    padding: 0 20px; background: #667eea; color: white; border: none; border-radius: 20px; cursor: pointer;
}

/* --- Bottom Nav --- */
.bottom-nav {
    display: flex;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 10px 0;
    z-index: 20;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #64748b;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}
.nav-item.active {
    color: #667eea;
}
.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}
.nav-label {
    font-size: 0.75rem;
    font-weight: 500;
}
.nav-badge {
    position: absolute;
    top: -2px;
    right: 25%;
    background: #ef4444;
    color: white;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 10px;
}

/* --- Chat Modal --- */
.chat-modal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #f8fafc;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-modal.open {
    transform: translateX(0);
}
.chat-header {
    background: #fff;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    z-index: 10;
}
.btn-back {
    background: transparent; border: none; font-size: 1.5rem; cursor: pointer; color: #1e293b; margin-right: 10px;
}
.chat-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}
.avatar-small {
    width: 35px; height: 35px; border-radius: 50%; object-fit: cover;
}
.chat-header h1 { font-size: 1.1rem; }

/* Messages */
.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.message-wrapper {
    display: flex;
    gap: 10px;
    animation: fadeInUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.message-wrapper.self {
    flex-direction: row-reverse;
}
.message-avatar {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #e2e8f0;
}
.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}
.message-wrapper.self .message-content {
    align-items: flex-end;
}
.msg-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.message-wrapper.self .msg-bubble {
    background: #667eea; color: white; border-top-right-radius: 4px;
}
.message-wrapper.other .msg-bubble {
    background: white; color: #1e293b; border-top-left-radius: 4px; border: 1px solid #e2e8f0;
}
/* Media */
.msg-bubble img, .msg-bubble video { max-width: 100%; border-radius: 10px; margin-top: 5px; }
.msg-bubble audio { max-width: 200px; height: 35px; }
.msg-bubble .file-link { color: inherit; text-decoration: underline; }

.message-wrapper.system {
    align-self: center;
    max-width: 90%;
    font-size: 0.8rem;
    color: #718096;
    background: #e2e8f0;
    padding: 5px 15px;
    border-radius: 20px;
    margin: 10px 0;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Chat Form */
.chat-form {
    background: #fff; padding: 10px 15px; border-top: 1px solid #e2e8f0; display: flex; flex-direction: column; gap: 10px;
}
.chat-input-wrapper { display: flex; justify-content: space-between; align-items: center; }
.media-toolbar { display: flex; gap: 15px; }
.tool-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b; }
.tool-btn:hover { color: #667eea; transform: scale(1.1); }
.chat-input-row { display: flex; gap: 10px; }
.message-input { flex: 1; padding: 10px 15px; border: 1px solid #e2e8f0; border-radius: 20px; outline: none; background: #f8fafc; }
.send-btn { background: #667eea; color: white; border: none; padding: 0 20px; border-radius: 20px; cursor: pointer; }

/* --- Profile Section --- */
.profile-section {
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}
.avatar-wrapper {
    position: relative;
    width: 100px; height: 100px;
    margin-bottom: 20px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.avatar-large {
    width: 100%; height: 100%; object-fit: cover;
}
.avatar-edit-overlay {
    position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.5); color: white; text-align: center; font-size: 0.7rem; padding: 5px 0;
}
.profile-field {
    width: 100%; margin-bottom: 15px;
}
.profile-field label {
    display: block; font-size: 0.8rem; color: #64748b; margin-bottom: 5px;
}
.profile-value {
    padding: 12px; background: #f1f5f9; border-radius: 8px; color: #1e293b;
}
.profile-field input, .profile-field textarea, .profile-field select {
    width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; outline: none; font-family: inherit;
}
.btn-primary {
    width: 100%; padding: 12px; background: #667eea; color: white; border: none; border-radius: 8px; font-weight: 500; cursor: pointer; margin-top: 10px;
}

/* --- WebRTC Call Styles & Overlays --- */
.call-btn { background: transparent; border: none; font-size: 1.2rem; cursor: pointer; padding: 5px; }
.call-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 3000; }
.call-box { background: white; padding: 30px; border-radius: 20px; text-align: center; min-width: 300px; }
.btn-accept { background: #22c55e; color: white; padding: 10px 20px; border: none; border-radius: 20px; cursor: pointer; }
.btn-reject { background: #ef4444; color: white; padding: 10px 20px; border: none; border-radius: 20px; cursor: pointer; }
.active-call-box { background: #1e293b; padding: 30px; border-radius: 20px; text-align: center; width: 90%; max-width: 800px; color: white; }
#call-duration { font-size: 1.2rem; color: #cbd5e1; margin-bottom: 20px; }
.video-container { position: relative; width: 100%; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; }
#remote-video { width: 100%; height: 100%; object-fit: cover; }
#local-video { position: absolute; bottom: 20px; right: 20px; width: 100px; aspect-ratio: 16/9; background: #222; border-radius: 8px; object-fit: cover; border: 2px solid white; }

/* Notification Area */
.notification-area { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.notification-card { background: white; padding: 15px 20px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); border-left: 4px solid #667eea; }

/* Login */
.login-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.login-box { background: white; padding: 40px; border-radius: 20px; text-align: center; width: 90%; max-width: 400px; }
.login-box input { width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; margin-bottom: 20px; outline: none; }
.login-box button { width: 100%; padding: 12px; background: #667eea; color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 500; }

/* Admin Panel Styles */
.admin-panel-box {
    background: white;
    width: 95%;
    max-width: 900px;
    height: 90vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.admin-header {
    background: #1e293b;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h2 { font-size: 1.2rem; }
.admin-header .btn-back { color: white; }

.admin-tabs {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid #cbd5e1;
}

.admin-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.admin-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

.admin-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #fff;
}

.admin-tab-content {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow-y: auto;
    padding: 20px;
    display: none;
}

.admin-tab-content.active {
    display: block;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th, .admin-table td {
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-table tr:hover { background: #f1f5f9; }

.btn-admin-action {
    padding: 4px 8px;
    margin-right: 5px;
    font-size: 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
    background: #667eea;
}
.btn-admin-action.delete { background: #ef4444; }
.btn-admin-action.ban { background: #f59e0b; }
.btn-admin-action.edit { background: #10b981; }
