/* ============================================
   CQQ — Modern Chat UI
   ============================================ */

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

:root {
    --bg: #0a0a0f;
    --surface: #12121a;
    --surface2: #1a1a25;
    --surface3: #222230;
    --border: #2a2a38;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-bg: rgba(99, 102, 241, 0.1);
    --accent: #22d3ee;
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --yellow: #f59e0b;
    --text: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: all 0.2s ease;
}

html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ============ SCREENS ============ */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* ============ LOGIN ============ */
.login-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.08) 0%, transparent 60%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px 36px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    margin-bottom: 8px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 36px;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 14px 16px;
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.form-group input::placeholder { color: var(--text-muted); }
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background: var(--primary-bg); }
.btn-full { width: 100%; }

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}
.send-btn:hover { background: var(--primary-hover); transform: scale(1.05); }

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.icon-btn:hover { background: var(--surface3); color: var(--text); }

/* ============ SPINNER ============ */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-spinner-lg {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 24px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ ERROR ============ */
.error-msg {
    color: var(--red);
    font-size: 13px;
    margin-top: 16px;
    text-align: center;
    min-height: 20px;
}

/* ============ LOGIN FOOTER ============ */
.login-footer { margin-top: 32px; text-align: center; }
.e2e-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--green);
    padding: 6px 14px;
    background: var(--green-bg);
    border-radius: 20px;
}

/* ============ APP LAYOUT ============ */
.app-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: 300px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    color: var(--text);
}

.sidebar-logo svg { color: var(--primary); }

.sidebar-users {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

/* User Items */
.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
}

.user-item:hover { background: var(--surface2); }
.user-item.active { background: var(--primary-bg); border: 1px solid rgba(99,102,241,0.3); }

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.user-status { font-size: 12px; color: var(--text-muted); }
.user-status.online { color: var(--green); }
.user-status.waiting { color: var(--yellow); }

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

.content-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* Verify Card */
.verify-card {
    text-align: center;
    max-width: 420px;
    width: 100%;
}

.verify-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-bg);
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    color: var(--primary);
}

.verify-icon.waiting {
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--primary); }
    50% { border-color: transparent; }
}

.verify-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

.verify-hint {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.verify-code-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 48px;
    font-weight: 700;
    color: var(--yellow);
    letter-spacing: 12px;
    padding: 20px;
    margin: 24px 0;
    background: var(--surface);
    border: 2px dashed var(--yellow);
    border-radius: var(--radius-lg);
    text-align: center;
}

.verify-input-row {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.verify-input-row input {
    flex: 1;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 14px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    text-align: center;
    letter-spacing: 8px;
    outline: none;
    transition: var(--transition);
}

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

/* Info Card */
.info-card {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 40px;
}

.info-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: var(--text-muted);
}

/* ============ CHAT PANEL ============ */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.avatar-sm { width: 36px; height: 36px; font-size: 16px; }

.chat-name { font-size: 15px; font-weight: 600; }
.chat-status { font-size: 12px; color: var(--green); }

/* ============ CHAT MESSAGES ============ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: msgIn 0.2s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.sent { align-self: flex-end; }
.message.received { align-self: flex-start; }

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    max-width: 100%;
}

.message.sent .message-bubble {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: var(--surface2);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

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

.message-image {
    max-width: 280px;
    max-height: 300px;
    margin-top: 8px;
    border-radius: var(--radius);
    object-fit: cover;
    cursor: pointer;
    transition: var(--transition);
}

.message-image:hover { transform: scale(1.02); }

/* ============ CHAT INPUT ============ */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    flex-shrink: 0;
}

.chat-input-area input[type="text"] {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text);
    padding: 12px 18px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.chat-input-area input[type="text"]::placeholder { color: var(--text-muted); }
.chat-input-area input[type="text"]:focus { border-color: var(--primary); }

/* ============ NOTIFICATION ============ */
.notification-bar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green-bg);
    border: 1px solid var(--green);
    color: var(--green);
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    animation: slideDown 0.3s ease;
    box-shadow: var(--shadow);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============ MOBILE ============ */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        width: 100%;
        transform: translateX(0);
        transition: transform 0.3s ease;
    }

    .sidebar.hidden { transform: translateX(-100%); }

    .mobile-only { display: flex; }

    .chat-header-left { cursor: pointer; }

    .message { max-width: 85%; }

    .verify-code-display { font-size: 32px; letter-spacing: 8px; }

    .verify-input-row { flex-direction: column; }
    .verify-input-row input { letter-spacing: 4px; font-size: 20px; }

    .login-card { padding: 32px 24px; }

    .notification-bar {
        left: 16px;
        right: 16px;
        transform: none;
    }
}

@media (max-width: 480px) {
    .login-card { padding: 24px 20px; border-radius: var(--radius-lg); }
    .logo-icon { width: 56px; height: 56px; }
    .login-logo h1 { font-size: 24px; }
    .verify-code-display { font-size: 28px; letter-spacing: 6px; padding: 16px; }
}
