/* =====================================================
   bzwaAPP - Telegram-style Blue Theme
   ===================================================== */

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

:root {
    --primary: #0088cc;
    --primary-dark: #006699;
    --primary-light: #54a9eb;
    --secondary: #2AABEE;
    --bg-light: #f0f4f8;
    --bg-chat: #e7ebf0;
    --bg-message-sent: #effdde;
    --bg-message-received: #ffffff;
    --text-dark: #222;
    --text-muted: #707579;
    --text-light: #999;
    --border: #e4e4e4;
    --success: #4caf50;
    --danger: #e53935;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== AUTH PAGES (Login / Register / OTP) ===== */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #0088cc 0%, #2AABEE 100%);
}

.auth-box {
    background: white;
    width: 100%;
    max-width: 420px;
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo .logo-circle {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #0088cc, #2AABEE);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.4rem;
    margin-bottom: 15px;
    box-shadow: 0 8px 20px rgba(0,136,204,0.3);
}

.auth-logo h1 {
    font-size: 1.8rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.auth-logo p {
    color: var(--text-muted);
    margin-top: 5px;
    font-size: 0.95rem;
}

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 13px 15px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    transition: border 0.2s;
    background: #fafafa;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0,136,204,0.4);
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.92rem;
}

.alert-danger { background: #fee; color: #c62828; border-left: 4px solid #e53935; }
.alert-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid #4caf50; }
.alert-info { background: #e3f2fd; color: #1565c0; border-left: 4px solid #0088cc; }

/* OTP input */
.otp-input {
    text-align: center;
    font-size: 1.8rem;
    letter-spacing: 12px;
    font-weight: 600;
}

/* ===== APP LAYOUT (Chat list / Chat window) ===== */
.app-container {
    display: flex;
    height: 100vh;
    background: var(--bg-light);
}

.sidebar {
    width: 380px;
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

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

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

.sidebar-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.sidebar-actions { display: flex; gap: 10px; }

.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;
    font-size: 1rem;
    transition: background 0.2s;
}

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

.search-bar {
    padding: 10px 15px;
    background: #f5f7fa;
    border-bottom: 1px solid var(--border);
}

.search-bar input {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    background: white;
    font-size: 0.95rem;
}

.search-bar input:focus { outline: 2px solid var(--primary); }

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

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.chat-item:hover { background: #f5f7fa; }
.chat-item.active { background: #e3f2fd; }

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
    overflow: hidden;
}

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

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

.chat-info .top-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.chat-info .name {
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-info .time {
    font-size: 0.78rem;
    color: var(--text-light);
    flex-shrink: 0;
    margin-left: 8px;
}

.chat-info .last-msg {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--primary);
    color: white;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== CHAT WINDOW ===== */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    background-image:
        linear-gradient(rgba(231,235,240,0.95), rgba(231,235,240,0.95)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Ccircle cx='40' cy='40' r='1' fill='%230088cc' opacity='0.15'/%3E%3C/svg%3E");
}

.chat-header {
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.chat-header .back-btn {
    display: none;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.4rem;
    cursor: pointer;
}

.chat-header .chat-avatar { width: 42px; height: 42px; font-size: 1.05rem; }

.chat-header .info h4 {
    font-size: 1.05rem;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.chat-header .info .status {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.chat-header .info .status.online { color: var(--success); }

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

.msg-row {
    display: flex;
    max-width: 75%;
}

.msg-row.sent {
    align-self: flex-end;
    justify-content: flex-end;
}

.msg-row.received { align-self: flex-start; }

.msg-bubble {
    padding: 8px 12px 6px 12px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08);
    font-size: 0.95rem;
    line-height: 1.4;
}

.msg-row.sent .msg-bubble {
    background: #d1eaff;
    border-bottom-right-radius: 4px;
}

.msg-row.received .msg-bubble {
    background: white;
    border-bottom-left-radius: 4px;
}

.msg-text { color: var(--text-dark); }

.msg-meta {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 3px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.msg-ticks {
    color: var(--text-light);
    font-size: 0.85rem;
}

.msg-ticks.read { color: var(--primary); }

.chat-input-bar {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-bar input {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid var(--border);
    border-radius: 22px;
    font-size: 0.98rem;
    background: #f5f7fa;
}

.chat-input-bar input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: transform 0.15s;
}

.send-btn:hover { transform: scale(1.08); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.no-chat-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.no-chat-selected .big-icon {
    font-size: 5rem;
    color: var(--primary);
    opacity: 0.4;
    margin-bottom: 20px;
}

.no-chat-selected h3 { color: var(--text-dark); margin-bottom: 10px; }

/* Profile dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 180px;
    margin-top: 5px;
    z-index: 100;
    display: none;
    overflow: hidden;
}

.dropdown-menu.show { display: block; }

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-dark);
    transition: background 0.15s;
}

.dropdown-menu a:hover { background: #f0f4f8; }
.dropdown-menu a i { color: var(--primary); width: 18px; }

/* Profile page */
.profile-container {
    max-width: 600px;
    margin: 30px auto;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.profile-header {
    text-align: center;
    margin-bottom: 30px;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 15px;
    overflow: hidden;
}

.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    margin-bottom: 20px;
    font-weight: 500;
}

/* Contacts page */
.contact-search-result {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.btn-add {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

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

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { width: 100%; }
    .chat-window { display: none; }
    .app-container.chat-open .sidebar { display: none; }
    .app-container.chat-open .chat-window { display: flex; }
    .chat-header .back-btn { display: inline-flex; }
    .auth-box { padding: 30px 22px; }
}
