/* TEMA CLARO */
:root {
    --primary: #00a884;
    --primary-hover: #06cf9c;
    --bg-main: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-panel: #ffffff;
    --bg-input: #f0f2f5;
    --text-main: #111b21; 
    --bg-chat: #e5ddd5; /* Cor bege clássica do WhatsApp claro */
    --text-title: #111b21;
    --text-desc: #667781;
    --border: rgba(0, 0, 0, 0.1);
    --msg-client: #ffffff;
    --msg-agent: #d9fdd3;
    --msg-text: #111b21;
}

/* TEMA ESCURO */
[data-theme="dark"] {
    --bg-main: #0b141a;
    --bg-sidebar: #111b21;
    --bg-panel: #202c33;
    --bg-chat: #0b141a;
    --text-title: #e9edef;
    --text-desc: #8696a0;
    --border: rgba(255, 255, 255, 0.1);
    --msg-client: #202c33;
    --msg-agent: #005c4b;
    --msg-text: #e9edef;
    --bg-input: #2a3942;
}

/* RESET TOTAL PARA TELA CHEIA */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', sans-serif; }

body { 
    background: var(--bg-main); 
    color: var(--text-title); 
    height: 100vh; 
    width: 100vw;
    overflow: hidden; 
}

.app-container { 
    width: 100%; 
    height: 100%; 
    display: flex; 
    background: var(--bg-sidebar); 
}
/* SIDEBAR */
.sidebar { width: 350px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg-sidebar); }
.sidebar-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-header-icon {
    background: #2a3942;
    border: 1px solid var(--border);
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.btn-header-icon:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.btn-logout:hover {
    background: #ea4335;
    border-color: #ea4335;
}
.sidebar-header h3 { color: var(--primary); font-size: 1.1rem; }

.search-bar { padding: 10px 15px; background: var(--bg-sidebar); }
.search-bar input { width: 100%; padding: 8px 15px; border-radius: 8px; border: none; background: var(--bg-panel); color: white; outline: none; }

.filters { display: flex; gap: 5px; padding: 10px 15px; background: var(--bg-sidebar); }
.filters button { flex: 1; padding: 6px; border: none; border-radius: 6px; background: var(--bg-panel); color: var(--text-desc); cursor: pointer; font-size: 0.75rem; }
.filters button.active { background: var(--primary); color: white; }

.ticket-list { flex: 1; overflow-y: auto; }
.ticket-item { padding: 15px 20px; border-bottom: 1px solid var(--border); cursor: pointer; transition: 0.2s; }
.ticket-item:hover { background: #2a3942; }
.ticket-item.active { background: #2a3942; border-left: 4px solid var(--primary); }
.ticket-item .name { display: block; font-weight: 600; margin-bottom: 3px; font-size: 0.95rem; }
.ticket-item .info { font-size: 0.75rem; color: var(--text-desc); display: flex; justify-content: space-between; }

/* CHAT AREA */
.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg-chat); }
.chat-header { padding: 12px 25px; background: var(--bg-panel); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.chat-actions { display: flex; gap: 8px; }

.btn-action { padding: 6px 15px; border-radius: 15px; border: none; cursor: pointer; font-weight: bold; font-size: 0.8rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: #ea4335; color: white; }

.chat-messages { 
    flex: 1; 
    padding: 20px; 
    overflow-y: auto; 
    background-color: var(--bg-chat); /* Usa a variável corrigida */
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-blend-mode: overlay;
    opacity: 0.9;
    display: flex; 
    flex-direction: column; 
    gap: 4px;
}

.msg { max-width: 65%; padding: 6px 12px; border-radius: 8px; font-size: 0.9rem; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,0.2); margin-bottom: 2px; }
.msg.client { 
    align-self: flex-start; 
    background: var(--msg-client); 
    color: var(--msg-text); 
    border-top-left-radius: 0; 
}
.msg.agent { 
    align-self: flex-end; 
    background: var(--msg-agent); 
    color: var(--msg-text); 
    border-top-right-radius: 0; 
}
.msg-inner {
    position: relative;
    display: inline-block;
    max-width: 100%;
    min-width: 120px;
    padding-right: 28px;
    overflow: visible;
}
.msg-menu-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.22);
    color: var(--text-title);
    cursor: pointer;
    font-size: 14px;
    line-height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    -webkit-appearance: none;
    appearance: none;
    font-family: Arial, sans-serif;
    font-weight: 700;
}
.msg-menu-btn:hover {
    background: rgba(0, 0, 0, 0.34);
}
.msg-menu-panel {
    display: none;
    position: absolute;
    top: 25px;
    right: 5px;
    min-width: 150px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
    overflow: hidden;
    z-index: 20;
}
.msg-menu-item {
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-title);
    text-align: left;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.msg-menu-item:hover {
    background: rgba(0, 168, 132, 0.12);
    color: var(--primary);
}
.msg-time { font-size: 0.65rem; color: rgba(255,255,255,0.5); margin-left: 10px; float: right; margin-top: 5px; }

/* INPUT */
.chat-input { 
    padding: 10px 20px; 
    background: var(--bg-panel); 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    border-top: 1px solid var(--border); /* Linha fina que separa o chat do input */
    z-index: 10;
}
.chat-input input { 
    flex: 1; 
    padding: 12px 18px; 
    border-radius: 24px; 
    border: 1px solid var(--border); /* Borda leve para o input ficar visível */
    background: var(--bg-input); 
    color: var(--text-title); 
    outline: none; 
    font-size: 0.95rem;
}

.chat-input input:focus {
    background: var(--bg-main); /* Muda levemente ao clicar para dar feedback */
    border-color: var(--primary);
}

.btn-circle { width: 38px; height: 38px; border-radius: 50%; border: none; background: transparent; color: var(--text-desc); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; transition: 0.2s; }
.btn-circle:hover { background: rgba(255,255,255,0.1); color: var(--primary); }
.btn-send { background: var(--primary); color: white; }

.sector-selector-wrapper {
    padding: 10px 15px;
    background: var(--bg-sidebar);
}

#sectorSelect {
    width: 100%;
    padding: 10px 15px;
    border-radius: 8px;
    background: var(--bg-panel); /* Variável aqui */
    color: var(--text-title);    /* Variável aqui */
    border: 1px solid var(--border);
    outline: none;
    cursor: pointer;
    appearance: none;
    /* Ajuste da cor da seta via SVG */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='gray'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
}

#sectorSelect:hover {
    border-color: var(--primary);
    background-color: #2a3942;
}

#sectorSelect option {
    background: var(--bg-panel);
    color: white;
    padding: 10px;
}

.filters-sectors button {
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 15px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-desc);
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.3s;
}

.filters-sectors button.active {
    background: rgba(0, 168, 132, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

/* Estilização do Scrollbar (Barra de Rolagem) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-sidebar);
}

::-webkit-scrollbar-thumb {
    background: #374045;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-desc);
}

/* Remove a barra de rolagem horizontal dos filtros */
.filters-sectors {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.filters-sectors::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-desc); /* Usa a cor de descrição variável */
    text-align: center;
    font-size: 1.1rem;
}

/* Modais */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-content {
    background: var(--bg-sidebar); width: 450px; border-radius: 12px; overflow: hidden;
}
.modal-header {
    padding: 15px; background: var(--bg-panel); display: flex; justify-content: space-between; align-items: center;
}
.quick-list { padding: 10px; max-height: 400px; overflow-y: auto; }
.quick-item {
    padding: 12px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--border); transition: 0.2s;
}
.quick-item:hover { background: var(--bg-panel); border-left: 4px solid var(--primary); }
.quick-item strong { display: block; color: var(--primary); margin-bottom: 4px; }
.quick-item p { font-size: 0.8rem; color: var(--text-desc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Vídeo Flutuante */
.video-floating {
    position: fixed; 
    bottom: 20px; 
    right: 20px; 
    width: 260px; /* Mais estreito */
    height: 480px; /* Mais alto para formato celular */
    background: #000; 
    border-radius: 15px; 
    overflow: hidden; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.6); 
    z-index: 1001;
    border: 3px solid var(--primary);
    display: flex;
    flex-direction: column;
}

/* Ajuste o tamanho do iframe do vídeo dentro da janela */
.video-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.video-body {
    flex: 1;
}
.video-nav { background: #202c33; padding: 8px 12px; display: flex; justify-content: space-between; color: white; font-size: 0.8rem; }
.video-nav button { background: none; border: none; color: white; cursor: pointer; }

.msg-media { max-width: 100%; border-radius: 8px; margin-top: 5px; cursor: pointer; }

/* MÍDIAS NAS MENSAGENS */
.msg img {
    max-width: 250px;
    max-height: 250px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    margin-top: 5px;
}

.msg video,
.msg audio {
    max-width: 250px;
    border-radius: 8px;
    display: block;
    margin-top: 5px;
}

.msg .pdf-link,
.msg .file-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: rgba(0, 168, 132, 0.15);
    border: 1px solid var(--primary);
    border-radius: 8px;
    color: var(--primary);
    cursor: pointer;
    margin-top: 5px;
    font-weight: 500;
    transition: all 0.2s;
}

.msg .pdf-link:hover,
.msg .file-link:hover {
    background: rgba(0, 168, 132, 0.25);
    transform: translateY(-2px);
}
.audio-preview-bar {
    position: absolute; bottom: 70px; left: 20px; right: 20px; 
    background: var(--bg-panel); padding: 15px; border-radius: 12px;
    display: flex; align-items: center; gap: 15px; box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
    border: 1px solid var(--primary);
}
.upload-item { background: var(--bg-main); padding: 10px; border-radius: 8px; margin-bottom: 8px; }
.upload-item input { width: 100%; margin-top: 5px; }

/* ==============================
   MODAL NOVA CONVERSA
   ============================== */
#modalNewChat .modal-content {
    width: 400px;
    background: rgba(32, 44, 51, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(0, 168, 132, 0.2);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#modalNewChat .modal-header {
    background: linear-gradient(135deg, rgba(0, 168, 132, 0.1) 0%, transparent 100%);
    padding: 18px 25px;
    border-bottom: 1px solid rgba(0, 168, 132, 0.2);
}

#modalNewChat .modal-header h3 {
    color: #00a884;
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
}

#modalNewChat .modal-header button {
    background: transparent;
    border: none;
    color: #8696a0;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#modalNewChat .modal-header button:hover {
    color: #00a884;
    transform: scale(1.1);
}

.forward-modal {
    width: 430px;
    max-width: calc(100vw - 24px);
    background: var(--bg-sidebar);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.35);
    animation: modalSlide 0.2s ease-out;
}
.forward-modal .modal-header {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}
.forward-modal .modal-header h3 {
    color: var(--text-title);
    font-size: 1.05rem;
}
.forward-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-desc);
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s ease, color 0.2s ease;
}
.forward-modal-close:hover {
    background: rgba(0, 168, 132, 0.12);
    color: var(--primary);
}
.forward-modal-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-sidebar);
}
.forward-search {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-title);
    outline: none;
}
.forward-search:focus {
    border-color: var(--primary);
}
.forward-destination-list {
    max-height: 320px;
    overflow-y: auto;
}
.forward-destination-item {
    width: 100%;
    text-align: left;
    margin-bottom: 8px;
    background: transparent;
    border-left: 3px solid transparent;
}
.forward-destination-item:hover {
    border-left-color: var(--primary);
}
.forward-modal-actions {
    padding: 15px;
    display: flex;
    justify-content: flex-end;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
}

#modalNewChat input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(11, 20, 26, 0.8);
    color: #e9edef;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
    box-sizing: border-box;
}

#modalNewChat input::placeholder {
    color: #667781;
}

#modalNewChat input:focus {
    border-color: #00a884;
    box-shadow: 0 0 10px rgba(0, 168, 132, 0.2);
    background: rgba(11, 20, 26, 0.9);
}

#modalNewChat .btn-action {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
}

#modalNewChat .btn-action:hover {
    transform: translateY(-2px);
}

.msg-doc-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-main);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border);
    margin-top: 5px;
    min-width: 200px;
}
.msg-doc-container:hover {
    background: var(--bg-panel);
    border-color: var(--primary);
}

/* Barra de Abas Luxuosas */
.view-tabs {
    display: flex;
    padding: 5px 15px;
    gap: 10px;
    background: var(--bg-sidebar);
}

.tab-item {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-desc);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: 0.3s;
}

.tab-item:hover { color: white; }

.tab-item.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

/* Ajuste nos filtros para não sumirem */
.filters {
    padding: 10px 15px;
    display: flex;
    gap: 5px;
}

/* ==============================
   PÁGINA DE LOGIN
   ============================== */
.login-body {
    background: linear-gradient(135deg, #0b141a 0%, #111b21 50%, #00a884 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', sans-serif;
    position: relative;
    overflow: hidden;
}

.login-body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0,168,132,0.1) 0%, transparent 70%);
    animation: pulse 15s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

.login-container {
    background: rgba(32, 44, 51, 0.95);
    backdrop-filter: blur(10px);
    padding: 40px 35px;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(0,168,132,0.2);
    position: relative;
    z-index: 1;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-container h2 {
    color: #00a884;
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0,168,132,0.3);
}

.login-container input {
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 15px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.1);
    background: rgba(11,20,26,0.8);
    color: #e9edef;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.login-container input::placeholder {
    color: #8696a0;
}

.login-container input:focus {
    border-color: #00a884;
    box-shadow: 0 0 15px rgba(0,168,132,0.3);
    background: rgba(11,20,26,0.9);
}

.login-container button {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #00a884 0%, #00c896 100%);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0,168,132,0.3);
}

.login-container button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,168,132,0.4);
    background: linear-gradient(135deg, #00c896 0%, #00d9a8 100%);
}

.login-container button:active {
    transform: translateY(0);
}

/* Ícone de WhatsApp no topo */
.login-container::before {
    content: '💬';
    display: block;
    font-size: 3rem;
    text-align: center;
    margin-bottom: 15px;
    filter: drop-shadow(0 5px 10px rgba(0,168,132,0.3));
}

/* Responsividade */
@media (max-width: 480px) {
    .login-container {
        padding: 30px 25px;
        margin: 20px;
    }

    .login-container h2 {
        font-size: 1.5rem;
    }
}
