:root {
    --bg-deep: #0b141a;
    --surface: #111b21;
    --header-bg: #202c33;
    --bubble-in: #202c33;
    --bubble-out: #005c4b;
    --social-green: #00f5c4;
    --gold: #ffd700;
    --aura-blue: #00d1ff;
    --text-main: #e9edef;
    --text-muted: #8696a0;
    --danger: #ff4b4b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background: #060b0f;
    color: var(--text-main);
    height: 100%;
    width: 100vw;
    overflow: hidden;
}

.app-container {
    width: 100%;
    height: 100%;
    max-width: 1560px;
    margin: 0 auto;
    display: flex;
    background: var(--bg-deep);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
}

/* AUTH / ONBOARDING */
#auth-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, rgba(0, 245, 196, 0.12), var(--bg-deep) 60%);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid rgba(0, 245, 196, 0.28);
    border-radius: 20px;
    padding: 26px 22px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
    max-height: 94vh;
    overflow-y: auto;
}

.auth-logo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid var(--social-green);
    object-fit: cover;
    margin-bottom: 12px;
    box-shadow: 0 0 24px rgba(0, 245, 196, 0.25);
}

.auth-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
}

.auth-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.45;
}

.auth-tabs {
    display: flex;
    gap: 6px;
    background: var(--bg-deep);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.auth-tab-btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.auth-tab-btn.active {
    background: var(--header-bg);
    color: var(--social-green);
}

#qrcode-container {
    background: #fff;
    padding: 14px;
    border-radius: 12px;
    display: inline-flex;
    margin: 6px auto 14px;
}

.phone-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.phone-ddi {
    width: 78px;
    padding: 11px 6px;
    background: var(--header-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: var(--social-green);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.field-input {
    width: 100%;
    padding: 11px 13px;
    background: var(--header-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    margin-bottom: 10px;
}

.field-input:focus {
    border-color: var(--social-green);
}

.btn-primary {
    width: 100%;
    padding: 13px;
    background: var(--social-green);
    color: #03130f;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 245, 196, 0.25);
}

.btn-primary:active { transform: scale(0.98); }

.auth-error {
    background: rgba(255, 75, 75, 0.14);
    border: 1px solid var(--danger);
    color: #ff9c9c;
    border-radius: 10px;
    padding: 9px;
    font-size: 12px;
    margin-bottom: 10px;
    display: none;
}

/* SIDEBAR */
#sidebar {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-deep);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 10;
}

@media (min-width: 900px) {
    #sidebar { width: 35%; min-width: 360px; max-width: 440px; }
}

header {
    height: 60px;
    background: var(--header-bg);
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
}

.nav-tabs {
    display: flex;
    background: var(--header-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 10px 4px;
    text-align: center;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    text-transform: uppercase;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: var(--social-green);
    border-bottom-color: var(--social-green);
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    display: none;
}
.tab-content.active { display: block; }

.chat-item {
    display: flex;
    align-items: center;
    padding: 11px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s;
}
.chat-item:hover, .chat-item.active { background: #182229; }

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    font-size: 19px;
    font-weight: 800;
    position: relative;
}

.online-badge {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #25d366;
    border: 2px solid var(--bg-deep);
}

.chat-info { flex: 1; min-width: 0; }
.chat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.chat-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; margin-left: 6px; }
.chat-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.unread-pill {
    background: var(--social-green);
    color: #03130f;
    font-size: 10px;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* CHAT VIEW */
#chat-view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #0b141a;
    z-index: 20;
    transform: translateX(100%);
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}
#chat-view.active { transform: translateX(0); }
@media (min-width: 900px) {
    #chat-view { position: relative; flex: 1; transform: translateX(0); z-index: 5; }
    .mobile-back { display: none !important; }
}

.messages-box {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: #0b141a;
    background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 0);
    background-size: 22px 22px;
}

.security-banner {
    align-self: center;
    background: rgba(0, 245, 196, 0.09);
    border: 1px solid rgba(0, 245, 196, 0.28);
    border-radius: 10px;
    padding: 7px 12px;
    font-size: 11px;
    color: #b7fff0;
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
    max-width: 92%;
}

.msg {
    max-width: 82%;
    padding: 8px 11px;
    border-radius: 11px;
    font-size: 13.5px;
    line-height: 1.42;
    position: relative;
    word-wrap: break-word;
    cursor: pointer;
}
.msg.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 2px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); color: #fff; border-top-right-radius: 2px; }
.msg.ai-msg { border-left: 3px solid var(--social-green); background: linear-gradient(145deg, #16232b, #0e2c26); }

.msg-sender { font-size: 11px; font-weight: 700; color: var(--aura-blue); margin-bottom: 2px; }
.msg.out .msg-sender { color: var(--social-green); }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 10px; color: rgba(255, 255, 255, 0.55); margin-top: 4px; }

.msg-reaction-badge {
    position: absolute;
    bottom: -9px;
    right: 8px;
    background: #1f2c34;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 1px 6px;
    font-size: 11px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.45);
}

.floating-reaction-bar {
    position: fixed;
    background: #1f2c34;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 24px;
    padding: 6px 12px;
    display: none;
    gap: 10px;
    font-size: 21px;
    z-index: 5000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.65);
}

/* AUDIO PLAYER REAL */
.audio-bubble { display: flex; align-items: center; gap: 9px; min-width: 200px; padding: 3px 0; }
.audio-play-btn {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--social-green); color: #03130f;
    border: none; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px; flex-shrink: 0;
}
.audio-speed-btn {
    background: rgba(255, 255, 255, 0.16); border: none; color: #fff;
    padding: 3px 7px; border-radius: 10px; font-size: 10px; font-weight: 700; cursor: pointer;
}

/* PIX CARD */
.pix-card {
    background: #141e24;
    border: 1px solid var(--social-green);
    border-radius: 10px;
    padding: 10px;
    margin-top: 4px;
    text-align: center;
}
.pix-qr-box {
    background: #fff;
    padding: 8px;
    border-radius: 8px;
    display: inline-block;
    margin: 8px auto;
}
.pix-btn {
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    background: var(--social-green);
    color: #03130f;
    border: none;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    font-size: 11.5px;
}

/* POLL */
.poll-opt {
    background: rgba(11, 20, 26, 0.75);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.poll-bar {
    position: absolute; inset: 0;
    background: rgba(0, 245, 196, 0.18);
    width: 0%;
    transition: width 0.3s ease;
}
.poll-row {
    position: relative;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    gap: 10px;
}

/* INPUT BAR & RECORDING BAR */
.input-bar {
    min-height: 58px;
    background: var(--header-bg);
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}
.input-bar input {
    flex: 1;
    min-width: 0;
    background: #2a3942;
    border: none;
    outline: none;
    border-radius: 22px;
    padding: 10px 14px;
    color: #fff;
    font-size: 14px;
}
.action-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: transparent; border: none;
    color: var(--text-muted); font-size: 20px;
    display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.send-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--social-green); border: none; color: #03130f;
    font-size: 18px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
}

.rec-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: #281419;
    border-top: 1px solid var(--danger);
    padding: 8px 14px;
    gap: 10px;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }

/* POPUP PANELS & MODALS */
.popup-panel {
    position: absolute;
    bottom: 64px; left: 10px; right: 10px;
    background: #1f2c34;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.65);
    display: none;
    z-index: 100;
    border: 1px solid rgba(255,255,255,0.1);
}
.popup-panel.show { display: block; }
.attach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.attach-item { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; padding: 6px; border-radius: 8px; }
.attach-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; }
.emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; font-size: 22px; text-align: center; max-height: 170px; overflow-y: auto; }

.native-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.native-modal-card {
    width: 100%; max-width: 360px;
    background: #1f2c34;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(0, 245, 196, 0.25);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.75);
}
.native-modal-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.native-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.btn-modal-cancel { background: transparent; border: none; color: var(--text-muted); font-weight: 700; padding: 8px 12px; cursor: pointer; }
.btn-modal-confirm { background: var(--social-green); color: #03130f; border: none; border-radius: 8px; font-weight: 800; padding: 8px 16px; cursor: pointer; }

#options-dropdown {
    position: absolute; top: 56px; right: 12px;
    background: #1f2c34; border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 10px 30px rgba(0,0,0,0.7);
    display: none; flex-direction: column; width: 220px; z-index: 2500; overflow: hidden;
}
.dropdown-item { padding: 11px 14px; font-size: 13px; display: flex; align-items: center; gap: 9px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05); }
.dropdown-item:hover { background: #2a3942; }

/* CALL OVERLAY WEBRTC */
#call-overlay {
    position: fixed; inset: 0;
    background: linear-gradient(180deg, #0b141a 0%, #022b23 100%);
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    padding: 36px 20px;
    text-align: center;
}
#remote-video {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    display: none;
    z-index: 1;
}
#local-video {
    position: absolute; top: 20px; right: 16px;
    width: 104px; height: 148px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid var(--social-green);
    display: none;
    z-index: 12;
}
.call-btn {
    width: 58px; height: 58px; border-radius: 50%;
    border: none; display: flex; align-items: center; justify-content: center;
    font-size: 24px; cursor: pointer; color: #fff;
}

#toast-notice {
    position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%);
    background: var(--social-green); color: #03130f;
    font-weight: 800; font-size: 12px;
    padding: 8px 18px; border-radius: 20px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    z-index: 9500; display: none;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
