/* =========================================================
   PALETA DE CORES GLOBAL E BASE
   ========================================================= */
:root {
    --primary-color: #1a2a40; 
    --hover-color: #2c4463;   
    --accent-color: #e63946;  
    --bg-color: #f0f4f8;      
    --table-bg: #ffffff;      
    --border-color: #e2e8f0;  
    --add-color: #2a9d8f;     
    --text-color: #1e293b;    
}

*, *::before, *::after { box-sizing: border-box; }

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-color);
    margin: 0; 
    min-height: 100vh; 
    overflow-x: hidden; 
    -webkit-tap-highlight-color: transparent;
}

/* =========================================================
   TELA DE LOGIN
   ========================================================= */
#login-screen {
    display: flex; width: 100%; height: 100vh;
    background-color: var(--primary-color);
    overflow: hidden; position: relative;
}

.login-panel {
    width: 100%; max-width: 500px; background-color: var(--table-bg);
    border-radius: 0 20px 20px 0; display: flex; flex-direction: column;
    justify-content: center; align-items: center; padding: 40px;
    box-shadow: 10px 0 30px rgba(0,0,0,0.25); z-index: 10;
}

.login-form-container { width: 100%; max-width: 320px; }

.login-logo {
    font-size: 2.2rem; font-weight: 900; color: var(--primary-color);
    display: flex; justify-content: center; align-items: center;
    gap: 12px; letter-spacing: 2px; margin-bottom: 5px;
}

.login-panel h2 { color: var(--primary-color); font-size: 1.4rem; margin-bottom: 25px; margin-top: 5px; text-align: center; font-weight: 800; }

.login-clock { border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; text-align: center; margin-bottom: 30px; background-color: #f8fafc; }
.clock-time { font-size: 2.2rem; font-weight: 800; color: var(--primary-color); font-variant-numeric: tabular-nums; letter-spacing: 1px; margin-bottom: 5px; }
.clock-date { font-size: 0.85rem; color: #64748b; font-weight: 500; }

.input-wrapper { position: relative; margin-bottom: 15px; width: 100%; }
.login-panel input {
    width: 100%; padding: 15px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 1rem;
    text-align: center; color: var(--text-color); font-weight: 500; outline: none; transition: all 0.3s; background-color: #ffffff;
}
.login-panel input::placeholder { color: #94a3b8; font-weight: 500; }
.login-panel input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(26, 42, 64, 0.1); }

.btn-toggle-senha { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: #64748b; cursor: pointer; font-size: 1.1rem; padding: 0; transition: color 0.2s; }
.btn-toggle-senha:hover { color: var(--primary-color); }

.btn-entrar {
    width: 100%; padding: 16px; background-color: var(--primary-color); color: white; border: none;
    border-radius: 8px; font-size: 1rem; font-weight: bold; cursor: pointer; transition: all 0.3s; margin-top: 15px;
    text-transform: uppercase; letter-spacing: 1px; display: flex; justify-content: center; align-items: center; position: relative;
}
.btn-entrar:hover { background-color: var(--hover-color); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(26, 42, 64, 0.3); }

.spinner { display: none; width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: #ffffff; animation: spin 0.8s linear infinite; position: absolute; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.btn-entrar.loading .btn-text { visibility: hidden; }
.btn-entrar.loading .spinner { display: block; }

#msg-erro { color: var(--accent-color); font-size: 0.9rem; margin-top: 15px; display: none; font-weight: 600; text-align: center; }

.illustration-area { flex: 1; display: flex; justify-content: center; align-items: flex-end; position: relative; padding: 0; }
.illustration-area img { max-width: 100%; max-height: 100vh; object-fit: contain; margin-bottom: 0; }

/* =========================================================
   LAYOUT PRINCIPAL E BARRA LATERAL
   ========================================================= */
#app-wrapper { display: none; width: 100%; height: 100vh; overflow: hidden; background-color: var(--bg-color); }
#app-wrapper.logged-in { display: flex; flex-direction: row; }

.sidebar {
    width: 320px; background-color: var(--primary-color); border-radius: 0 20px 20px 0;
    display: flex; flex-direction: column; height: 100vh; flex-shrink: 0;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15); z-index: 100;
}

.sidebar-logo { padding: 15px 20px 5px 20px; color: white; font-size: 1.6rem; font-weight: 900; letter-spacing: 2px; display: flex; align-items: center; gap: 12px; }

.sidebar-nav { display: flex; flex-direction: column; padding: 0 15px; }
.sidebar-nav-item {
    background: transparent; color: #cbd5e1; border: none; padding: 8px 15px;
    font-weight: 600; font-size: 0.85rem; cursor: pointer; text-align: left;
    border-radius: 8px; margin-bottom: 2px; transition: all 0.2s; display: flex; align-items: center; text-decoration: none;
}
.sidebar-nav-item i { width: 25px; font-size: 1rem; text-align: center; margin-right: 8px; }
.sidebar-nav-item:hover { background: rgba(255,255,255,0.1); color: white; transform: translateX(5px); }

/* =========================================================
   CHAT
   ========================================================= */
.chat-wrapper { flex: 1; display: flex; flex-direction: column; padding: 5px 15px 15px 15px; overflow: hidden; min-height: 0; }
.chat-panel { background-color: var(--table-bg); border-radius: 12px; display: flex; flex-direction: column; flex: 1; overflow: hidden; box-shadow: inset 0 2px 10px rgba(0,0,0,0.05); }
.chat-header { background-color: #1d4ed8; color: white; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 1rem; z-index: 2; }
.chat-messages { flex: 1; padding: 15px; overflow-y: auto; background-color: #f8fafc; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }

.chat-input-area { display: flex; padding: 12px 12px; border-top: 1px solid var(--border-color); background: white; gap: 8px; align-items: center; }
.btn-chat-urgente { background: transparent; border: none; color: #94a3b8; width: 30px; height: 30px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: all 0.2s; font-size: 1.3rem; border-radius: 50%; flex-shrink: 0; padding: 0; }
.btn-chat-urgente:hover { transform: scale(1.1); color: var(--accent-color); }
.btn-chat-urgente.active { color: var(--accent-color) !important; background-color: #fee2e2 !important; transform: scale(1.1); }
.chat-input-area input { flex: 1; min-width: 0; padding: 10px 15px; border: 1px solid var(--border-color); border-radius: 20px; font-size: 0.9rem; outline: none; background: #f1f5f9; color: var(--text-color); transition: all 0.2s; }
.chat-input-area input:focus { border-color: #1d4ed8; background: white; }
.btn-chat-send { background: #1d4ed8; border: none; color: white; border-radius: 50%; width: 38px; height: 38px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: transform 0.2s; flex-shrink: 0; padding: 0; font-size: 0.95rem; }
.btn-chat-send:hover { transform: scale(1.08); background: #1e40af; }

.msg-wrap { display: flex; flex-direction: column; max-width: 90%; }
.msg-wrap.mine { align-self: flex-end; align-items: flex-end; }
.msg-wrap.theirs { align-self: flex-start; align-items: flex-start; }
.msg-bubbles-container { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.msg-wrap.mine .msg-bubbles-container { align-items: flex-end; }
.msg-wrap.theirs .msg-bubbles-container { align-items: flex-start; }

.msg-bubble { padding: 9px 13px; border-radius: 16px; font-size: 0.85rem; line-height: 1.4; position: relative; word-wrap: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05); max-width: 100%; }
.msg-wrap.mine .msg-bubble { background-color: #dcfce7; color: #064e3b; border-bottom-right-radius: 4px; border: 1px solid #bbf7d0; }
.msg-wrap.theirs .msg-bubble { background-color: white; color: var(--text-color); border-bottom-left-radius: 4px; border: 1px solid var(--border-color); }
.msg-wrap .msg-bubble.urgent, .msg-wrap.mine .msg-bubble.urgent, .msg-wrap.theirs .msg-bubble.urgent { background-color: var(--accent-color) !important; color: #ffffff !important; border: none !important; }
.msg-wrap .msg-bubble.urgent strong { color: #ffffff !important; font-weight: 900; }

.msg-name { font-size: 0.65rem; font-weight: 800; color: #64748b; margin-bottom: 2px; margin-left: 6px; margin-right: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.msg-time { font-size: 0.6rem; color: #94a3b8; margin-top: 2px; margin-left: 6px; margin-right: 6px; }

/* =========================================================
   ÁREA DE PACIENTES (DIREITA) E TABELAS
   ========================================================= */
#main-content { flex: 1; overflow-y: auto; padding: 30px; display: flex; flex-direction: column; align-items: center; }

#main-header { width: 100%; max-width: 1100px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 15px; }
#main-header h1 { color: var(--primary-color); margin: 0; text-transform: uppercase; letter-spacing: 2px; font-size: 1.8rem; font-weight: 900; }
.header-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-clear { background-color: transparent; color: var(--accent-color); border: 2px solid var(--accent-color); padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 0.9rem; transition: all 0.3s ease; }
.btn-clear:hover { background-color: var(--accent-color); color: white; }
.btn-sair { background-color: transparent; color: #64748b; border: 2px solid #cbd5e1; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 0.9rem; transition: all 0.3s ease; }
.btn-sair:hover { background-color: #cbd5e1; color: var(--primary-color); }

.dashboard-cards { width: 100%; max-width: 1100px; display: flex; gap: 15px; margin-bottom: 25px; }
.card { flex: 1; background-color: transparent; padding: 15px 20px; border-radius: 8px; border: 1px solid var(--border-color); display: flex; flex-direction: row; justify-content: space-between; align-items: center; transition: all 0.2s ease; }
.card:hover { background-color: #f8fafc; border-color: #cbd5e1; }
.card-title { font-size: 0.85rem; color: #64748b; font-weight: 600; margin-bottom: 0; }
.card-value { font-size: 1.5rem; font-weight: 700; color: var(--text-color); line-height: 1; }

.btn-add { background-color: var(--add-color); color: white; border: none; padding: 14px 30px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 1rem; transition: all 0.3s ease; box-shadow: 0 4px 6px rgba(42, 157, 143, 0.2); margin-top: 10px; margin-bottom: 25px; letter-spacing: 1px; }
.btn-add:hover { background-color: #21867a; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(42, 157, 143, 0.3); }

.table-container { width: 100%; max-width: 1100px; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; margin-bottom: 5px; }
table { width: 100%; border-collapse: separate; border-spacing: 0 12px; min-width: 950px; table-layout: fixed; }
th { color: var(--primary-color); padding: 0 15px 10px 15px; text-align: left; font-size: 0.8rem; letter-spacing: 1.5px; font-weight: 800; border-bottom: 2px solid var(--border-color); }
td { padding: 10px 15px; background-color: var(--table-bg); border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); transition: all 0.2s; }

/* AJUSTE DAS BORDAS - PRIMEIRA COLUNA AGORA É A DO NOME */
td:first-child { border-left: 1px solid var(--border-color); border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
td:last-child { border-right: 1px solid var(--border-color); border-top-right-radius: 12px; border-bottom-right-radius: 12px; }

tr { box-shadow: 0 4px 6px rgba(0,0,0,0.01); transition: box-shadow 0.2s; }
tr:hover { box-shadow: 0 8px 15px rgba(26, 42, 64, 0.05); }
tr:hover td { border-color: #cbd5e1; }

/* BARRAS DE COR (PRIORIDADE E ALERTA) NA PRIMEIRA COLUNA (NOME) */
@media (min-width: 769px) {
    tr.linha-prio td { background-color: #fff0f1 !important; border-color: #ffccd5; }
    tr.linha-prio td:first-child { border-left: 5px solid var(--accent-color) !important; }

    tr.linha-alerta td { background-color: #fefce8 !important; border-color: #fde047 !important; }
    tr.linha-alerta td:first-child { border-left: 5px solid #eab308 !important; }
}

.col-index { display: none !important; width: 0; padding: 0; margin: 0; border: none; }
.col-iniciais { width: 230px; } 
.col-status { width: 180px; } 
.col-prioridade { width: 60px; text-align: center; }
.col-sala { width: 75px; text-align: center; } 
.col-professor { width: 60px; text-align: center; }
.col-responsavel { width: 150px; }
.col-acao { width: 140px; text-align: center; }
.col-toggle { display: none; } 

td input[type="text"] { width: 100%; max-width: 100%; padding: 10px; border: 1px solid transparent; border-radius: 6px; font-size: 15px; transition: all 0.3s; color: var(--text-color); background-color: transparent; text-transform: uppercase; box-sizing: border-box; }
td input[type="text"]:focus, td input[type="text"]:hover { outline: none; border-color: var(--border-color); background-color: #f8fafc; }
input[id^="nome_"] { font-weight: 900 !important; font-size: 17px !important; color: var(--primary-color) !important; letter-spacing: 0.5px; }
.input-sala { color: #64748b !important; font-weight: 700 !important; font-size: 14px !important; text-align: center; }
td select { appearance: none; -webkit-appearance: none; width: 100%; padding: 10px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 800; text-align: center; cursor: pointer; border: 1px solid transparent; text-transform: uppercase; letter-spacing: 0; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: all 0.3s; box-sizing: border-box;}
td select:hover { filter: brightness(0.95); }
select option { background-color: white; color: var(--text-color); text-transform: none; font-weight: 500; }

/* =========================================================
   CRONÔMETRO DE ESPERA (DESIGN CLEAN)
   ========================================================= */
.timer-espera { 
    font-size: 0.75rem; 
    font-weight: 700; 
    text-align: center; 
    margin-top: 4px; 
    padding: 0; 
    width: 100%; 
    display: none; 
    letter-spacing: 0.5px; 
    background: transparent; 
    border: none; 
}
.timer-espera.bom { color: #94a3b8; } 
.timer-espera.atencao { color: #d97706; } 
.timer-espera.critico { 
    color: #ef4444; 
    font-weight: 800; 
    animation: pulse-text-red 2.5s infinite; 
}

@keyframes pulse-text-red { 
    0%, 100% { opacity: 1; } 
    50% { opacity: 0.5; } 
}

.check-prioridade { width: 22px; height: 22px; cursor: pointer; accent-color: var(--accent-color); margin: 0 auto; display: block; }
.check-professor { width: 22px; height: 22px; cursor: pointer; accent-color: var(--primary-color); margin: 0 auto; display: block; }
.btn-delete, .btn-bell, .btn-assumir { border: none; border-radius: 8px; width: 34px; height: 34px; font-size: 16px; font-weight: bold; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; transition: all 0.2s; }

.btn-delete { background-color: #f8fafc; color: #cbd5e1; }
.btn-delete:hover { background-color: #fee2e2; color: var(--accent-color); transform: scale(1.1); }
.btn-bell { background-color: #f8fafc; color: #cbd5e1; }
.btn-bell:hover { background-color: #fef08a; color: #ca8a04; transform: scale(1.1); }
.btn-bell.active { background-color: #fef08a; color: #ca8a04; animation: bell-ring 1.5s infinite; }
.btn-assumir { background-color: #dcfce7; color: #166534; }
.btn-assumir:hover { background-color: #bbf7d0; color: #14532d; transform: scale(1.1); }

@keyframes bell-ring { 0%, 100% { transform: rotate(0deg); } 10%, 30%, 50% { transform: rotate(15deg) scale(1.1); } 20%, 40% { transform: rotate(-15deg) scale(1.1); } 60% { transform: rotate(0deg) scale(1.1); } }

.msg-vazia { text-align: center; color: #94a3b8; font-size: 1.1rem; padding: 40px 20px; display: none; line-height: 1.5; width: 100%; max-width: 1100px; }
.lgpd-warning { background-color: #f8fafc; color: #475569; border: 1px solid #e2e8f0; border-left: 4px solid var(--primary-color); padding: 15px 20px; margin-top: 15px; border-radius: 8px; font-size: 0.85rem; line-height: 1.5; width: 100%; display: flex; align-items: center; gap: 15px; }
.lgpd-warning i { font-size: 1.4rem; color: var(--primary-color); }
.lgpd-warning div { flex: 1; text-align: left; }
.lgpd-warning strong { color: var(--primary-color); }
#status-conexao { font-size: 13px; color: #64748b; text-align: center; margin-top: 30px; width: 100%; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;}
.section-title { width: 100%; max-width: 1100px; margin-top: 15px; margin-bottom: 0px; text-align: center; }
.section-title h2 { font-size: 1.1rem; letter-spacing: 1px; margin: 0; text-transform: uppercase; font-weight: 900;}

/* =========================================================
   MODAIS GLOBAIS E MENU DE CALCULADORAS
   ========================================================= */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(26, 42, 64, 0.7); display: flex; justify-content: center; align-items: center; z-index: 9999; opacity: 0; visibility: hidden; transition: all 0.3s ease; backdrop-filter: blur(4px); }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-box { background-color: var(--table-bg); width: 90%; max-width: 850px; height: 85vh; border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,0.3); transform: translateY(-20px); transition: all 0.3s ease; }
.modal-overlay.active .modal-box { transform: translateY(0); }
.modal-header { padding: 20px 25px; border-bottom: 2px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background-color: var(--primary-color); color: white; border-top-left-radius: 12px; border-top-right-radius: 12px; }
.modal-header h2 { margin: 0; font-size: 1.4rem; letter-spacing: 1px; }
.btn-close-modal { background: transparent; border: none; color: white; font-size: 28px; cursor: pointer; line-height: 1; transition: color 0.2s; }
.btn-close-modal:hover { color: var(--accent-color); }
.modal-body { padding: 25px; overflow-y: auto; flex: 1; font-size: 0.95rem; line-height: 1.6; color: var(--text-color); }

.modal-body h3 { color: var(--primary-color); margin-top: 25px; margin-bottom: 10px; font-size: 1.1rem; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { margin-bottom: 15px; margin-top: 0; }
.modal-body ul { margin-top: 5px; padding-left: 20px; }
.modal-body li { margin-bottom: 8px; }
.modal-body strong { color: var(--primary-color); }

.box-copia { background-color: #f8fafc; border-left: 4px solid var(--primary-color); padding: 15px; margin-bottom: 15px; border-radius: 4px; font-family: 'Courier New', Courier, monospace; font-size: 0.9rem; color: #334155; white-space: pre-wrap; }
.btn-copiar { background-color: var(--primary-color); color: white; border: none; padding: 12px 20px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 0.9rem; transition: all 0.3s ease; box-shadow: 0 4px 6px rgba(0,0,0,0.1); display: inline-flex; align-items: center; gap: 8px; }
.btn-copiar:hover { background-color: var(--hover-color); transform: translateY(-2px); }

.calc-category-title { color: var(--primary-color); font-size: 1.05rem; border-bottom: 2px solid var(--border-color); padding-bottom: 8px; margin-bottom: 15px; margin-top: 25px; text-transform: uppercase; letter-spacing: 1px;}
.calc-category-title:first-child { margin-top: 0; }
.calc-menu-btn { width: 100%; text-align: left; background: #f8fafc; border: 1px solid var(--border-color); padding: 15px 20px; border-radius: 8px; font-weight: 700; font-size: 0.95rem; color: var(--text-color); cursor: pointer; transition: all 0.2s; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.calc-menu-btn::after { content: '\f054'; font-family: 'Font Awesome 5 Free'; font-weight: 900; color: #cbd5e1; transition: transform 0.2s; }
.calc-menu-btn:hover { background: white; border-color: var(--primary-color); color: var(--primary-color); transform: translateX(5px); box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.calc-menu-btn:hover::after { color: var(--primary-color); transform: translateX(3px); }
.calc-menu-btn.external::after { content: '\f35d'; }

.calc-view { display: none; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.btn-voltar-calc { background: transparent; border: none; color: #64748b; font-weight: 800; font-size: 0.9rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px; padding: 0; transition: color 0.2s; text-transform: uppercase; letter-spacing: 0.5px;}
.btn-voltar-calc:hover { color: var(--primary-color); }

.cp-btn-group { display: flex; gap: 8px; margin-top: 5px; margin-bottom: 15px; flex-wrap: wrap;}
.cp-btn { flex: 1; min-width: 80px; padding: 10px 5px; border: 1px solid var(--border-color); background: #ffffff; cursor: pointer; border-radius: 8px; font-size: 0.8rem; font-weight: 700; color: #64748b; transition: all 0.2s; text-align: center; }
.cp-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); box-shadow: 0 4px 10px rgba(26,42,64,0.2); }
.cp-label { font-size: 0.85rem; font-weight: 800; color: var(--primary-color); margin-bottom: 5px; display: block; text-transform: uppercase; letter-spacing: 0.5px;}

.calc-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.95rem; background-color: #ffffff; color: var(--text-color); box-sizing: border-box;}
.calc-btn { width: 100%; padding: 12px; background-color: var(--primary-color); color: white; border: none; border-radius: 6px; font-weight: bold; font-size: 0.95rem; cursor: pointer; transition: all 0.2s; margin-top: 10px; }
.calc-btn:hover { background-color: var(--hover-color); }
.calc-result { text-align: center; font-weight: bold; font-size: 1.15rem; color: var(--primary-color); margin-top: 15px; margin-bottom: 0; min-height: 25px; }

/* =========================================================
   RESPONSIVIDADE (DESKTOP E MOBILE)
   ========================================================= */
@media (min-width: 769px) {
    .mobile-only { display: none !important; }
    .desktop-hidden { display: none !important; }
    
    .chat-panel { background-color: rgba(0, 0, 0, 0.15) !important; box-shadow: inset 0 2px 10px rgba(0,0,0,0.1) !important; border: none !important; }
    .chat-header { background: transparent !important; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
    .chat-messages { background: transparent !important; }
    .chat-input-area { background: transparent !important; border-top: 1px solid rgba(255, 255, 255, 0.05) !important; }
    .chat-input-area input { background-color: rgba(255, 255, 255, 0.1) !important; color: white !important; border: 1px solid rgba(255, 255, 255, 0.1) !important; }
    .chat-input-area input::placeholder { color: #cbd5e1 !important; }
    .chat-input-area input:focus { background-color: rgba(255, 255, 255, 0.15) !important; border-color: var(--add-color) !important; }
    
    .msg-wrap.mine .msg-bubble { background: var(--add-color) !important; color: white !important; border: none !important; }
    .msg-wrap.theirs .msg-bubble { background: #334155 !important; color: white !important; border: none !important; }
    .msg-wrap .msg-bubble.urgent, .msg-wrap.mine .msg-bubble.urgent, .msg-wrap.theirs .msg-bubble.urgent { background-color: var(--accent-color) !important; color: #ffffff !important; border: none !important; }
    .msg-name { color: #94a3b8 !important; }
    .msg-time { color: #64748b !important; }

    .acao-group-main { display: flex; gap: 5px; justify-content: center; margin-top: 4px; }
}

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .illustration-area { display: none; }
    .login-panel { max-width: 100%; border-radius: 0; padding: 20px; }
    
    #app-wrapper.logged-in { display: block; height: auto; overflow: visible; padding-bottom: 80px; }
    
    .sidebar { position: fixed; width: 100%; height: 0; bottom: 0; left: 0; background: transparent; z-index: 99999; box-shadow: none; overflow: visible; pointer-events: none;}
    .sidebar-logo { display: none; }
    
    .top-bar-mobile { background-color: var(--primary-color); color: white; width: 100%; padding: calc(15px + env(safe-area-inset-top)) 15px 15px 15px; text-align: center; font-size: 1.5rem; font-weight: 900; letter-spacing: 2px; position: fixed; top: 0; left: 0; z-index: 1000; display: flex; justify-content: center; align-items: center; gap: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.25); border-radius: 0 0 24px 24px; }
    
    #main-content { padding: calc(95px + env(safe-area-inset-top)) 10px 30px 10px; height: auto; overflow: visible; }
    #main-header h1 { display: none; } 
    
    .header-buttons { width: 100%; justify-content: center; margin-bottom: 10px; }
    .dashboard-cards { flex-direction: row; flex-wrap: wrap; gap: 5px; margin-bottom: 15px; }
    .card { padding: 10px; flex: 1 1 calc(33% - 5px); min-width: 80px; flex-direction: column; text-align: center; justify-content: center; gap: 4px; border-radius: 8px;}
    .card-title { font-size: 0.55rem; text-align: center; margin-bottom: 0; line-height: 1.2; }
    .card-value { font-size: 1.1rem; }

    .table-container { width: 100%; padding: 0 5px; box-sizing: border-box; margin-bottom: 10px; overflow-x: hidden; } 
    table, thead, tbody, tr, td { display: block; width: 100%; min-width: 0 !important; box-sizing: border-box; } 
    thead { display: none; } 
    tbody { display: flex; flex-direction: column; gap: 12px; width: 100%; padding-bottom: 5px; }
    
    tr { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--border-color) !important; border-radius: 16px !important; padding: 15px 40px 15px 45px !important; background: var(--table-bg) !important; box-shadow: 0 4px 10px rgba(26, 42, 64, 0.05); margin: 0; position: relative; width: 100%; max-width: 100%; min-height: 85px; transition: all 0.3s ease; }
    tr.linha-prio { border-left: 6px solid var(--accent-color) !important; box-shadow: 0 4px 12px rgba(230, 57, 70, 0.1) !important;}
    tr.linha-alerta { border-left: 6px solid #eab308 !important; box-shadow: 0 4px 12px rgba(234, 179, 8, 0.1) !important;}
    tr.expanded { flex-direction: row; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; padding: 18px 18px 18px 45px !important; }
    
    td { display: flex !important; flex-direction: column !important; padding: 0 !important; border: none !important; position: relative; margin-bottom: 12px; background-color: transparent !important;} 
    td::before { content: attr(data-label); font-weight: 700; color: #94a3b8; font-size: 0.65rem; text-transform: uppercase; margin-bottom: 6px; letter-spacing: 0.5px; display: block; }
    td.col-index { display: none !important; }
    
    .col-toggle { display: flex !important; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 35px; height: 35px; justify-content: center; align-items: center; font-size: 1.2rem; color: #94a3b8; cursor: pointer; margin-bottom: 0 !important; }
    tr.expanded .col-toggle { top: 15px; transform: none; }
    
    tr:not(.expanded) .col-status, tr:not(.expanded) .col-prioridade, tr:not(.expanded) .col-sala, tr:not(.expanded) .col-professor, tr:not(.expanded) .col-acao { display: none !important; }
    tr:not(.expanded) td::before { display: none !important; } 
    tr:not(.expanded) td { margin-bottom: 0 !important; }
    tr:not(.expanded) .col-iniciais { width: 100%; justify-content: center; margin-bottom: 2px !important;}
    tr:not(.expanded) .col-responsavel { width: 100%; flex-direction: row !important; justify-content: center; align-items: center; gap: 5px; }
    tr:not(.expanded) .col-responsavel::before { display: block !important; content: "RESPONSÁVEL: "; font-size: 0.75rem; color: #64748b; margin: 0; font-weight: 700; }
    tr:not(.expanded) input, tr:not(.expanded) select { background: transparent !important; border: none !important; box-shadow: none !important; text-align: center !important; padding: 0 !important; height: auto !important; }
    tr:not(.expanded) input { font-size: 1.15rem !important; font-weight: 900 !important; color: var(--primary-color) !important; margin-bottom: 2px;}
    tr:not(.expanded) select { font-size: 0.85rem !important; font-weight: 700 !important; width: auto !important; color: var(--primary-color) !important; appearance: none; -webkit-appearance: none;}

    tr.expanded .col-iniciais { width: 100%; }
    tr.expanded .col-status { width: 100%; }
    tr.expanded .col-sala { width: 48%; } 
    tr.expanded .col-responsavel { width: 48%; }
    tr.expanded .col-prioridade { width: 48%; flex-direction: row !important; justify-content: space-between; align-items: center; background: #f8fafc !important; padding: 12px 15px !important; border-radius: 10px; border: 1px solid rgba(0,0,0,0.05) !important; margin-bottom: 0; }
    tr.expanded .col-prioridade::before { content: 'Prioridade'; font-size: 0.75rem; color: var(--primary-color); margin: 0; }
    tr.expanded .col-professor { width: 48%; flex-direction: row !important; justify-content: space-between; align-items: center; background: #f8fafc !important; padding: 12px 15px !important; border-radius: 10px; border: 1px solid rgba(0,0,0,0.05) !important; margin-bottom: 0; }
    tr.expanded .col-professor::before { content: 'Prof/Resid'; font-size: 0.75rem; color: var(--primary-color); margin: 0; }
    tr.expanded .col-acao { width: 100%; flex-direction: row !important; justify-content: flex-end; align-items: center; margin-top: 5px; margin-bottom: 0; border-top: 1px solid rgba(0,0,0,0.05) !important; padding-top: 15px !important; }
    tr.expanded .col-acao::before { display: none !important; }

    .acao-group-main { display: flex; gap: 10px; justify-content: flex-end; width: 100%; }
    .check-prioridade, .check-professor { width: 22px !important; height: 22px !important; margin: 0 !important; transform: scale(1.1); }
    .btn-delete, .btn-bell, .btn-assumir { width: 45px; height: 45px; border-radius: 12px; font-size: 20px; }
    
    td input[type="text"], td select { width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; padding: 14px !important; font-size: 0.95rem !important; border-radius: 10px !important; background-color: #f8fafc !important; border: 1px solid var(--border-color) !important; color: var(--text-color) !important; font-weight: 600; height: 50px; }
    td input[type="text"]:focus, td select:focus { border-color: var(--primary-color) !important; background-color: #ffffff !important; box-shadow: 0 0 0 3px rgba(26, 42, 64, 0.1); outline: none; }
    input[id^="nome_"] { font-size: 1.05rem !important; text-transform: uppercase; }
    .input-sala { text-align: left !important; margin: 0 !important; }
    .btn-add { width: 100%; max-width: 100%; padding: 16px; margin-top: 10px; margin-bottom: 30px; border-radius: 12px; font-size: 1.05rem; box-shadow: 0 4px 15px rgba(42, 157, 143, 0.3); }

    .bottom-nav-mobile { 
        position: fixed; 
        bottom: 0 !important; 
        left: 0; 
        width: 100%; 
        height: calc(65px + env(safe-area-inset-bottom)) !important; 
        background-color: var(--primary-color); 
        display: flex; 
        justify-content: space-around; 
        align-items: center; 
        z-index: 1000; 
        border-radius: 20px 20px 0 0; 
        padding-top: 0 !important; 
        padding-bottom: env(safe-area-inset-bottom) !important; 
        box-sizing: border-box !important;
    }
    .nav-btn { background: transparent; border: none; color: #cbd5e1; font-size: 1.4rem; padding: 10px; cursor: pointer; transition: 0.2s; }
    .nav-btn:hover { color: white; }
    .nav-btn-chat-wrapper { position: relative; top: -20px; }
    .nav-btn-chat { background-color: #1d4ed8; color: white; border: 4px solid var(--bg-color); border-radius: 50%; width: 65px; height: 65px; font-size: 1.8rem; display: flex; justify-content: center; align-items: center; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.2); padding: 0; }
    .chat-badge { position: absolute; top: -2px; right: -2px; background-color: var(--accent-color); color: white; font-size: 0.75rem; font-weight: 900; width: 24px; height: 24px; border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.3); border: 2px solid var(--primary-color); }

    .chat-wrapper { position: static; pointer-events: auto; }
    .chat-panel { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; width: 100% !important; height: 100% !important; opacity: 0; visibility: hidden; transform: translateY(20px); transition: 0.3s ease; z-index: 9999 !important; background-color: var(--bg-color) !important; box-shadow: none !important; border-radius: 0 !important; border: none !important; display: flex !important; flex-direction: column !important; }
    .chat-panel.active { opacity: 1; visibility: visible; transform: translateY(0); }
    .chat-header { background-color: var(--primary-color) !important; color: white !important; padding: calc(15px + env(safe-area-inset-top)) 20px 15px 20px !important; border-bottom: none !important; border-radius: 0 0 24px 24px !important; box-shadow: 0 4px 15px rgba(0,0,0,0.25) !important; font-size: 1.3rem !important; font-weight: 900 !important; letter-spacing: 1px; display: flex; justify-content: center; align-items: center; position: relative; }
    .chat-header span { display: flex; align-items: center; justify-content: center; width: 100%; }
    .chat-header .btn-close-modal { display: block !important; position: absolute; right: 15px; top: calc(50% + (env(safe-area-inset-top) / 2)); transform: translateY(-50%); font-size: 2.2rem !important; color: white !important; background: transparent; border: none; padding: 0; cursor: pointer; }
    .chat-messages { background-color: transparent !important; flex: 1 !important; padding-bottom: 20px !important; }
    .chat-input-area { background: white !important; border-top: 1px solid var(--border-color) !important; padding: 15px !important; padding-bottom: calc(15px + env(safe-area-inset-bottom)) !important; }
    .chat-input-area input { background: #f1f5f9 !important; color: var(--text-color) !important; border: 1px solid var(--border-color) !important; }
    .chat-input-area input:focus { border-color: #1d4ed8 !important; background: white !important; }
    .msg-wrap.mine .msg-bubble { background-color: #dcfce7 !important; color: #064e3b !important; border: 1px solid #bbf7d0 !important; }
    .msg-wrap.theirs .msg-bubble { background-color: white !important; color: var(--text-color) !important; border: 1px solid var(--border-color) !important; }
    .msg-name { color: #64748b !important; }
    .msg-time { color: #94a3b8 !important; }
}

/* =========================================================
   MENU DROPDOWN (MEDICINA)
   ========================================================= */
.nav-dropdown { position: relative; width: 100%; }
.dropdown-toggle { width: 100%; justify-content: space-between; }
.arrow-icon { margin-left: auto; font-size: 0.8rem; transition: transform 0.3s; }

.dropdown-menu { 
   position: absolute; left: 100%; top: 0; 
   background-color: var(--primary-color); 
   min-width: 200px; border-radius: 0 12px 12px 0;
   box-shadow: 4px 4px 15px rgba(0,0,0,0.2);
   opacity: 0; visibility: hidden; transform: translateX(-10px);
   transition: all 0.3s ease; z-index: 1000;
   display: flex; flex-direction: column; padding: 10px;
}
.nav-dropdown:hover .dropdown-menu { opacity: 1; visibility: visible; transform: translateX(0); }
.nav-dropdown:hover .arrow-icon { transform: rotate(90deg); }

.dropdown-menu a {
   color: #cbd5e1; text-decoration: none; padding: 12px 15px;
   border-radius: 8px; font-size: 0.9rem; font-weight: bold;
   display: flex; align-items: center; gap: 10px; transition: 0.2s;
}
.dropdown-menu a:hover { background: rgba(255,255,255,0.1); color: white; transform: translateX(5px); }

@media (max-width: 768px) {
  .nav-dropdown-mobile { position: relative; display: flex; justify-content: center; }
  .dropdown-menu-mobile {
     position: absolute; bottom: calc(100% + 15px); left: 50%; transform: translateX(-50%) translateY(20px);
     background-color: var(--primary-color); padding: 10px;
     border-radius: 16px; box-shadow: 0 -4px 15px rgba(0,0,0,0.3);
     opacity: 0; visibility: hidden; transition: all 0.3s ease;
     display: flex; flex-direction: column; gap: 5px; width: max-content;
     z-index: 1001;
  }
  .dropdown-menu-mobile.active { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
  
  .dropdown-menu-mobile a {
     color: #cbd5e1; text-decoration: none; padding: 15px 20px;
     border-radius: 8px; font-size: 0.95rem; font-weight: bold;
     display: flex; align-items: center; gap: 12px; transition: 0.2s;
  }
  .dropdown-menu-mobile a:hover { background: rgba(255,255,255,0.1); color: white; }
  
  .dropdown-menu-mobile::after {
     content: ''; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
     border-width: 8px 8px 0; border-style: solid;
     border-color: var(--primary-color) transparent transparent transparent;
  }
}


/* =========================================================
   LEGENDA DE STATUS
   ========================================================= */
.btn-help-status {
    color: #cbd5e1;
    font-size: 0.9rem;
    margin-left: 6px;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}
.btn-help-status:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

.legenda-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
}
.legenda-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.legenda-badge {
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    text-align: center;
    min-width: 150px;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.legenda-desc {
    font-size: 0.9rem;
    color: var(--text-color);
    line-height: 1.5;
}

/* =========================================================
   AVISO TEMPORÁRIO DA LEGENDA (DISCRETO)
   ========================================================= */
.aviso-tooltip {
    position: absolute;
    bottom: 150%; /* Altura fixa logo acima do ícone */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color); /* Azul escuro padrão */
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none; 
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    animation: showAndFade 7s forwards; /* Aparece, fica e some suavemente */
    z-index: 50;
}

/* Setinha apontando para baixo */
.aviso-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--primary-color) transparent transparent transparent;
}

/* Animação: surge suavemente de baixo, fica parado, e some */
@keyframes showAndFade {
    0% { opacity: 0; transform: translate(-50%, 5px); }
    10%, 85% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; visibility: hidden; }
}