/* ============================================================
   Connect Web 6.0 — FINAL MASTER STYLESHEET
   Zero-Overflow Guaranteed | All Sections | All Devices
   ============================================================ */

:root {
    --wa-green: #008069;
    --wa-lgreen: #d9fdd3;
    --wa-bg: #fff;
    --wa-dark: #111b21;
    --wa-grey: #667781;
    --wa-border: #e9edef;
    --wa-header-bg: #fff;
    --wa-list-active: #f5f6f6;
    --wa-search-bg: #f0f2f5;
}

body.dark {
    --wa-bg: #0b141a;
    --wa-dark: #e9edef;
    --wa-grey: #8696a0;
    --wa-border: #222d34;
    --wa-header-bg: #202c33;
    --wa-list-active: #2a3942;
    --wa-search-bg: #202c33;
    --wa-lgreen: #005c4b;
}

/* ── NUCLEAR RESET ─────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box !important;
    font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* ── PREVENT CODE LEAK (STRICT) ── */
script,
style,
template,
noscript {
    display: none !important;
    visibility: hidden !important;
}

.ad-row,
.wa-ad-row,
.call-ad-slot,
#chatAdZone,
#cAd {
    min-height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px !important;
    color: inherit !important;
    line-height: normal !important;
    text-align: center;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ad-row>*,
.wa-ad-row>*,
.call-ad-slot>*,
#chatAdZone>*,
#cAd>* {
    font-size: initial !important;
    color: initial !important;
    line-height: initial !important;
}



/* ── HTML & BODY — PC DARK BACKGROUND ─────────────────── */
html,
body {
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    overflow: hidden !important;
    overflow-x: hidden !important;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #060d11 0%, #0d1a20 40%, #0b1416 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

main {
    display: block !important;
    width: 100% !important;
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    user-select: auto;
    position: relative;
}

.app-container {
    width: 100% !important;
    max-width: 480px !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    background: var(--wa-bg) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative;
    color: var(--wa-dark);
    box-shadow: 0 12px 60px rgba(0, 0, 0, .4);
    user-select: none;
    -webkit-user-select: none;
    border: none;
}

/* Ensure images display instantly */
img {
    display: block;
    max-width: 100%;
}

/* ── HEADER — ALWAYS SHRINKS ──────────────────────────── */
.app-header {
    background: var(--wa-header-bg) !important;
    padding: 13px 16px 10px;
    flex-shrink: 0 !important;
    z-index: 200;
    border-bottom: 1px solid var(--wa-border);
    width: 100% !important;
    overflow: hidden !important;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.header-top h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--wa-green);
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    gap: 20px;
    color: #54656f;
    align-items: center;
    flex-shrink: 0;
}

.header-actions svg {
    cursor: pointer;
}

.wa-search-bar {
    background: var(--wa-search-bg) !important;
    border-radius: 25px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #8696a0;
    font-size: 15px;
    width: 100%;
    overflow: hidden;
}

/* ── SCROLL AREA — ONLY VERTICAL SCROLL ──────────────── */
.scroll-area {
    width: 100% !important;
    max-width: 100% !important;
    -webkit-overflow-scrolling: touch;
}

.scroll-area::-webkit-scrollbar {
    display: none;
}

/* ── BOTTOM NAV — ALWAYS AT BOTTOM ───────────────────── */
.bottom-nav {
    height: 66px !important;
    min-height: 66px !important;
    background: var(--wa-header-bg) !important;
    display: flex !important;
    border-top: 1px solid var(--wa-border);
    flex-shrink: 0 !important;
    z-index: 200;
    width: 100% !important;
    overflow: hidden !important;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--wa-grey);
    gap: 3px;
    padding: 0;
    overflow: hidden;
}

.nav-btn.active {
    color: var(--wa-dark) !important;
}

.nav-pill {
    padding: 5px 18px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.nav-btn.active .nav-pill {
    background: var(--wa-lgreen);
}

.nav-btn span {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* ── LIST ITEMS — ABSOLUTE CONTAIN ───────────────────── */
.list-item {
    display: flex !important;
    align-items: center;
    padding: 12px 16px;
    gap: 15px;
    min-height: 72px;
    cursor: pointer;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.list-item:active {
    background: var(--wa-list-active) !important;
}

/* Avatar wrapper */
.list-avatar-wrap {
    width: 52px !important;
    height: 52px !important;
    min-width: 52px !important;
    min-height: 52px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
    background: #e9edef;
    box-sizing: border-box !important;
}

.list-avatar {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.letter-av {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    font-weight: bold;
    border-radius: 50%;
    text-transform: uppercase;
}

/* Info Block */
.list-info {
    flex: 1 !important;
    min-width: 0 !important;
    border-bottom: 1px solid var(--wa-border);
    padding-bottom: 10px;
    overflow: hidden;
}

.list-row-1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    gap: 8px;
}

.list-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--wa-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.list-time {
    font-size: 12px;
    color: var(--wa-grey);
    flex-shrink: 0 !important;
    white-space: nowrap;
}

.green-time {
    color: var(--wa-green) !important;
}

.list-row-2 {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

.list-msg {
    font-size: 14px;
    color: var(--wa-grey);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.unread-badge {
    background: var(--wa-green);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0 !important;
    padding: 0 5px;
}

.call-phone-icon {
    color: var(--wa-green);
    flex-shrink: 0;
}

.section-label {
    padding: 12px 16px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #667781;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: #fff;
}

body.dark .section-label {
    background: #0b141a;
    color: #8696a0;
}

/* ── RECORDING NOW FIX ── */
.status-recording {
    color: #25d366 !important;
    font-weight: 600;
}

body.dark .status-recording {
    color: #00a884 !important;
}

/* ── AD ROWS — FLEXIBLE CONTAIN ───────────────────── */
.wa-ad-row,
.ad-row,
.ad-row-fast {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    margin: 12px 0;
    flex-shrink: 0;
    clear: both;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

/* Shimmer loading state for fast ads */
.ad-row-fast {
    background: rgba(0,0,0,0.02);
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.ad-row-fast::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: ad-shimmer 1.5s infinite;
    pointer-events: none;
}

.ad-row-fast.ad-loaded::after {
    display: none;
}

.ad-row-fast.ad-loaded {
    background: transparent;
    min-height: auto;
}

@keyframes ad-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.ad-row-fast iframe {
    position: relative;
    z-index: 2;
}

/* ── STATUS TRAY ──────────────────────────────────────── */
.status-tray {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    border-bottom: 8px solid var(--wa-bg);
    flex-shrink: 0;
    width: 100%;
}

.status-tray::-webkit-scrollbar {
    display: none !important;
}

.tray-item {
    text-align: center;
    min-width: 68px;
    flex-shrink: 0;
    cursor: pointer;
    overflow: hidden;
}

.tray-ring {
    width: 62px !important;
    height: 62px !important;
    border-radius: 50% !important;
    border: 2.5px solid var(--wa-green);
    padding: 2.5px;
    margin: 0 auto 5px;
    position: relative;
    overflow: visible;
}

.tray-avatar {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block;
}

.tray-plus {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--wa-green);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #fff;
    font-size: 18px;
    line-height: 18px;
    text-align: center;
    z-index: 2;
}

.tray-name {
    font-size: 11px;
    color: var(--wa-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 68px;
    margin: 0 auto;
}

/* ── CALL SCREEN OVERLAY — MODERN STYLE ────────── */
#callScreen {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 100% !important;
    max-width: 480px !important;
    height: 100% !important;
    background: #0b141a;
    background: radial-gradient(circle at top, #1e3a4a 0%, #0b141a 80%);
    z-index: 10000 !important;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 60px 24px 40px;
    text-align: center;
    overflow: hidden;
    user-select: none;
}

.call-top-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    margin-bottom: 30px;
    font-weight: 500;
}

.call-img {
    width: 160px !important;
    height: 160px !important;
    border-radius: 50% !important;
    border: 3px solid rgba(255, 255, 255, .08);
    object-fit: cover !important;
    margin-bottom: 25px;
    flex-shrink: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.call-name-big {
    color: #fff;
    font-size: 24px;
    font-weight: 500;
    margin: 10px 0 2px 0;
    width: 100%;
    max-width: 92%;
    min-height: 32px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    display: block !important;
    position: relative;
    z-index: 5;
    line-height: 1.2;
}

.call-txt {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
    display: block !important;
}

.call-ad-container {
    margin-top: 30px;
    width: 100%;
    min-height: 120px;
    overflow: visible;
}

.call-btns {
    margin-top: auto;
    display: flex;
    width: 100%;
    justify-content: space-around;
    padding: 0 40px 40px;
    gap: 60px;
}

.call-btn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
}

.call-btn {
    width: 76px !important;
    height: 76px !important;
    border-radius: 50% !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.call-btn:active {
    transform: scale(0.88);
}

.c-ans {
    background: #21c063 !important;
}

.c-ans:hover {
    background: #25d366 !important;
    box-shadow: 0 0 25px rgba(37, 211, 102, 0.4);
}

.c-end {
    background: #f44336 !important;
}

.c-end:hover {
    background: #ff5252 !important;
    box-shadow: 0 0 25px rgba(244, 67, 54, 0.4);
}

.call-btn svg {
    width: 34px;
    height: 34px;
}

/* ── STATUS VIEWER OVERLAY ────────────────────────────── */
#statusViewer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    background: #000;
    z-index: 9999 !important;
    display: none;
    flex-direction: column;
    overflow: hidden;
    margin: 0 auto;
}

.sv-progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, .3);
    flex-shrink: 0;
    width: 100%;
}

#svProgress {
    height: 100%;
    background: #fff;
    width: 0;
}

.sv-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .7), transparent);
    flex-shrink: 0;
}

.sv-avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0;
}

#svImg {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0 !important;
    max-height: 100% !important;
    object-fit: contain !important;
    display: block;
    background: #000;
}



/* ── CHAT PAGE ────────────────────────────────────────── */
.chat-bg {
    background-color: #e5ddd5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg fill='none' stroke='%23cfc7bd' stroke-width='0.6' opacity='0.55'%3E%3Cpath d='M20 10c0 5.52-4.48 10-10 10S0 15.52 0 10 4.48 0 10 0s10 4.48 10 10zm40 0c0 5.52-4.48 10-10 10S40 15.52 40 10 44.48 0 50 0s10 4.48 10 10zM20 50c0 5.52-4.48 10-10 10S0 55.52 0 50s4.48-10 10-10 10 4.48 10 10zm40 0c0 5.52-4.48 10-10 10S40 55.52 40 50s4.48-10 10-10 10 4.48 10 10z'/%3E%3Cpath d='M10 20v20M50 20v20M0 30h20M40 30h20M30 0v20M30 40v20M20 10h20M20 50h20'/%3E%3C/g%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 80px 80px;
}

/* ── CHAT HEADER ──────────────────────────────────────── */
.chat-header {
    display: flex !important;
    align-items: center;
    padding: 10px 12px 10px 8px;
    background: #008069;
    gap: 10px;
    flex-shrink: 0 !important;
    z-index: 200;
    width: 100% !important;
    overflow: hidden !important;
    min-height: 60px;
}

.chat-back-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    flex-shrink: 0;
}

.chat-header-av-wrap {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    background: #e9edef;
}

.chat-header-av {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chat-header-name {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.82);
}

.chat-header-actions {
    display: flex;
    gap: 18px;
    color: #fff;
    flex-shrink: 0;
}

.msg-row {
    display: flex;
    margin-bottom: 3px;
    padding: 0 12px;
}

.msg-row.sent {
    justify-content: flex-end;
}

.msg-row.recv {
    justify-content: flex-start;
}

.bubble {
    max-width: 85% !important;
    min-width: 60px;
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 14.5px;
    line-height: 1.45;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
    position: relative;
    word-break: break-word;
    overflow: visible;
    box-sizing: border-box !important;
}

.bubble.sent {
    background: #dcf8c6;
    border-top-right-radius: 2px;
}

.bubble.recv {
    background: #fff;
    border-top-left-radius: 2px;
}

.msg-time {
    font-size: 10.5px;
    color: #8696a0;
    float: right;
    margin-left: 8px;
    margin-top: 3px;
}

/* Voice Note */
.vn-row {
    display: flex !important;
    align-items: center;
    gap: 8px;
    min-width: 160px;
    max-width: 100%;
    cursor: pointer;
    padding: 3px 0;
    overflow: hidden !important;
    flex-wrap: nowrap;
}

.vn-play-btn {
    width: 38px !important;
    height: 38px !important;
    background: var(--wa-green);
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 14px;
}

.vn-waveform {
    flex: 1;
    min-width: 0;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 2px;
    overflow: hidden;
}

.vn-bar {
    width: 3px;
    border-radius: 2px;
    background: rgba(0, 128, 105, .35);
    flex-shrink: 0;
}

.vn-bar.tall {
    height: 80%;
}

.vn-bar.mid {
    height: 50%;
}

.vn-bar.short {
    height: 25%;
}

/* Chat Input */
.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 10px 12px;
    background: #f0f2f5;
    flex-shrink: 0 !important;
    width: 100%;
    overflow: hidden;
}

.chat-input-box {
    flex: 1;
    background: #fff;
    border-radius: 24px;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.chat-input-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    background: transparent;
    min-width: 0;
}

.chat-send-btn {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    background: var(--wa-green) !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    flex-shrink: 0 !important;
    color: #fff;
    transition: transform .1s;
}

.chat-send-btn:active {
    transform: scale(.9);
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── ADMIN PANEL — STANDALONE PAGE ───────────────────── */
.admin-alert-ok {
    background: #f0fff4;
    color: #276749;
    border: 1px solid #9ae6b4;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.admin-alert-err {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

/* ── AD ROW (between list items) ───────────────────────── */
/* ── SOCIAL PRO (READ/UNREAD) ── */
.unread-badge {
    background: #25d366;
    color: #fff;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    margin-left: auto;
}

.read-ticks {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.unread-time {
    color: #25d366 !important;
    font-weight: bold;
}

.dark .unread-badge {
    background: #00a884;
}

.dark .unread-time {
    color: #00a884 !important;
}