/* --- VARIÁVEIS E CORES (NEON RESTAURADO) --- */
:root {
    --primary: #0affd1;
    --secondary: #8e2de2;
    --bg-main: #0a0b0e;
    --bg-sidebar: #111319;
    --bg-surface: #1a1d26;
    --bg-input: #0f1116;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --status-open: #ff3366;
    --status-sent: #00c6ff;
    --status-resolved: #00f260;
    --status-responded: #f0932b;
    --shadow-surface: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }
body { background-color: var(--bg-main); color: var(--text-main); height: 100vh; overflow: hidden; -webkit-font-smoothing: antialiased; }

/* UTILS */
.hidden { display: none !important; }
.mobile-only { display: none; }

/* TOAST NOTIFICATIONS */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--bg-surface); color: #fff; padding: 15px 25px; border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5); display: flex; align-items: center; gap: 10px;
    border-left: 4px solid var(--primary); animation: slideIn 0.3s ease-out; min-width: 300px;
}
.toast.error { border-left-color: var(--status-open); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* BOTÕES GERAIS */
.btn-gradient {
    background: linear-gradient(135deg, var(--secondary), var(--primary)); color: #000; font-weight: 700; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; transition: 0.3s;
}
.btn-gradient:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(10, 255, 209, 0.3); }
.btn-cancel { background: transparent; border: 2px solid #333; color: var(--text-muted); padding: 12px 24px; border-radius: 8px; cursor: pointer; transition: 0.3s; }
.btn-cancel:hover { border-color: #fff; color: #fff; }

/* LAYOUT */
#app-screen { display: flex; height: 100vh; transition: 0.3s; }
.sidebar { width: 260px; background: var(--bg-sidebar); display: flex; flex-direction: column; border-right: 1px solid rgba(255,255,255,0.03); transition: all 0.3s ease; }
.sidebar.closed { width: 0; overflow: hidden; border: none; }

.brand { padding: 30px; font-size: 1.6rem; font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.brand .dot { color: var(--primary); }
.menu { list-style: none; margin-top: 20px; padding: 0 15px; }
.menu li { padding: 15px 20px; cursor: pointer; color: var(--text-muted); transition: 0.3s; border-radius: 10px; margin-bottom: 5px; display: flex; align-items: center; white-space: nowrap; }
.menu li i { margin-right: 15px; width: 20px; text-align: center; font-size: 1.1rem; }
.menu li:hover, .menu li.active { background: rgba(255,255,255,0.05); color: var(--primary); }

.content { flex: 1; padding: 40px; overflow-y: auto; background: var(--bg-main); transition: 0.3s; }

/* HEADER */
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; }
.header-left { display: flex; align-items: center; gap: 20px; }
#sidebar-toggle { background: none; border: none; color: var(--text-main); font-size: 1.5rem; cursor: pointer; }
#page-title { font-size: 1.8rem; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 15px; }
#refresh-btn { background: var(--bg-surface); border: 1px solid rgba(255,255,255,0.1); color: var(--text-muted); width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; transition: 0.3s; }
#refresh-btn:hover { color: var(--primary); border-color: var(--primary); transform: rotate(180deg); }
.user-profile { background: var(--bg-surface); padding: 5px 15px; border-radius: 30px; border: 1px solid rgba(255,255,255,0.05); display: flex; align-items: center; gap: 10px; cursor: pointer; }
.user-info { text-align: right; }
#user-display { font-weight: 700; font-size: 0.9rem; display: block; }
#user-role-display { font-size: 0.7rem; color: var(--text-muted); display: block; margin-top: -2px; font-weight: 600; text-align: right; }
.avatar { width: 35px; height: 35px; background: var(--primary); color: #000; border-radius: 50%; display: flex; justify-content: center; align-items: center; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* DASHBOARD */
.kpi-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 40px; }
.kpi-card { background: var(--bg-surface); padding: 25px; border-radius: 15px; display: flex; align-items: center; border: 1px solid rgba(255,255,255,0.03); box-shadow: var(--shadow-surface); position: relative; overflow: hidden; cursor: pointer; }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 3px; }
.kpi-card.open::before { background: var(--status-open); } .kpi-card.sent::before { background: var(--status-sent); } .kpi-card.resolved::before { background: var(--status-resolved); }
.kpi-icon { font-size: 2.2rem; margin-right: 20px; opacity: 0.9; }
.kpi-card.open .kpi-icon { color: var(--status-open); } .kpi-card.sent .kpi-icon { color: var(--status-sent); } .kpi-card.resolved .kpi-icon { color: var(--status-resolved); }
.kpi-info h3 { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.kpi-info span { font-size: 2rem; font-weight: 700; }

/* TABLE (CORRIGIDA) */
.table-container { background: var(--bg-surface); border-radius: 15px; padding: 25px; box-shadow: var(--shadow-surface); overflow-x: auto; min-height: 400px; }
.table-header { display: flex; justify-content: space-between; margin-bottom: 20px; align-items: center; }
#search-input { background: var(--bg-input); border: 1px solid rgba(255,255,255,0.1); padding: 10px 15px; border-radius: 8px; color: #fff; width: 300px; }

/* Correção de largura mínima para não espremer os botões */
table { width: 100%; border-collapse: collapse; min-width: 1100px; }
th, td { padding: 15px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.05); white-space: nowrap; vertical-align: middle; }
th { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; font-weight: 700; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

/* BADGES */
.badge { padding: 5px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge.aberto { background: rgba(255, 51, 102, 0.15); color: var(--status-open); }
.badge.email-enviado { background: rgba(0, 198, 255, 0.15); color: var(--status-sent); }
.badge.resolvida { background: rgba(0, 242, 96, 0.15); color: var(--status-resolved); }
.badge.email-respondido { background: rgba(240, 147, 43, 0.15); color: var(--status-responded); }

/* AÇÕES (CORRIGIDO ALINHAMENTO) */
.action-cell { 
    display: flex; 
    gap: 8px; 
    justify-content: flex-start; /* Alinha à esquerda ou use center */
    align-items: center;
}
.icon-btn { 
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: var(--text-muted); 
    width: 32px; height: 32px; border-radius: 6px; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; transition: 0.2s; 
}
.icon-btn:hover { color: #fff; transform: translateY(-2px); }
.btn-details:hover { background: var(--primary); color: #000; border-color: var(--primary); }
.btn-next:hover { background: var(--status-sent); border-color: var(--status-sent); }
.btn-email:hover { background: #fff; color: #000; border-color: #fff; }
.btn-undo:hover { background: var(--status-responded); border-color: var(--status-responded); }
.btn-delete:hover { background: var(--status-open); border-color: var(--status-open); }

/* FORMS */
.form-container, .admin-grid { background: var(--bg-surface); padding: 30px; border-radius: 15px; max-width: 1000px; margin: 0 auto; box-shadow: var(--shadow-surface); }
.form-grid, .admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
label { display: block; color: var(--text-muted); font-size: 0.8rem; margin-bottom: 5px; }
input, select, textarea { width: 100%; background: var(--bg-input); border: 1px solid rgba(255,255,255,0.1); color: #fff; padding: 12px; border-radius: 8px; outline: none; transition: 0.3s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.card-admin { background: #252830; padding: 20px; border-radius: 8px; }

/* MODAIS */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 1000; display: flex; justify-content: center; align-items: center; }
.modal-content { background: var(--bg-surface); padding: 30px; border-radius: 10px; width: 600px; max-width: 95%; max-height: 90vh; overflow-y: auto; border: 1px solid var(--primary); position: relative; }
.close-modal { position: absolute; top: 15px; right: 20px; font-size: 24px; cursor: pointer; color: #fff; }
.profile-header { display: flex; flex-direction: column; align-items: center; margin-bottom: 20px; }
.profile-pic-wrapper { width: 100px; height: 100px; border-radius: 50%; border: 2px solid var(--primary); display: flex; justify-content: center; align-items: center; overflow: hidden; margin-bottom: 10px; position: relative; }
.profile-pic-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.profile-pic-wrapper i { font-size: 3rem; color: #fff; }

/* RESPONSIVIDADE */
@media (max-width: 768px) {
    .mobile-only { display: block; }
    .mobile-hide { display: none !important; }
    .sidebar { position: fixed; left: -100%; top: 0; height: 100%; width: 80%; z-index: 1000; box-shadow: 10px 0 30px rgba(0,0,0,0.5); }
    .sidebar.active { left: 0; }
    .content { padding: 15px; }
    .header-actions #refresh-btn { display: none; }
    #page-title { font-size: 1.2rem; }
    .kpi-container { grid-template-columns: 1fr; gap: 15px; }
    .form-grid, .admin-grid { grid-template-columns: 1fr; }
    .table-header { flex-direction: column; align-items: stretch; gap: 10px; }
    #search-input { width: 100%; }
    #close-sidebar-mobile { background: none; border: none; color: #fff; font-size: 1.5rem; }
}

/* LOGIN SCREEN & LOADING */
#login-screen { height: 100vh; display: flex; justify-content: center; align-items: center; background: url('https://images.unsplash.com/photo-1519501025264-65ba15a82390?q=80&w=1964&auto=format&fit=crop') no-repeat center center/cover; }
.login-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); }
.login-box { position: relative; z-index: 2; background: rgba(30,30,30,0.9); padding: 3rem 2rem; border-radius: 15px; width: 90%; max-width: 400px; text-align: center; border: 1px solid rgba(255,255,255,0.05); }
.neon-text { color: var(--primary); text-shadow: 0 0 10px var(--primary); font-weight: 700; }
.input-group { background: var(--bg-input); margin: 15px 0; padding: 12px; border-radius: 8px; display: flex; align-items: center; }
.input-group input { border: none; margin: 0; padding: 0 0 0 10px; }

#loading { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 999; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.spinner { border: 4px solid rgba(255,255,255,0.1); border-top: 4px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* PRINT */
@media print {
    body * { visibility: hidden; }
    #modal-details, #modal-details * { visibility: visible; }
    #modal-details { position: absolute; left: 0; top: 0; width: 100%; background: white !important; color: black !important; border: none; }
    .close-modal, .btn-gradient, button { display: none !important; }
}
