/* Estilos Globais */
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f7f6; margin: 0; color: #333; position: relative; min-height: 100vh;}
.container { display: flex; justify-content: center; align-items: center; height: 100vh; z-index: 2; position: relative;}

/* Marca D'água */
.watermark { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; background-repeat: no-repeat; background-position: center; background-size: 70vmin auto; opacity: 0.04; pointer-events: none; display: none; }

#login-screen, #main-menu, #ajustes-screen { background: white; padding: 40px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); z-index: 2; position: relative;}
#login-screen { width: 100%; max-width: 360px; text-align: center; }
#main-menu, #ajustes-screen { display: none; width: 100%; max-width: 850px; }

.login-logo { display: none; margin: 0 auto 25px auto; max-width: 220px; height: auto; }

/* Inputs Modernizados (Corrigido Cursor Branco) */
input, textarea, select { width: 100%; padding: 12px; margin: 8px 0; border: 1px solid #dcdde1; border-radius: 8px; box-sizing: border-box; font-family: inherit; font-size: 14px; transition: all 0.3s ease; background-color: #fbfbfb; color: #2c3e50; caret-color: #3498db; }
input:focus, textarea:focus, select:focus { border-color: #3498db; box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2); outline: none; background-color: #ffffff; }

input[readonly], textarea[readonly], select:disabled { background-color: #e9ecef; cursor: not-allowed; color: #7f8c8d; border-color: #ddd; box-shadow: none; }

.search-bar { width: 100%; max-width: 300px; padding: 12px 18px; border: 2px solid #3498db; border-radius: 25px; outline: none; margin-right: auto; background-color: #fff; }

/* ================== BOTÕES MODERNIZADOS ================== */
button { cursor: pointer; border: none; border-radius: 8px; font-weight: 600; font-size: 14px; letter-spacing: 0.3px; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); box-shadow: 0 2px 4px rgba(0,0,0,0.1); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:active { transform: scale(0.96); box-shadow: 0 1px 2px rgba(0,0,0,0.1); } 

.btn-primary { padding: 14px; background: linear-gradient(135deg, #3498db, #2980b9); color: white; width: 100%; margin-top: 15px; }
.btn-primary:hover { background: linear-gradient(135deg, #2980b9, #1f6391); box-shadow: 0 6px 12px rgba(52, 152, 219, 0.3); transform: translateY(-2px); }

.btn-danger { background: linear-gradient(135deg, #e74c3c, #c0392b); color: white; padding: 10px 18px; }
.btn-danger:hover { background: linear-gradient(135deg, #c0392b, #962d22); box-shadow: 0 6px 12px rgba(231, 76, 60, 0.3); transform: translateY(-2px); }

.btn-excel { background: linear-gradient(135deg, #2ecc71, #27ae60); color: white; }
.btn-excel:hover { background: linear-gradient(135deg, #27ae60, #1e8449); box-shadow: 0 6px 12px rgba(46, 204, 113, 0.3); transform: translateY(-2px); }

.btn-pdf { background: linear-gradient(135deg, #9b59b6, #8e44ad); color: white; }
.btn-pdf:hover { background: linear-gradient(135deg, #8e44ad, #732d91); box-shadow: 0 6px 12px rgba(155, 89, 182, 0.3); transform: translateY(-2px); }

.btn-action { background: linear-gradient(135deg, #2ecc71, #27ae60); color: white; padding: 10px 18px; }
.btn-action:hover { background: linear-gradient(135deg, #27ae60, #1e8449); box-shadow: 0 6px 12px rgba(46, 204, 113, 0.3); transform: translateY(-2px); }

.btn-tool { background: linear-gradient(135deg, #f1c40f, #f39c12); color: white; padding: 10px 18px; }
.btn-tool:hover:not(:disabled) { background: linear-gradient(135deg, #f39c12, #d68910); box-shadow: 0 6px 12px rgba(243, 156, 18, 0.3); transform: translateY(-2px); }
.btn-tool:disabled { background: #bdc3c7; color: #7f8c8d; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-log { background: linear-gradient(135deg, #34495e, #2c3e50); color: white; padding: 10px 18px; }
.btn-log:hover { background: linear-gradient(135deg, #2c3e50, #1a252f); box-shadow: 0 6px 12px rgba(52, 73, 94, 0.3); transform: translateY(-2px); }

.button-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.menu-btn { background-color: #ffffff; border: 1px solid #e9ecef; padding: 30px 20px; font-size: 16px; color: #2c3e50; display: flex; flex-direction: column; align-items: center; gap: 15px; z-index: 2; position: relative; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.02); transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
.menu-btn:hover { transform: translateY(-5px); box-shadow: 0 12px 24px rgba(0,0,0,0.08); border-color: #3498db; color: #3498db; }
.menu-btn:active { transform: translateY(-2px) scale(0.98); box-shadow: 0 4px 8px rgba(0,0,0,0.05); }

/* Outros Elementos */
header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #ecf0f1; padding-bottom: 20px; margin-bottom: 20px; }
.header-direita { display: flex; align-items: center; gap: 20px; text-align: right; }
#data-hora-container { font-size: 13px; color: #7f8c8d; font-weight: bold; }
#relogio-digital { font-size: 20px; color: #2c3e50; }

/* ======== WIDGETS DO DASHBOARD MODO LINK ======== */
.dashboard-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 25px; }
.kpi-card { background: white; padding: 20px; border-radius: 12px; border: 1px solid #e9ecef; border-left: 5px solid #3498db; box-shadow: 0 4px 10px rgba(0,0,0,0.03); transition: transform 0.2s, box-shadow 0.2s; cursor: pointer; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0,0,0,0.08); }
.kpi-card.green { border-left-color: #27ae60; }
.kpi-card.purple { border-left-color: #9b59b6; }
.kpi-label { font-size: 12px; color: #7f8c8d; text-transform: uppercase; font-weight: bold; letter-spacing: 0.5px; }
.kpi-value { font-size: 28px; font-weight: bold; color: #2c3e50; margin-top: 5px; }
.kpi-zonas-container { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.zona-badge { background: #eef2f5; padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: bold; color: #34495e; border: 1px solid #dfe6e9; }

.bg-process-card { background: #f8f9fa; padding: 15px 20px; border-radius: 12px; border: 1px solid #e9ecef; margin-bottom: 25px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }
.bg-process-header { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: bold; color: #2c3e50; }
.progress-bar-bg { width: 100%; height: 10px; background: #dfe6e9; border-radius: 5px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #2ecc71, #27ae60); width: 0%; transition: width 0.5s ease; }
.btn-start-bg { background: linear-gradient(135deg, #34495e, #2c3e50); color: white; padding: 8px 16px; border-radius: 6px; font-size: 12px; }
.btn-start-bg:hover { background: linear-gradient(135deg, #2c3e50, #1a252f); transform: translateY(-1px); box-shadow: 0 4px 8px rgba(52, 73, 94, 0.3); }

.tela-planilha { display: none; padding: 30px; position: relative; z-index: 2;}
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; background: white; padding: 15px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); flex-wrap: wrap; align-items: center;}
.toolbar button { font-size: 13px; }

.table-container { background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); overflow-x: auto; max-height: 55vh; overflow-y: auto; border: 1px solid #f1f2f6;}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 15px; text-align: left; border-bottom: 1px solid #f1f2f6; font-size: 14px;}
th { background-color: #f8f9fa; color: #2c3e50; font-weight: 700; position: sticky; top: 0; z-index: 10; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px;}
tr { cursor: pointer; transition: background 0.2s; }
tr:hover { background-color: #f1f8ff; }
tr.selected { background-color: #d6eaf8; border-left: 4px solid #3498db; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); justify-content: center; align-items: center; z-index: 10000; }
.modal-content { background: white; padding: 35px; border-radius: 16px; width: 100%; max-width: 650px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.modal-content.small { max-width: 420px; }
.modal-content.large { max-width: 1000px; }

.modal-body-split { display: flex; gap: 25px; align-items: flex-start; }
.modal-form-side { flex: 2; min-width: 0; }
.modal-map-side { flex: 1.2; display: flex; flex-direction: column; gap: 15px; position: sticky; top: 0; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; border-bottom: 1px solid #f1f2f6; padding-bottom: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group.full-width { grid-column: span 2; }
.modal-footer { margin-top: 25px; display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid #f1f2f6; padding-top: 20px;}
.btn-cancel { background: #f1f2f6; color: #2c3e50; padding: 12px 20px; box-shadow: none;}
.btn-cancel:hover { background: #e2e4e9; transform: none; box-shadow: none; }

.checkbox-container { display: flex; gap: 20px; flex-wrap: wrap; background: #f8f9fa; padding: 15px; border-radius: 8px; border: 1px solid #e9ecef; }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-weight: bold; cursor: pointer; }
.checkbox-item input { width: 18px; height: 18px; cursor: pointer; margin: 0; }

.tag-tipo { padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: bold; display: inline-block; letter-spacing: 0.5px; text-transform: uppercase;}
.tag-lid { background-color: #e2e8f0; color: #2d3436; }
.tag-ele { background-color: #f8f9fa; color: #6c757d; border: 1px solid #dee2e6; }
.tag-admin { background-color: #ffeaa7; color: #d35400; }
.tag-geral { background-color: #d4edda; color: #155724; }
.tag-coord { background-color: #cce5ff; color: #004085; }
.tag-ver { background-color: #e2d9f3; color: #5a32a8; }

#loading-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.85); backdrop-filter: blur(2px); z-index: 99999; justify-content: center; align-items: center; flex-direction: column; }
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 45px; height: 45px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.info-secao-box { display: none; background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 5px solid #ccc; font-size: 13px; box-shadow: 0 2px 4px rgba(0,0,0,0.02);}
.map-container { width: 100%; height: 280px; background: #e9ecef; border-radius: 8px; border: 1px solid #ccc; z-index: 1;}

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px; margin-bottom: 20px; }
.chart-card { background: white; padding: 20px; border-radius: 12px; border: 1px solid #e9ecef; box-shadow: 0 4px 10px rgba(0,0,0,0.03); transition: transform 0.3s; }
.chart-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.06);}
.chart-card h3 { margin-top: 0; color: #2c3e50; font-size: 15px; border-bottom: 2px solid #ecf0f1; padding-bottom: 10px; margin-bottom: 15px; display: flex; align-items: center; gap: 8px;}
.mapa-calor-container { width: 100%; height: 450px; border-radius: 8px; z-index: 1; border: 1px solid #ccc;}

/* CSS DO CHAT IN-APP */
.chat-widget { position: fixed; bottom: 25px; right: 25px; z-index: 9000; }
.chat-btn { background: linear-gradient(135deg, #2ecc71, #27ae60); color: white; border-radius: 50%; width: 60px; height: 60px; display: flex; justify-content: center; align-items: center; font-size: 28px; cursor: pointer; box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4); transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); border: none; padding: 0;}
.chat-btn:hover { transform: scale(1.08) translateY(-3px); box-shadow: 0 8px 20px rgba(46, 204, 113, 0.5);}
.chat-btn:active { transform: scale(0.95); }
.chat-panel { display: none; position: fixed; bottom: 100px; right: 25px; width: 340px; height: 450px; background: white; border-radius: 16px; box-shadow: 0 15px 35px rgba(0,0,0,0.2); flex-direction: column; overflow: hidden; z-index: 9000; border: 1px solid #e9ecef; }
.chat-header { background: linear-gradient(135deg, #2c3e50, #1a252f); color: white; padding: 15px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); z-index: 2;}
.chat-body-users { flex: 1; overflow-y: auto; background: #f4f7f6; padding: 10px; }
.chat-body-msgs { flex: 1; overflow-y: auto; padding: 15px; background: #e5ddd5; display: none; flex-direction: column; gap: 10px; }
.chat-footer { padding: 12px; background: white; border-top: 1px solid #f1f2f6; display: none; gap: 10px; align-items: center;}
.user-chat-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: white; border-radius: 8px; border: 1px solid #eee; cursor: pointer; margin-bottom: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); transition: 0.2s;}
.user-chat-item:hover { background: #f1f8ff; border-color: #3498db; transform: translateX(3px);}
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #ccc; border: 2px solid white; box-shadow: 0 0 2px rgba(0,0,0,0.3);}
.status-dot.online { background: #2ecc71; }
.msg-balao { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.4; position: relative; word-wrap: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05);}
.msg-minha { background: #dcf8c6; align-self: flex-end; border-bottom-right-radius: 0;}
.msg-deles { background: white; align-self: flex-start; border-bottom-left-radius: 0;}
.msg-hora { font-size: 10px; color: #999; margin-top: 4px; text-align: right; display: block;}

/* =======================================================
   📱 GABINEX MOBILE - REGRAS DE RESPONSIVIDADE
   ======================================================= */

@media (max-width: 768px) {
	/* Manda o corpo do site parar de centralizar e ir pro topo */
    body {
        align-items: flex-start !important; 
        padding-top: 20px !important; 
        padding-bottom: 40px !important;
        height: auto !important;
        min-height: 100vh !important;
    }
    
    /* Garante que a caixa principal não fique presa */
    .container {
        margin: 0 auto !important;
        height: auto !important;
        min-height: 100% !important;
    }
	
	/* 1. Tela de Login */
    #login-screen { 
        width: 90%; 
        padding: 20px; 
    }
    
    /* 2. Cabeçalho (Header) */
    header { 
        flex-direction: column !important; 
        align-items: flex-start !important; 
        gap: 15px; 
        padding: 15px; 
    }
    .header-direita { 
        width: 100%; 
        justify-content: space-between; 
        margin-top: 10px; 
    }
    
    /* 3. Menus e Botões Gigantes (Ficam um embaixo do outro) */
    .button-grid { 
        grid-template-columns: 1fr !important; 
    }
    
    /* 4. Paineis Lado a Lado (Recepção e Avisos) */
    div[style*="display: flex; gap: 15px; margin-bottom: 30px; flex-wrap: wrap;"],
    div[style*="display: flex; gap: 20px; margin-top: 20px; flex-wrap: wrap;"] {
        flex-direction: column !important;
    }
    
    /* 5. Modais (Janelas Pop-up) */
    .modal-content, .modal-content.large, .modal-content.small { 
        width: 95% !important; 
        padding: 15px; 
        margin: 10px auto; 
        max-height: 90vh; 
        overflow-y: auto;
    }
    .modal-body-split { 
        flex-direction: column !important; 
    }
    
    /* 6. Formulários (Inputs um embaixo do outro) */
    .form-grid { 
        grid-template-columns: 1fr !important; 
    }
    
    /* 7. Gráficos e KPIs da Campanha */
    .dashboard-container { 
        grid-template-columns: 1fr !important; 
    }
    .kpi-card.purple { 
        grid-column: span 1 !important; 
    }
    .chart-grid { 
        grid-template-columns: 1fr !important; 
    }
    
    /* 8. Tabelas (Permite rolar para o lado com o dedo) */
    .table-container { 
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch; /* Rolagem suave no iPhone */
    }
    table { 
        width: 100%; 
        min-width: 600px; /* Impede as letras de espremerem */
    }

    /* 9. Botões da Barra de Ferramentas (Toolbar) */
    .toolbar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }
    .toolbar button, .toolbar input, .toolbar select {
        width: 100% !important;
        margin-left: 0 !important;
    }
}