:root {
    --wa-bg: #0b141a;
    --wa-panel: #111b21;
    --wa-surface: #1f2c34;
    --wa-header: #111b21;
    --wa-green: #25d366;
    --wa-text: #e9edef;
    --wa-muted: #8696a0;
    --wa-border: #222d34;
    --wa-nav-h: 64px;
    --wa-fab-size: 52px;
}

/* Evita ícones SVG gigantes quando o CSS externo não carrega */
.wa-mobile-app svg,
.wa-desktop-shell svg {
    display: block;
    flex-shrink: 0;
    max-width: 100%;
    max-height: 100%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--wa-bg);
    color: var(--wa-text);
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- Mobile app (WhatsApp-like) --- */

.wa-contacts-page {
    background: var(--wa-bg);
}

.wa-mobile-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--wa-bg);
    padding-bottom: calc(var(--wa-nav-h) + 8px);
}

.wa-desktop-shell {
    display: none;
}

.wa-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    background: var(--wa-header);
}

.wa-mobile-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.wa-mobile-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wa-icon-btn {
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--wa-text);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    list-style: none;
}

.wa-icon-btn::-webkit-details-marker {
    display: none;
}

.wa-icon-btn svg {
    width: 24px;
    height: 24px;
}

.wa-icon-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.wa-menu {
    position: relative;
}

.wa-menu-panel {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 140px;
    background: var(--wa-surface);
    border-radius: 8px;
    padding: 8px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    z-index: 20;
}

.wa-menu-panel a {
    display: block;
    padding: 10px 16px;
    font-size: 15px;
}

.wa-menu-panel a:hover {
    background: rgba(255, 255, 255, 0.06);
}

.wa-search-wrap {
    position: relative;
    padding: 0 16px 8px;
    background: var(--wa-header);
}

.wa-search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--wa-muted);
    pointer-events: none;
}

.wa-search-wrap input {
    width: 100%;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: var(--wa-surface);
    color: var(--wa-text);
    padding: 0 14px 0 40px;
    font-size: 15px;
    outline: none;
}

.wa-search-wrap input::placeholder {
    color: var(--wa-muted);
}

.wa-chat-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--wa-nav-h) + 12px);
}

.wa-chat-item {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 72px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--wa-border);
    transition: background 0.12s ease;
}

.wa-chat-item:active,
.wa-chat-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.wa-chat-item--disabled {
    opacity: 0.65;
    cursor: not-allowed;
    pointer-events: none;
}

.wa-avatar {
    flex-shrink: 0;
    width: 49px;
    height: 49px;
    border-radius: 999px;
    background: #6a7175;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
}

.wa-avatar--photo {
    background: transparent;
}

.wa-avatar--photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wa-chat-item:first-of-type .wa-avatar:not(.wa-avatar--photo) {
    background: #00a884;
}

.wa-chat-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wa-chat-top,
.wa-chat-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.wa-chat-name {
    font-size: 17px;
    font-weight: 400;
    color: var(--wa-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-chat-time {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--wa-muted);
}

.wa-chat-time--unread {
    color: var(--wa-green);
}

.wa-chat-preview {
    flex: 1;
    font-size: 14px;
    color: var(--wa-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-chat-meta {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 20px;
}

.wa-icon-pin {
    width: 16px;
    height: 16px;
    color: var(--wa-muted);
}

.wa-unread-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--wa-green);
    color: #0b141a;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wa-chat-empty {
    margin: 24px 16px;
    text-align: center;
    color: var(--wa-muted);
    font-size: 14px;
}

.wa-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--wa-nav-h);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background: #0b141a;
    border-top: 1px solid var(--wa-border);
    z-index: 15;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.wa-nav-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--wa-muted);
    padding: 6px 4px;
}

.wa-nav-item svg {
    width: 24px;
    height: 24px;
}

.wa-nav-item--active {
    color: var(--wa-green);
}

.wa-nav-item--active::before {
    content: "";
    position: absolute;
    width: 64px;
    height: 32px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    z-index: -1;
}

.wa-nav-item--disabled {
    opacity: 0.55;
}

.wa-nav-label-long {
    font-size: 10px;
    line-height: 1.15;
    max-width: 76px;
    text-align: center;
    white-space: normal;
}

.wa-nav-icon-wrap {
    position: relative;
    display: inline-flex;
}

.wa-nav-badge {
    position: absolute;
    top: -4px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--wa-green);
    color: #0b141a;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Desktop two-column --- */

@media (min-width: 960px) {
    .wa-mobile-app {
        display: none;
    }

    .wa-desktop-shell {
        display: block;
    }

    .wa-shell {
        display: flex;
        height: 100vh;
        max-width: 1440px;
        margin: 0 auto;
        background: var(--wa-panel);
    }

    .wa-sidebar {
        width: min(100%, 420px);
        border-right: 1px solid #2a3942;
        display: flex;
        flex-direction: column;
        background: var(--wa-panel);
    }

    .wa-sidebar-header {
        height: 60px;
        padding: 0 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #202c33;
    }

    .wa-profile {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .wa-avatar-me {
        width: 40px;
        height: 40px;
        font-size: 16px;
        background: #6a7175;
    }

    .wa-profile-texts {
        display: flex;
        flex-direction: column;
        line-height: 1.2;
    }

    .wa-profile-texts strong {
        font-size: 14px;
    }

    .wa-profile-texts span {
        font-size: 12px;
        color: #aebac1;
    }

    .wa-logout {
        font-size: 13px;
        color: #00a884;
    }

    .wa-search-wrap--desktop {
        padding: 8px 12px;
        background: var(--wa-panel);
        border-bottom: 1px solid #2a3942;
    }

    .wa-list {
        flex: 1;
        overflow-y: auto;
    }

    .wa-chat-item--disabled {
        pointer-events: none;
    }

    .wa-empty-state {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #222e35;
        padding: 24px;
    }

    .wa-empty-card {
        max-width: 520px;
        text-align: center;
        color: #d1d7db;
    }

    .wa-empty-card h2 {
        margin: 0 0 12px;
        font-size: 28px;
        font-weight: 300;
    }

    .wa-empty-card p {
        margin: 0 0 16px;
        color: var(--wa-muted);
    }

    .wa-empty-cta {
        display: inline-block;
        background: #00a884;
        color: #ffffff;
        border-radius: 8px;
        padding: 10px 14px;
        font-weight: 600;
    }
}

/* --- Chat conversation page (WhatsApp) --- */

.chat-page {
    overflow: hidden;
}

.chat-app svg {
    display: block;
    flex-shrink: 0;
}

.chat-header {
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.chat-header-back:hover {
    opacity: 0.85;
}

.chat-header-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.chat-body {
    background-color: #0b141a;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M30 8c-2 0-3 2-5 2s-4-1-5 2 2 4 2 5-2 3-2 5-2 3 2 5 2 4-1 5-2-2-3-2-5 2-3 2-5-2-3-2-5 2z'/%3E%3C/g%3E%3C/svg%3E");
    background-repeat: repeat;
}

.chat-compose-icon:disabled,
.chat-compose-attach:disabled,
.chat-compose-camera:disabled {
    opacity: 0.45;
    cursor: default;
}

.chat-compose-field input::placeholder {
    color: #8696a0;
}

.chat-action-btn {
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.chat-action-btn:hover {
    opacity: 0.9;
}

.chat-action-btn[hidden] {
    display: none !important;
}

.chat-bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble-text a {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

.chat-bubble--user .chat-bubble-text a {
    color: #fff;
}

.chat-bubble--user .chat-bubble-time {
    color: rgba(255, 255, 255, 0.55);
}

.chat-bubble-ticks {
    width: 16px;
    height: 11px;
    color: #53bdeb;
    flex-shrink: 0;
}

.chat-bubble-ticks--pending {
    color: rgba(255, 255, 255, 0.45);
}

.chat-bubble--pending {
    opacity: 0.85;
}

.chat-bubble-status--error {
    background: #5c2b2b;
}

.chat-bubble-error-text {
    margin: 6px 0 0;
    font-size: 12px;
    color: #ffb4b4;
}

.chat-retry-btn {
    margin-top: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 16px;
    background: transparent;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

.chat-retry-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-bubble--typing {
    min-width: 140px;
    padding: 10px 12px;
}

.chat-typing {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-typing-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
}

.chat-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 18px;
}

.chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    animation: chatTypingBlink 1.4s infinite ease-in-out;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatTypingBlink {
    0%,
    80%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.chat-quick-reply:hover {
    background: rgba(0, 168, 132, 0.12);
}

.chat-quick-reply:active {
    background: rgba(0, 168, 132, 0.2);
}

.chat-row + .chat-row--agent .chat-row-avatar--spacer,
.chat-row--user + .chat-row--agent .chat-row-avatar {
    visibility: visible;
}

.chat-row--agent + .chat-row--agent .chat-row-avatar,
.chat-row--agent + .chat-row--agent .chat-row-avatar--spacer {
    visibility: hidden;
}

.chat-row--agent:first-child .chat-row-avatar,
.chat-row--agent:first-child .chat-row-avatar--spacer {
    visibility: visible;
}

.chat-row--user {
    align-items: flex-end;
    gap: 6px;
}

.chat-row--user + .chat-row--user .chat-row-avatar,
.chat-row--user + .chat-row--user .chat-row-avatar--spacer {
    visibility: hidden;
}

.chat-row--user:first-child .chat-row-avatar,
.chat-row--user:first-child .chat-row-avatar--spacer,
.chat-row--agent + .chat-row--user .chat-row-avatar,
.chat-row--agent + .chat-row--user .chat-row-avatar--spacer {
    visibility: visible;
}
