/* ── RESET & BASE ──────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: linear-gradient(160deg, #0a0a14 0%, #12002a 100%);
  --surface: rgba(255,255,255,0.04);
  --surface2: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.09);
  --text: #f0f0f5;
  --text2: #9999b0;
  --text3: #666688;
  --sidebar-bg: rgba(10,10,20,0.92);
  --sidebar-w: 260px;
  --purple: #7B00FF;
  --purple-light: #a855f7;
  --purple-glow: rgba(123,0,255,0.15);
  --gold: #C89B3C;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0a0a14;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: relative;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url('/img/bg-b4.png') center/cover no-repeat;
  filter: blur(2px) brightness(0.45);
  transform: scale(1.02);
  z-index: -2;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, rgba(10,10,20,0.55) 0%, rgba(18,0,42,0.50) 100%);
  z-index: -1;
}

/* ── SCROLLBAR ─────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(123,0,255,0.35); border-radius: 99px; }

/* ── LOGIN PAGE ────────────────────────────────────── */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: rgba(10,10,20,0.65);
  border: 1px solid rgba(123,0,255,0.3);
  border-radius: 24px;
  padding: 48px 44px;
  max-width: 440px;
  width: 100%;
  backdrop-filter: blur(24px) saturate(1.2);
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
}
.logo-badge {
  width: 56px;
  height: 56px;
  background: var(--purple);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.logo-text .company { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: 2px; }
.logo-text .tagline { font-size: 11px; color: var(--text2); letter-spacing: 1px; margin-top: 2px; }
.login-card h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-card .subtitle { font-size: 13px; color: var(--text2); margin-bottom: 28px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 6px; }
.form-group input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-glow); }
.form-group input::placeholder { color: rgba(255,255,255,0.25); }
.btn-login {
  width: 100%;
  padding: 14px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.btn-login:hover { background: #6a00e0; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(123,0,255,0.4); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.login-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  padding: 12px 16px;
  color: #f87171;
  font-size: 13px;
  margin-bottom: 18px;
  display: none;
}

/* ── APP LAYOUT ────────────────────────────────────── */
#app-page { display: none; height: 100vh; }
.app-layout { display: flex; height: 100%; }

/* ── SIDEBAR ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  backdrop-filter: blur(20px);
  z-index: 100;
  transition: width 0.25s ease, transform 0.3s ease;
  overflow: hidden;
}
.sidebar.collapsed {
  width: 60px;
}
.sidebar.collapsed .sidebar-header .logo-area > div:first-child { display: flex; justify-content: center; width: 100%; }
.sidebar.collapsed .sidebar-header .logo-area > div:first-child .logo-text { display: none; }
.sidebar.collapsed .sidebar-header .logo-badge { width: 36px; height: 36px; font-size: 14px; border-radius: 8px; }
.sidebar.collapsed .btn-collapse { display: none; }
.sidebar.collapsed .nav-section-title { display: none; }
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 14px 0;
  font-size: 0;
  color: transparent;
  gap: 0;
  overflow: hidden;
  white-space: nowrap;
}
.sidebar.collapsed .nav-item .nav-dot,
.sidebar.collapsed .nav-item .nav-icon {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--text2);
}
.sidebar.collapsed .nav-item .nav-dot {
  width: 12px;
  height: 12px;
}
.sidebar.collapsed .nav-item.active .nav-dot,
.sidebar.collapsed .nav-item.active .nav-icon {
  color: var(--purple-light);
}
.sidebar.collapsed .sidebar-footer { padding: 10px 6px; }
.sidebar.collapsed .user-info { justify-content: center; padding: 6px; }
.sidebar.collapsed .user-info > div:last-child { display: none; }
.sidebar.collapsed .user-avatar { width: 32px; height: 32px; font-size: 13px; }
.sidebar.collapsed .btn-logout {
  font-size: 0;
  padding: 8px;
  justify-content: center;
}
.sidebar.collapsed .btn-logout::before { content: '✕'; font-size: 13px; color: #f87171; }
.btn-collapse {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  font-size: 18px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-collapse:hover { color: var(--text); background: var(--surface2); }
.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header .logo-area { margin-bottom: 0; gap: 12px; }
.sidebar-header .logo-badge { width: 42px; height: 42px; font-size: 16px; border-radius: 10px; }
.sidebar-header .company { font-size: 16px; letter-spacing: 1.5px; }
.sidebar-header .tagline { font-size: 10px; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}
.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 12px 12px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--purple-glow); color: #fff; font-weight: 600; }
.nav-item.active .nav-icon { color: var(--purple-light); }
.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.btn-logout {
  width: 100%;
  padding: 10px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  color: #f87171;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}
.btn-logout:hover { background: rgba(239,68,68,0.15); }

/* ── MAIN CONTENT ──────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-subtitle { font-size: 13px; color: var(--text2); }
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}
.content-area:has(#view-module[style*="block"]),
.content-area:has(#view-estrutura[style*="flex"]) {
  padding: 0;
  overflow: hidden;
}

/* ── DASHBOARD ─────────────────────────────────────── */
#view-dashboard .welcome-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 28px;
  text-align: center;
}
.module-card { width: 200px; padding: 18px; }
.welcome-banner h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.welcome-banner p { color: var(--text2); font-size: 14px; }
.welcome-banner .date { color: var(--gold); font-weight: 600; font-size: 13px; margin-top: 8px; }

.modules-grid {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.module-card:hover {
  border-color: rgba(123,0,255,0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.module-card .card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 16px;
}
.module-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.module-card p { font-size: 13px; color: var(--text2); line-height: 1.5; }
.module-card .card-arrow {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 18px;
  transition: all var(--transition);
}
.module-card:hover .card-arrow { color: var(--purple-light); transform: translateY(-50%) translateX(3px); }

/* ── ESTRUTURA TABS ─────────────────────────────────── */
.estrutura-tabs-bar {
  display: flex;
  gap: 4px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
  justify-content: center;
}
.estrutura-tab {
  padding: 10px 24px;
  border-radius: 8px;
  background: transparent;
  color: var(--text2);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.estrutura-tab:hover {
  background: var(--surface2);
  color: var(--text);
}
.estrutura-tab.active {
  background: var(--surface2);
  color: #fff;
  border-color: var(--tab-color, var(--purple));
  border-bottom: 2px solid var(--tab-color, var(--purple));
}

/* ── MODULE VIEW (IFRAME) ──────────────────────────── */
.module-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg);
}
#view-module { height: 100%; }

/* ── MOBILE ────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}
/* ── THEME ROW ─────────────────────────────────────── */
.theme-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.theme-row .btn-logout { flex: 1; margin-top: 0; }
.btn-theme {
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-theme:hover { background: rgba(255,255,255,0.12); transform: scale(1.05); }
.sidebar.collapsed .theme-row { flex-direction: column; }
.sidebar.collapsed .theme-row .btn-logout { font-size: 0; padding: 8px; }
.sidebar.collapsed .theme-row .btn-theme { padding: 8px; font-size: 14px; }

/* ── LIGHT THEME ───────────────────────────────────── */
body.light {
  --bg: linear-gradient(160deg, #f5f3ff 0%, #ede9fe 100%);
  --surface: rgba(0,0,0,0.03);
  --surface2: rgba(0,0,0,0.06);
  --border: rgba(0,0,0,0.08);
  --text: #1a1a2e;
  --text2: #64648a;
  --text3: #9999b0;
  --sidebar-bg: rgba(255,255,255,0.95);
  --purple-glow: rgba(123,0,255,0.1);
}
body.light .login-card {
  background: rgba(255,255,255,0.85);
  border-color: rgba(123,0,255,0.15);
}
body.light .form-group input {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.12);
  color: #1a1a2e;
}
body.light .form-group input::placeholder { color: rgba(0,0,0,0.3); }
body.light .logo-badge { background: #7B00FF; color: #fff; }
body.light .user-avatar { background: #7B00FF; color: #fff; }
body.light .module-card { background: rgba(255,255,255,0.7); border-color: rgba(0,0,0,0.06); }
body.light .module-card:hover { border-color: rgba(123,0,255,0.2); box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
body.light .topbar { border-bottom-color: rgba(0,0,0,0.06); }
body.light .topbar { border-bottom-color: rgba(0,0,0,0.06); }
body.light .sidebar { border-right-color: rgba(0,0,0,0.06); }
body.light .sidebar-header { border-bottom-color: rgba(0,0,0,0.06); }
body.light .sidebar-footer { border-top-color: rgba(0,0,0,0.06); }
body.light .nav-item:hover { background: rgba(0,0,0,0.04); }
body.light .nav-item.active { background: rgba(123,0,255,0.08); color: #7B00FF; }
body.light .btn-logout { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.15); }
body.light .btn-theme { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.08); }
body.light .estrutura-tabs-bar { background: rgba(255,255,255,0.9); }
body.light .estrutura-tab:hover { background: rgba(0,0,0,0.04); }
body.light .estrutura-tab.active { background: rgba(123,0,255,0.06); color: #7B00FF; }
body.light ::-webkit-scrollbar-thumb { background: rgba(123,0,255,0.2); }
body.light::before { filter: blur(4px) brightness(0.95) saturate(0.3); }
body.light::after { background: linear-gradient(160deg, rgba(245,243,255,0.88) 0%, rgba(237,233,254,0.85) 100%); }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: block; }
  .modules-grid { grid-template-columns: 1fr; }
}


/* ── NOTIF + SOUND BUTTONS ─────────────────────────── */
.btn-icon {
  position: relative;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.12); transform: scale(1.05); }
.btn-icon.muted { opacity: 0.55; }
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 1.5px solid var(--sidebar-bg);
}
.volume-row {
  display: none;
  margin-bottom: 10px;
  padding: 6px 4px 2px;
}
.volume-row.open { display: block; }
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--purple-light);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(168,85,247,0.18);
  transition: transform 0.15s ease;
}
.volume-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--purple-light);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 3px rgba(168,85,247,0.18);
}
.notif-panel {
  display: none;
  position: absolute;
  bottom: 130px;
  left: 16px;
  right: 16px;
  max-height: 320px;
  background: rgba(15,15,28,0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  z-index: 200;
  overflow: hidden;
  flex-direction: column;
}
.notif-panel.open { display: flex; }
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.notif-clear {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.notif-clear:hover { color: var(--purple-light); }
.notif-list {
  overflow-y: auto;
  max-height: 260px;
}
.notif-item {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.notif-item:last-child { border-bottom: none; }
.notif-item strong { font-size: 12px; color: var(--text); font-weight: 600; }
.notif-item span { color: var(--text2); font-size: 11px; }
.notif-item time { color: var(--text3); font-size: 10px; margin-top: 2px; }
.notif-clickable {
  cursor: pointer;
  transition: background var(--transition);
}
.notif-clickable:hover {
  background: var(--purple-glow);
}
.notif-clickable:active {
  background: rgba(123,0,255,0.22);
}
body.light .notif-clickable:hover {
  background: rgba(123,0,255,0.08);
}
.notif-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text3);
  font-size: 12px;
}
.sidebar.collapsed .volume-row { display: none; }
.sidebar.collapsed .notif-panel { display: none !important; }
body.light .btn-icon { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.08); color: var(--text); }
body.light .volume-slider { background: rgba(0,0,0,0.12); }
body.light .notif-panel { background: rgba(255,255,255,0.98); }
body.light .notif-badge { border-color: #fff; }

/* ── LIGHT THEME — FULL PAGE FIX ─────────────────── */
body.light {
  background: #f0eef5;
}
body.light .sidebar {
  background: rgba(255,255,255,0.95);
}
body.light .sidebar-header {
  background: rgba(255,255,255,0.98);
}
body.light .sidebar-footer {
  background: rgba(255,255,255,0.95);
}
body.light .nav-item {
  color: #555;
}
body.light .nav-item .icon { opacity: 0.7; }
body.light .user-name { color: #1a1a2e; }
body.light .user-role { color: #888; }
body.light .topbar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  color: #1a1a2e;
}
body.light .topbar-title { color: #1a1a2e; }
body.light .topbar-subtitle { color: #666; }
body.light .content-area { color: #1a1a2e; }
body.light .welcome-banner {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.06);
  color: #1a1a2e;
}
body.light .welcome-banner h2 { color: #1a1a2e; }
body.light .welcome-banner p { color: #555; }
body.light .module-card h3 { color: #1a1a2e; }
body.light .module-card .card-arrow { color: #888; }
body.light h1, body.light h2, body.light h3 { color: #1a1a2e; }
body.light .desc, body.light .section-desc { color: #666; }
body.light .logo-info .tagline { color: #888; }
body.light .logo-info .name { color: #1a1a2e; }
body.light .btn-collapse { color: #888; }
body.light .btn-collapse:hover { color: #1a1a2e; background: rgba(0,0,0,0.04); }
body.light .sidebar-label { color: #999; }
body.light .notif-panel h4 { color: #1a1a2e; }
body.light .notif-panel .notif-item { color: #333; border-bottom-color: rgba(0,0,0,0.06); }
body.light .notif-panel .notif-time { color: #999; }
body.light .notif-panel .notif-empty { color: #999; }
