/* =========================================
   VARIÁVEIS GLOBAIS E RESET
   ========================================= */
:root {
    --bg-color: #0b2b3b;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --accent: #00FFB8;
    --glass-bg: rgba(20, 40, 60, 0.45);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-blur: blur(20px) saturate(1.5);
    --panel-bg: rgba(10, 25, 40, 0.85);
    --item-hover: rgba(255, 255, 255, 0.1);
    --item-active: rgba(0, 255, 180, 0.15);
    --gradient-primary: linear-gradient(135deg, #00A8E8, #00FFB8);
    --danger: #ff4757;
    --warning: #ffd32a;
    --font-family: 'Segoe UI', system-ui, sans-serif;
}

/* =========================================
   TEMA NOTURNO (DARK MODE)
   ========================================= */
body.dark-theme {
    background-image: url("../img/Gemini_Generated_Image_91id5m91id5m91id.png") !important;
    background-color: #020813;
    /* Ajustes sutis no glassmorphism para contraste perfeito com o novo fundo */
    --glass-bg: rgba(5, 10, 20, 0.65);
    --panel-bg: rgba(2, 5, 10, 0.95);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-family); }

body { 
    background-color: var(--bg-color);
    background-image: url("../img/ChatGPT\ Image\ 2\ de\ jul.\ de\ 2026,\ 20_59_20.png"), linear-gradient(145deg, #0A2463, #247B7B);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-primary); 
    overflow: hidden; 
    height: 100vh; 
    width: 100vw;
    transition: background-image 0.5s ease-in-out;
}

/* Glassmorphism Classes */
.glass-panel { background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); border-radius: 16px; box-shadow: var(--glass-shadow); transition: background 0.3s, border-color 0.3s; }

/* Utilitários e Idiomas */
.hidden { display: none !important; }
.mb-1 { margin-bottom: 5px; } .mb-2 { margin-bottom: 10px; } .mb-3 { margin-bottom: 15px; } .mb-4 { margin-bottom: 20px; }
.w-100 { width: 100%; } .p-2 { padding: 10px; }
a { color: var(--accent); text-decoration: none; transition: 0.2s; }
a:hover { text-decoration: underline; color: #fff; }

.lang-sel { background: rgba(0,0,0,0.3); color: var(--text-primary); border: 1px solid var(--glass-border); padding: 8px 12px; border-radius: 12px; outline: none; font-size: 0.9rem; cursor: pointer; font-weight: bold; }
.lang-sel option { background: var(--bg-color); color: #fff; }

/* Botões Gerais */
button { font-family: inherit; outline: none; cursor: pointer; }
.btn-primary { background: var(--gradient-primary); color: #000; border: none; padding: 12px 20px; border-radius: 12px; font-weight: bold; transition: 0.2s; width: 100%; font-size: 1.05rem; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,255,180,0.3); }
.btn-secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--glass-border); padding: 12px 20px; border-radius: 12px; transition: 0.2s; }
.btn-secondary:hover { background: rgba(255,255,255,0.1); }
.icon-btn { background: transparent; border: none; color: var(--text-secondary); padding: 8px; border-radius: 50%; font-size: 1.1rem; transition: 0.2s; }
.icon-btn:hover { background: var(--item-hover); color: var(--text-primary); }

/* Inputs Gerais */
.input-group { position: relative; margin-bottom: 15px; width: 100%; }
.input-group i:not(.toggle-pass) { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); z-index: 2; }
.input-group input, .input-group select, .input-group textarea { width: 100%; padding: 14px 15px 14px 45px; background: rgba(0,0,0,0.25); border: 1px solid var(--glass-border); border-radius: 12px; color: var(--text-primary); font-size: 1rem; transition: 0.3s; position: relative; outline: none; }
.input-group textarea { padding-left: 15px; resize: vertical; min-height: 100px; }
.input-group input:focus, .input-group select:focus, .input-group textarea:focus { border-color: var(--accent); background: rgba(0,0,0,0.4); }
.input-group select option { background: var(--bg-color); color: #fff; }

/* Ícone de Visibilidade da Senha e Barra de Força */
.input-group i.toggle-pass { position: absolute; right: 15px; left: auto !important; top: 50%; transform: translateY(-50%); color: var(--text-secondary); cursor: pointer; z-index: 10; pointer-events: auto; font-size: 1.1rem; transition: color 0.2s; }
.input-group i.toggle-pass:hover { color: var(--text-primary); }
.pass-input { padding-right: 45px !important; }

.strength-container { width: 100%; height: 6px; background: rgba(0,0,0,0.3); border-radius: 3px; overflow: hidden; margin-top: -8px; }
.strength-bar { height: 100%; width: 0%; transition: width 0.3s, background-color 0.3s; }
.strength-weak { background-color: var(--danger); width: 33%; }
.strength-medium { background-color: #ffd32a; width: 66%; }
.strength-strong { background-color: var(--accent); width: 100%; }

/* Toasts e Modals */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--panel-bg); backdrop-filter: var(--glass-blur); padding: 14px 20px; border-radius: 10px; border-left: 4px solid var(--accent); box-shadow: 0 5px 15px rgba(0,0,0,0.4); display: flex; align-items: center; gap: 12px; animation: slideIn 0.3s forwards; }
@keyframes slideIn { from{transform:translateX(100%);opacity:0} to{transform:translateX(0);opacity:1} }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 3000; opacity: 0; pointer-events: none; transition: 0.3s; }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-box { background: var(--panel-bg); backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); border-radius: 16px; width: 90%; max-width: 650px; display: flex; flex-direction: column; box-shadow: 0 20px 40px rgba(0,0,0,0.5); transform: scale(0.95); transition: 0.3s; }
.modal-overlay.active .modal-box { transform: scale(1); }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 24px; overflow-y: auto; max-height: 70vh; } 
.modal-footer { padding: 18px 24px; border-top: 1px solid var(--glass-border); display: flex; justify-content: flex-end; gap: 10px; }

/* Context Menu e Undo Snackbar */
.glass-menu { position: fixed; background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); border-radius: 8px; padding: 5px 0; z-index: 9999; display: flex; flex-direction: column; box-shadow: var(--glass-shadow); }
.glass-menu .menu-item { padding: 10px 20px; cursor: pointer; color: var(--text-primary); display: flex; align-items: center; gap: 10px; transition: 0.2s; }
.glass-menu .menu-item:hover { background: var(--item-hover); color: var(--accent); }
.undo-snackbar { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-bg); border: 1px solid var(--glass-border); padding: 12px 24px; border-radius: 30px; display: flex; gap: 15px; align-items: center; z-index: 10000; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.undo-snackbar button { background: transparent; border: none; color: var(--accent); font-weight: bold; cursor: pointer; }

/* =========================================
   TELA DE LOGIN / AUTENTICAÇÃO
   ========================================= */
#auth-container { height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; position: relative; }
.auth-card { width: 100%; max-width: 450px; padding: 40px 35px; text-align: center; animation: floatUp 0.5s ease; }
.auth-card.large { max-width: 650px; max-height: 90vh; overflow-y: auto; }
@keyframes floatUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.logo { font-size: 2.8rem; font-weight: 700; margin-bottom: 5px; text-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.logo span { color: var(--accent); }
.footer-links { margin-top: 25px; font-size: 0.95rem; color: var(--text-secondary); }

.captcha-box { background: rgba(0,0,0,0.25); padding: 12px; border-radius: 12px; margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--glass-border); gap: 10px; }
#captcha-question { font-weight: bold; color: var(--accent); font-size: 1.2rem; letter-spacing: 4px; font-family: monospace; background: rgba(0,0,0,0.4); padding: 6px 12px; border-radius: 8px; text-shadow: 2px 2px 4px rgba(0,0,0,0.8); }
.captcha-box input { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(0,0,0,0.2); color: #fff; text-align: center; font-size: 1rem; outline: none; }

/* =========================================
   TELA DO APLICATIVO (EMAIL) E ADMIN
   ========================================= */
#app-container, #app-admin { display: flex; flex-direction: column; height: 100vh; }

.topbar { height: 64px; display: flex; align-items: center; padding: 0 20px; gap: 20px; z-index: 100; border-radius: 0 0 20px 20px; margin-bottom: 12px; flex-shrink: 0; }
.topbar .logo { font-size: 1.5rem; margin: 0; }
.search-wrapper { flex: 1; position: relative; max-width: 600px; }
.search-wrapper input { width: 100%; padding: 10px 15px 10px 40px; border-radius: 20px; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); color: #fff; outline: none; }
.search-wrapper i:not(.toggle-pass) { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }
.top-actions { margin-left: auto; display: flex; gap: 15px; align-items: center; }

.avatar-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--gradient-primary); display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; font-weight: bold; color: #000; }
.dropdown-menu { position: absolute; top: 120%; right: 0; width: 220px; padding: 10px; display: flex; flex-direction: column; z-index: 1000; }
.dropdown-menu hr { border-color: var(--glass-border); margin: 5px 0; }
.dropdown-menu a { padding: 10px; color: var(--text-primary); display: flex; align-items: center; gap: 10px; border-radius: 8px; }
.dropdown-menu a:hover { background: var(--item-hover); text-decoration: none; }

.main-layout { display: flex; flex: 1; padding: 0 12px 12px 12px; gap: 12px; height: calc(100vh - 76px); overflow: hidden; }

/* Sidebar & Drag Hover */
.sidebar { width: 260px; padding: 20px; display: flex; flex-direction: column; height: 100%; overflow-y: auto; flex-shrink: 0; transition: width 0.3s; }
.nav-item { padding: 12px 15px; color: var(--text-secondary); border-radius: 12px; display: flex; align-items: center; gap: 12px; margin-bottom: 5px; transition: 0.2s; text-decoration: none; border: 1px solid transparent; }
.nav-item i { width: 20px; text-align: center; font-size: 1.1rem; }
.nav-item:hover, .nav-item.active { background: var(--item-active); color: var(--accent); }
.nav-item.drag-hover { background: rgba(0, 255, 180, 0.2); border: 1px dashed var(--accent); }
.badge { margin-left: auto; background: var(--accent); color: #000; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: bold; }

/* Lista de E-mails e Ações em Massa */
.email-list-container { flex: 1; display: flex; flex-direction: column; min-width: 320px; height: 100%; }
.list-header { padding: 15px 20px; border-bottom: 1px solid var(--glass-border); display: flex; align-items: center; flex-shrink: 0; gap: 15px; }

.bulk-actions-bar { display: none; padding: 10px 20px; background: rgba(0,0,0,0.3); border-bottom: 1px solid var(--glass-border); align-items: center; gap: 10px; }
.bulk-actions-bar.active { display: flex; }
.bulk-actions-bar button { font-size: 0.9rem; padding: 6px 12px; }

.email-list { flex: 1; overflow-y: auto; padding: 10px; }
.email-item { display: flex; align-items: flex-start; gap: 15px; padding: 14px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; transition: 0.2s; margin-bottom: 6px; }
.email-item:hover { background: var(--item-hover); border-color: var(--glass-border); }
.email-item.active { background: var(--item-active); border-color: var(--accent); }
.email-item.unread .sender { font-weight: bold; color: #fff; }
.email-item.unread::before { content:''; display:block; width:8px; height:8px; background:var(--accent); border-radius:50%; margin-top: 5px; flex-shrink: 0; }

/* Custom Checkbox */
.email-checkbox { width: 18px; height: 18px; cursor: pointer; margin-top: 2px; accent-color: var(--accent); }

/* Painel de Leitura */
.reading-pane { flex: 1.5; display: flex; flex-direction: column; height: 100%; }
.reading-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-secondary); }
.reading-empty i { font-size: 4rem; margin-bottom: 15px; opacity: 0.5; }
.reading-content { display: flex; flex-direction: column; height: 100%; }
.reading-header { padding: 24px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: flex-start; flex-shrink: 0; }
.reading-subject { font-size: 1.6rem; margin-bottom: 15px; }
.reading-actions { display: flex; gap: 5px; }
.reading-sender { display: flex; align-items: center; gap: 15px; padding: 20px 24px; background: rgba(0,0,0,0.15); flex-shrink: 0; }
.reading-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--gradient-primary); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: bold; color: #000; }
.reading-body { flex: 1; padding: 24px; overflow-y: auto; line-height: 1.7; font-size: 1.05rem; }

/* Compositor de E-mail */
.compose-box { height: 85vh; display: flex; flex-direction: column; }
.compose-field { display: flex; border-bottom: 1px solid var(--glass-border); padding: 0 20px; align-items: center; }
.compose-field label { width: 70px; color: var(--text-secondary); font-weight: bold; }
.compose-field input { flex: 1; background: transparent; border: none; color: #fff; padding: 16px 0; outline: none; font-size: 1rem; }
.editor-toolbar { padding: 10px 20px; border-bottom: 1px solid var(--glass-border); display: flex; gap: 8px; background: rgba(0,0,0,0.2); }
.editor-content { flex: 1; padding: 20px; outline: none; overflow-y: auto; font-size: 1rem; line-height: 1.5; }

/* Lista de Bloqueados */
.blocked-item { display: flex; justify-content: space-between; padding: 10px; border-bottom: 1px solid var(--glass-border); align-items: center; }
.blocked-item button { padding: 5px 10px; font-size: 0.8rem; }

/* =========================================
   ESTILOS DO PAINEL ADMINISTRATIVO (INJEÇÃO)
   ========================================= */
.admin-content-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 10px; }
.admin-view { display: none; flex-direction: column; height: 100%; animation: slideIn 0.3s forwards; }
.admin-view.active { display: flex; overflow-y: auto; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 20px; }
.admin-card { background: rgba(0,0,0,0.25); border: 1px solid var(--glass-border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.admin-card::after { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%); opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.admin-card:hover::after { opacity: 1; }
.admin-card h3 { color: var(--text-secondary); font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; }
.admin-card .val { font-size: 2.5rem; font-weight: bold; color: var(--accent); }
.admin-card i { position: absolute; right: 20px; bottom: 20px; font-size: 3rem; color: rgba(255,255,255,0.05); }

.data-table-wrapper { background: rgba(0,0,0,0.25); border: 1px solid var(--glass-border); border-radius: 12px; overflow: hidden; flex: 1; display: flex; flex-direction: column; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 15px; border-bottom: 1px solid var(--glass-border); }
.data-table th { background: rgba(0,0,0,0.4); font-weight: bold; color: var(--accent); text-transform: uppercase; font-size: 0.85rem; letter-spacing: 1px; }
.data-table tr:hover { background: rgba(255,255,255,0.05); }
.data-table .action-btn { padding: 6px 12px; font-size: 0.85rem; border-radius: 6px; border: none; cursor: pointer; color: #fff; margin-right: 5px; }
.data-table .btn-edit { background: var(--warning); color: #000; }
.data-table .btn-del { background: var(--danger); }

.admin-header-title { font-size: 1.8rem; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }

/* Terminal Logs */
.terminal-box { background: #051014; border: 1px solid var(--glass-border); border-radius: 12px; padding: 20px; font-family: monospace; color: #00FFB8; height: 300px; overflow-y: auto; font-size: 0.9rem; line-height: 1.5; }


/* ==========================================================================
   ⚡ RECORTE ULTRA-RESPONSIVO EXCLUSIVO PARA SMARTPHONES (MODO APP INTELIGENTE)
   ========================================================================== */
@media (max-width: 768px) {
    /* Tranca o tamanho no display físico do celular para emular comportamento de App */
    body { overflow: hidden !important; height: 100vh !important; width: 100vw !important; }

    /* Barra Superior Funcional (Quebra a linha de busca perfeitamente) */
    .topbar { height: auto !important; padding: 10px 8px !important; flex-wrap: wrap !important; gap: 8px !important; }
    .topbar .logo { font-size: 1.1rem !important; }
    .top-actions { margin-left: auto !important; gap: 10px !important; }
    .search-wrapper { flex: 1 1 100% !important; max-width: 100% !important; order: 3 !important; margin-top: 2px !important; }
    .lang-sel { padding: 5px 6px !important; font-size: 0.8rem !important; }

    /* Layout da Área de Trabalho Principal */
    .main-layout { flex-direction: column !important; height: calc(100vh - 135px) !important; overflow: hidden !important; padding: 6px !important; gap: 8px !important; }

    /* Menu de Pastas Superior (Navegação horizontal por toque - Fica sempre visível) */
    .sidebar { width: 100% !important; height: auto !important; padding: 6px !important; flex-direction: row !important; overflow-x: auto !important; overflow-y: hidden !important; white-space: nowrap !important; gap: 6px !important; flex-shrink: 0 !important; }
    .sidebar button.btn-primary { width: auto !important; margin-bottom: 0 !important; padding: 8px 12px !important; font-size: 0.85rem !important; display: inline-block !important; }
    .sidebar nav.nav-menu { display: flex !important; flex-direction: row !important; gap: 4px !important; width: auto !important; }
    .sidebar .nav-item { margin-bottom: 0 !important; padding: 8px 12px !important; display: inline-flex !important; align-items: center !important; font-size: 0.85rem !important; }

    /* 📱 MÁGICA DO MODO APP: DINÂMICA DE TELA CHEIA VIA CSS (:has) */
    
    /* ESTADO 1: Sem e-mail aberto -> Mostra a lista completa ocupando 100% do espaço útil */
    .email-list-container { display: flex !important; width: 100% !important; height: calc(100vh - 200px) !important; flex: 1 !important; }
    .reading-pane { display: none !important; }

    /* ESTADO 2: Quando um e-mail é clicado (.active) -> Esconde a lista inteira e abre a leitura em 100% da tela */
    .main-layout:has(.email-item.active) .email-list-container { display: none !important; }
    .main-layout:has(.email-item.active) .reading-pane { display: flex !important; width: 100% !important; height: calc(100vh - 200px) !important; flex: 1 !important; flex-direction: column !important; }
    
    /* Controles de rolagem independente para a lista e o leitor */
    .email-list { flex: 1 !important; overflow-y: auto !important; }
    .reading-content { display: flex !important; flex-direction: column !important; height: 100% !important; width: 100% !important; }
    
    /* Destrava a rolagem fluida e confortável para ler o corpo da mensagem inteira */
    .reading-body { flex: 1 !important; overflow-y: auto !important; display: block !important; padding: 12px !important; font-size: 0.95rem !important; -webkit-overflow-scrolling: touch; color: #fff !important; }

    /* Compactação visual de cabeçalhos no mobile */
    .list-header { padding: 8px 12px !important; font-size: 0.85rem !important; }
    .email-item { padding: 10px !important; gap: 8px !important; }
    .reading-header { padding: 10px 12px !important; flex-direction: column !important; gap: 6px !important; border-bottom: 1px solid var(--glass-border) !important; }
    .reading-subject { font-size: 1.2rem !important; margin-bottom: 2px !important; line-height: 1.3 !important; font-weight: bold !important; }
    .reading-actions { width: 100% !important; justify-content: space-between !important; margin-top: 2px !important; }
    .reading-sender { padding: 8px 12px !important; flex-wrap: wrap !important; gap: 4px !important; }
    .reading-avatar { width: 34px !important; height: 34px !important; font-size: 0.95rem !important; }
    .reading-date { margin-left: 0 !important; width: 100% !important; font-size: 0.75rem !important; margin-top: 2px !important; }

    /* Telas de Login e Formulários */
    .auth-card { padding: 25px 15px !important; width: 100% !important; margin: 10px !important; }
    .auth-card form > div[style*="display: flex"] { flex-direction: column !important; gap: 0 !important; }
    .auth-card form > div[style*="display: flex"] > .input-group { width: 100% !important; margin-bottom: 15px !important; }
    .logo { font-size: 2.2rem !important; }

    /* Modais Globais */
    .modal-box { width: 95% !important; margin: 10px !important; max-height: 85vh !important; }
    .modal-body { padding: 15px !important; }
    .modal-header, .modal-footer { padding: 12px 15px !important; }
    .editor-toolbar { overflow-x: auto !important; flex-wrap: nowrap !important; padding: 5px !important; }
    .compose-field label { width: 45px !important; font-size: 0.85rem !important; }

    /* Painel Administrativo */
    .admin-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
    .admin-header-title { font-size: 1.1rem !important; }
    .data-table th, .data-table td { padding: 6px 8px !important; font-size: 0.75rem !important; }
}