/**
 * PCNet Atendimento WhatsApp - CSS Mobile-First
 * @version 1.0.0 - 25/02/2026
 */

:root {
    --wpp-primary: #075e54;
    --wpp-primary-dark: #054d44;
    --wpp-secondary: #128c7e;
    --wpp-accent: #25d366;
    --wpp-light: #dcf8c6;
    --wpp-bg: #e5ddd5;
    --wpp-chat-bg: #efeae2;
    --wpp-header: #075e54;
    --wpp-sidebar-bg: #ffffff;
    --wpp-msg-out: #d9fdd3;
    --wpp-msg-in: #ffffff;
    --wpp-msg-system: #ffeeba;
    --wpp-msg-internal: #e3f2fd;
    --wpp-text: #111b21;
    --wpp-text-secondary: #667781;
    --wpp-border: #e9edef;
    --wpp-unread: #25d366;
    --wpp-danger: #dc3545;
    --wpp-radius: 8px;
    --wpp-safe-top: env(safe-area-inset-top, 0px);
    --wpp-safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--wpp-text);
    background: var(--wpp-bg);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* ============================
   LAYOUT PRINCIPAL
   ============================ */
.wpp-app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.wpp-sidebar {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--wpp-sidebar-bg);
    border-right: 1px solid var(--wpp-border);
    transition: transform 0.25s ease;
}

.wpp-main {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    background: var(--wpp-chat-bg);
}

/* Mobile: sidebar ou main, nunca ambos */
.wpp-app.chat-open .wpp-sidebar { display: none; }
.wpp-app.chat-open .wpp-main { display: flex; }

/* ============================
   HEADER DA SIDEBAR
   ============================ */
.wpp-sidebar-header {
    background: var(--wpp-header);
    color: white;
    padding: calc(12px + var(--wpp-safe-top)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    flex-shrink: 0;
}

.wpp-sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.wpp-sidebar-header .wpp-header-actions {
    display: flex;
    gap: 12px;
}

.wpp-sidebar-header .wpp-header-actions button {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.85;
}
.wpp-sidebar-header .wpp-header-actions button:hover { opacity: 1; }

/* Menu Dropdown */
.wpp-menu-wrap {
    position: relative;
}
.wpp-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    min-width: 220px;
    z-index: 1000;
    padding: 6px 0;
    margin-top: 8px;
}
.wpp-dropdown.show { display: block; }
.wpp-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}
.wpp-dropdown a:hover { background: #f0f2f5; }
.wpp-dropdown a i { width: 18px; text-align: center; color: var(--wpp-primary); font-size: 15px; }
.wpp-dropdown-divider { height: 1px; background: #e9edef; margin: 4px 0; }

/* ============================
   FILTROS / TABS
   ============================ */
.wpp-tabs {
    display: flex;
    background: var(--wpp-header);
    padding: 0 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}
.wpp-tabs::-webkit-scrollbar { display: none; }

.wpp-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
}
.wpp-tab.active { color: white; border-bottom-color: white; }
.wpp-tab .badge {
    display: inline-block;
    background: var(--wpp-unread);
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

/* ============================
   BUSCA
   ============================ */
.wpp-search {
    padding: 8px 12px;
    background: #f0f2f5;
    flex-shrink: 0;
}
.wpp-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: none;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    outline: none;
}
.wpp-search .search-wrap {
    position: relative;
}
.wpp-search .search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--wpp-text-secondary);
    font-size: 14px;
}

/* ============================
   LISTA DE CONVERSAS
   ============================ */
.wpp-conv-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.wpp-conv-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--wpp-border);
    transition: background 0.15s;
    gap: 12px;
}
.wpp-conv-item:hover, .wpp-conv-item:active { background: #f0f2f5; }
.wpp-conv-item.unread { background: #f0faf0; }

.wpp-conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--wpp-secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}
.wpp-conv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.wpp-conv-avatar[data-has-foto="1"], #chatAvatar[data-has-foto="1"] { cursor: pointer; }

/* ===== Avatar Lightbox ===== */
.wpp-avatar-lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,.85); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .25s ease; cursor: pointer;
}
.wpp-avatar-lightbox.show { opacity: 1; }
.wpp-avatar-lightbox-inner {
    position: relative; max-width: 90vw; max-height: 90vh;
    animation: wppLbZoom .25s ease;
}
.wpp-avatar-lightbox-inner img {
    max-width: 90vw; max-height: 85vh; border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5); object-fit: contain;
}
.wpp-avatar-lightbox-name {
    text-align: center; color: #fff; font-size: 15px; font-weight: 500;
    margin-top: 10px; text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.wpp-avatar-lightbox-close {
    position: absolute; top: -14px; right: -14px;
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,.2); border: none; color: #fff;
    font-size: 20px; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: background .2s;
}
.wpp-avatar-lightbox-close:hover { background: rgba(255,255,255,.4); }
@keyframes wppLbZoom { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.wpp-conv-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.wpp-conv-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.wpp-conv-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.wpp-conv-time {
    font-size: 11px;
    color: var(--wpp-text-secondary);
    flex-shrink: 0;
    margin-left: 4px;
}
.wpp-conv-item.unread .wpp-conv-time { color: var(--wpp-unread); }

.wpp-conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.wpp-conv-preview {
    font-size: 13px;
    color: var(--wpp-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.wpp-conv-badges {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
    margin-left: 4px;
}
.wpp-unread-badge {
    background: var(--wpp-unread);
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.wpp-status-badge {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}
.wpp-dept-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    color: white;
}
.wpp-conv-instance {
    font-size: 11px;
    color: var(--wpp-text-secondary, #667781);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================
   CHAT HEADER
   ============================ */
.wpp-chat-header {
    background: var(--wpp-header);
    color: white;
    padding: calc(8px + var(--wpp-safe-top)) 8px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    flex-shrink: 0;
}

.wpp-chat-back {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
}

.wpp-chat-contact-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.wpp-chat-contact-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wpp-chat-contact-status {
    font-size: 12px;
    opacity: 0.8;
}

.wpp-chat-actions {
    display: flex;
    gap: 4px;
}
.wpp-chat-actions button {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    padding: 8px;
    cursor: pointer;
    opacity: 0.85;
    border-radius: 50%;
}
.wpp-chat-actions button:hover { opacity: 1; background: rgba(255,255,255,0.1); }

/* ============================
   MENSAGENS
   ============================ */
.wpp-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--wpp-chat-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' opacity='0.06'%3E%3Cpath d='M20 20h20v20H20zm40 0h20v20H60zm40 0h20v20h-20zm40 0h20v20h-20zM0 40h20v20H0zm40 40h20v20H40zm80 0h20v20h-20zM20 100h20v20H20zm60 0h20v20H80zm60 0h20v20h-20zM0 120h20v20H0zm40 0h20v20H40zm40 40h20v20H80z' fill='%23111b21'/%3E%3C/svg%3E");
}

.wpp-msg {
    max-width: 85%;
    padding: 6px 8px;
    border-radius: var(--wpp-radius);
    position: relative;
    word-wrap: break-word;
    line-height: 1.4;
}
.wpp-msg.saida {
    align-self: flex-end;
    background: var(--wpp-msg-out);
    border-top-right-radius: 0;
}
.wpp-msg.entrada {
    align-self: flex-start;
    background: var(--wpp-msg-in);
    border-top-left-radius: 0;
}
.wpp-msg.sistema {
    align-self: center;
    background: var(--wpp-msg-system);
    font-size: 12px;
    text-align: center;
    max-width: 90%;
    border-radius: 6px;
    padding: 4px 12px;
    color: #856404;
}
.wpp-msg.interno {
    align-self: flex-end;
    background: var(--wpp-msg-internal);
    border: 1px dashed #90caf9;
    border-top-right-radius: 0;
}

.wpp-msg-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--wpp-secondary);
    margin-bottom: 2px;
}
.wpp-msg-text { font-size: 14px; white-space: pre-wrap; }
.wpp-msg-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}
.wpp-msg-time {
    font-size: 11px;
    color: var(--wpp-text-secondary);
}
.wpp-msg-reaction {
    font-size: 14px;
    line-height: 1;
    margin-left: 2px;
}
.wpp-msg-react-picker {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    left: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
    padding: 4px 6px;
    gap: 2px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    z-index: 10;
}
.wpp-msg-react-picker.open {
    display: flex;
}
.wpp-msg-react-picker .wpp-react-emoji {
    background: none;
    border: none;
    font-size: 22px;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 6px;
}
.wpp-msg-react-picker .wpp-react-emoji:hover {
    background: rgba(0,0,0,.06);
}
.wpp-msg-react-picker .wpp-react-remove {
    background: #f0f0f0;
    border: none;
    font-size: 12px;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
    color: #666;
}
.wpp-msg-react-picker .wpp-react-remove:hover {
    background: #e0e0e0;
}
/* Menu de ações: fixo no canto inferior direito da bolha, NUNCA em cima do áudio */
.wpp-msg {
    padding-right: 8px;
}
/* Deixar espaço para os ícones do menu para não sobrepor hora/áudio */
.wpp-msg:not(.wpp-msg-sistema) .wpp-msg-meta {
    padding-right: 100px;
}
/* Sempre canto inferior direito (anula bloco1 que coloca entrada à esquerda) */
.wpp-msg-hover-menu {
    position: absolute;
    left: auto !important;
    top: auto !important;
    bottom: 4px;
    right: 4px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 2;
}
.wpp-msg:hover .wpp-msg-hover-menu {
    opacity: 1;
    pointer-events: auto;
}
@media (hover: none) {
    .wpp-msg-hover-menu {
        opacity: 1;
        pointer-events: auto;
    }
}
/* Conteúdo (áudio, vídeo, texto) sempre à frente; reservar espaço à direita para o menu */
.wpp-msg-media {
    position: relative;
    z-index: 1;
    margin-right: 0;
    padding-right: 100px;
    box-sizing: border-box;
}
.wpp-msg-media audio,
.wpp-msg-media video {
    max-width: 100%;
}
/* Área da mensagem (texto + mídia + meta) não pode ser coberta pelo menu */
.wpp-msg-sender,
.wpp-msg-reply,
.wpp-msg-media,
.wpp-msg-text,
.wpp-msg-meta {
    position: relative;
    z-index: 1;
}
.wpp-msg-status {
    font-size: 12px;
}
.wpp-msg-status.lido { color: #53bdeb; }
.wpp-msg-status.entregue { color: var(--wpp-text-secondary); }

.wpp-msg-media img, .wpp-msg-media video {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 4px;
}
.wpp-msg-reply {
    background: rgba(0,0,0,0.05);
    border-left: 3px solid var(--wpp-secondary);
    padding: 4px 8px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--wpp-text-secondary);
}

/* ============================
   INPUT DE MENSAGEM
   ============================ */
.wpp-input-area {
    background: #f0f2f5;
    padding: 8px 8px calc(8px + var(--wpp-safe-bottom));
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.wpp-input-area .wpp-input-actions button {
    background: none;
    border: none;
    color: var(--wpp-text-secondary);
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
}
.wpp-input-area .wpp-input-actions button:hover { color: var(--wpp-primary); }

.wpp-input-wrap {
    flex: 1;
    background: white;
    border-radius: 24px;
    display: flex;
    align-items: flex-end;
    padding: 4px 12px;
    min-height: 40px;
}
.wpp-input-wrap textarea {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    padding: 6px 0;
    font-family: inherit;
    background: transparent;
}

.wpp-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--wpp-accent);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.wpp-send-btn:hover { background: #1fba59; }
.wpp-send-btn:disabled { background: #ccc; cursor: not-allowed; }

/* ============================
   EMPTY STATE
   ============================ */
.wpp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--wpp-text-secondary);
    text-align: center;
    padding: 32px;
}
.wpp-empty i { font-size: 64px; margin-bottom: 16px; opacity: 0.3; }
.wpp-empty h3 { font-size: 18px; margin-bottom: 8px; color: var(--wpp-text); }

/* ============================
   LOGIN
   ============================ */
.wpp-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--wpp-primary), var(--wpp-secondary));
    padding: 20px;
}
.wpp-login-card {
    background: white;
    border-radius: 12px;
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.wpp-login-card h2 {
    text-align: center;
    color: var(--wpp-primary);
    margin-bottom: 24px;
}
.wpp-login-card .form-group { margin-bottom: 16px; }
.wpp-login-card label { display: block; font-size: 13px; color: var(--wpp-text-secondary); margin-bottom: 4px; }
.wpp-login-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--wpp-border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border 0.2s;
}
.wpp-login-card input:focus { border-color: var(--wpp-primary); }
.wpp-login-card .btn-login {
    width: 100%;
    padding: 12px;
    background: var(--wpp-accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.wpp-login-card .btn-login:hover { background: #1fba59; }
.wpp-login-error { color: var(--wpp-danger); font-size: 13px; text-align: center; margin-top: 12px; display: none; }

/* ============================
   MODALS
   ============================ */
.wpp-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
}
.wpp-modal-backdrop.show { display: flex; align-items: flex-end; justify-content: center; }
.wpp-modal {
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.wpp-modal h3 { margin-bottom: 16px; font-size: 16px; }
.wpp-modal .wpp-modal-close {
    float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--wpp-text-secondary);
}

/* ============================
   LOADING
   ============================ */
.wpp-loading {
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.wpp-spinner {
    width: 32px; height: 32px; border: 3px solid var(--wpp-border);
    border-top-color: var(--wpp-primary); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================
   TOAST NOTIFICATIONS
   ============================ */
.wpp-toast-container {
    position: fixed; top: 12px; right: 12px; z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}
.wpp-toast {
    background: var(--wpp-primary); color: white; padding: 10px 16px; border-radius: 8px;
    font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: fadeIn 0.3s;
    max-width: 300px; cursor: pointer;
}
.wpp-toast.error { background: var(--wpp-danger); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; } }

/* ============================
   BLOCKED INTERACTION BANNER
   ============================ */
.wpp-blocked-banner {
    padding: 16px 20px;
    background: var(--wpp-bg-secondary, #f0f2f5);
    border-top: 1px solid var(--wpp-border, #e9edef);
    text-align: center;
}
.wpp-blocked-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--wpp-text-secondary, #667781);
    font-size: 13px;
}
.wpp-blocked-content strong { color: var(--wpp-text-primary, #111b21); }
.wpp-blocked-content small { opacity: 0.8; }
.wpp-blocked-transfer-btn {
    margin-top: 8px;
    padding: 8px 20px;
    background: var(--wpp-primary, #128c7e);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}
.wpp-blocked-transfer-btn:hover { background: var(--wpp-primary-dark, #075e54); }

/* ============================
   DESKTOP (>= 768px)
   ============================ */
@media (min-width: 768px) {
    .wpp-sidebar { width: 380px; display: flex !important; }
    .wpp-main { display: flex !important; flex: 1; }
    .wpp-app.chat-open .wpp-sidebar { display: flex !important; }
    
    .wpp-msg { max-width: 60%; }
    
    .wpp-modal-backdrop.show { align-items: center; }
    .wpp-modal { border-radius: 12px; max-height: 70vh; }
}

@media (min-width: 1200px) {
    .wpp-sidebar { width: 420px; }
}

/* ========================================
   SEMÁFORO DE CONEXÃO
   ======================================== */

.wpp-semaforo {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,.15);
    border-radius: 20px;
    padding: 4px 8px;
    cursor: pointer;
    transition: background .2s;
}
.wpp-semaforo:hover {
    background: rgba(0,0,0,.25);
}

.wpp-led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    opacity: 0.25;
    transition: opacity .3s, box-shadow .3s;
}

.wpp-led-red    { background: #ef4444; }
.wpp-led-orange { background: #f59e0b; }
.wpp-led-green  { background: #22c55e; }

.wpp-led.active {
    opacity: 1;
}
.wpp-led-red.active {
    box-shadow: 0 0 8px rgba(239,68,68,.6);
    animation: pulse-led 1.5s ease-in-out infinite;
}
.wpp-led-orange.active {
    box-shadow: 0 0 8px rgba(245,158,11,.5);
    animation: pulse-led 2s ease-in-out infinite;
}
.wpp-led-green.active {
    box-shadow: 0 0 6px rgba(34,197,94,.4);
}

/* Semáforo no header do chat: oculto no desktop (sidebar visível); visível em mobile quando conversa aberta */
.wpp-semaforo-chat { display: none; background: rgba(255,255,255,0.15); }
.wpp-semaforo-chat:hover { background: rgba(255,255,255,0.25); }
@media (max-width: 767px) {
    .wpp-app.chat-open .wpp-semaforo-chat { display: flex; }
}
@media (min-width: 768px) {
    .wpp-semaforo-chat { display: none !important; }
}

@keyframes pulse-led {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   GALERIA DE IMAGENS - Grid Thumbs + Viewer
   Mobile-First
   ======================================== */

/* === Grid de miniaturas no balão (2x2) === */
.wpp-gal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 220px;
    margin-bottom: 4px;
}

.wpp-gal-thumb {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--wpp-border, #e0e0e0);
    cursor: pointer;
}
.wpp-gal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .2s, opacity .2s;
}
.wpp-gal-thumb:hover img {
    transform: scale(1.06);
    opacity: .88;
}
.wpp-gal-more {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    pointer-events: none;
}

.wpp-gal-group {
    max-width: 260px;
}

/* === Viewer fullscreen (slideshow) === */
.wpp-gal-viewer {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,.94);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity .2s ease;
}
.wpp-gal-viewer.active {
    opacity: 1;
}

/* Header */
.wpp-gal-v-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
    color: #fff;
}
.wpp-gal-v-counter {
    font-size: 14px;
    font-weight: 600;
    opacity: .85;
    letter-spacing: .5px;
}
.wpp-gal-v-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.wpp-gal-v-actions a,
.wpp-gal-v-actions button {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background .2s;
    text-decoration: none;
}
.wpp-gal-v-actions a:hover,
.wpp-gal-v-actions button:hover {
    background: rgba(255,255,255,.12);
}

/* Body / imagem principal */
.wpp-gal-v-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}
.wpp-gal-v-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.wpp-gal-v-img-wrap img {
    max-width: 94%;
    max-height: calc(100vh - 180px);
    max-height: calc(100dvh - 180px);
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
    -webkit-user-select: none;
    transition: opacity .12s ease;
}
.wpp-gal-v-img-wrap img.transitioning {
    opacity: .2;
}

/* Setas de navegação */
.wpp-gal-v-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,.5);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: background .2s, transform .15s;
}
.wpp-gal-v-nav:hover {
    background: rgba(255,255,255,.18);
}
.wpp-gal-v-nav:active {
    transform: translateY(-50%) scale(.9);
}
.wpp-gal-v-nav.prev { left: 10px; }
.wpp-gal-v-nav.next { right: 10px; }

/* Caption */
.wpp-gal-v-caption {
    text-align: center;
    color: #fff;
    font-size: 13px;
    padding: 0 16px;
    min-height: 18px;
    opacity: .85;
    flex-shrink: 0;
}
.wpp-gal-v-caption:empty {
    display: none;
}

/* Strip de thumbs no viewer */
.wpp-gal-v-thumbs {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: center;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.wpp-gal-v-thumbs::-webkit-scrollbar { display: none; }

.wpp-gal-v-th {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: .45;
    transition: opacity .2s, border-color .2s, transform .15s;
}
.wpp-gal-v-th.active {
    border-color: #fff;
    opacity: 1;
    transform: scale(1.08);
}
.wpp-gal-v-th:hover {
    opacity: .8;
}
.wpp-gal-v-th img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* === Mobile === */
@media (max-width: 768px) {
    .wpp-gal-grid {
        max-width: 180px;
    }
    .wpp-gal-group {
        max-width: 220px;
    }

    .wpp-gal-v-nav {
        width: 36px;
        height: 36px;
        font-size: 14px;
        background: rgba(0,0,0,.35);
    }
    .wpp-gal-v-nav.prev { left: 4px; }
    .wpp-gal-v-nav.next { right: 4px; }

    .wpp-gal-v-img-wrap img {
        max-width: 100%;
        max-height: calc(100vh - 150px);
        max-height: calc(100dvh - 150px);
    }

    .wpp-gal-v-th {
        width: 42px;
        height: 42px;
    }
}

/* === Desktop === */
@media (min-width: 769px) {
    .wpp-gal-grid {
        max-width: 240px;
    }
    .wpp-gal-group {
        max-width: 280px;
    }
}
