@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&display=swap');

:root {
  --sidebar-width: 256px;

  /* SLAP Brand Colors */
  --slap-yellow:  #F1D24B;
  --slap-orange:  #FF5C3D;
  --slap-blue:    #84C7DF;
  --slap-purple:  #8671D1;
  --slap-black:   #000000;

  /* SLAP Light Tints */
  --slap-yellow-lt: #F0E8BE;
  --slap-orange-lt: #FFD3CA;
  --slap-blue-lt:   #C2DCE6;
  --slap-purple-lt: #C9C1E6;
  --slap-gray-lt:   #F5F5F5;

  /* Sidebar (dark) */
  --brand-dark:  #111110;
  --brand-dark2: #1c1c1a;
  --brand-text:  #f0efec;
  --brand-muted: #8a8880;

  /* Accent (yellow → black text) */
  --brand-accent:        var(--slap-yellow);
  --brand-active-bg:     rgba(241,210,75,0.14);
  --brand-active-border: var(--slap-yellow);
  --brand-active-color:  #c8a800;

  /* Content area */
  --content-bg: #F5F5F5;
  --card-bg:    #ffffff;
  --radius:     10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
  background: var(--content-bg);
  color: #111110;
}

/* ─── Page Loader ─────────────────────────────────── */
#page-loader {
  position: fixed;
  inset: 0;
  /* z-index BELOW the sidebar (z-index:100) so sidebar stays visible on top */
  z-index: 90;
  background: #F5F5F5;
  /* offset left so loader only covers the content area, not the sidebar */
  left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease;
}
#page-loader.hiding {
  opacity: 0;
  pointer-events: none;
}
#page-loader .pl-logo {
  height: 28px;
  opacity: 0.55;
  animation: pl-fadein .5s ease both;
}
#page-loader .pl-bar-wrap {
  width: 110px;
  height: 2px;
  background: #e7e5e4;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 22px;
}
#page-loader .pl-bar {
  height: 100%;
  background: var(--slap-yellow);
  border-radius: 999px;
  width: 8%;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes pl-fadein {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 0.55; transform: translateY(0); }
}

/* ─── Sidebar skeleton (shown while initNav() loads) ─ */
#sidebar .sk-bar {
  height: 12px;
  background: #2a2a27;
  border-radius: 4px;
  animation: sk-pulse 1.4s ease-in-out infinite alternate;
}
@keyframes sk-pulse { from { opacity: 0.4; } to { opacity: 0.9; } }

/* ─── Layout ─────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--brand-dark);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: #333330 transparent;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid #2a2a27;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-logo img {
  height: 26px;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.sidebar-user {
  padding: 12px 16px;
  border-bottom: 1px solid #1e1e1c;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--slap-yellow);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #111110;
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  transition: opacity 0.15s;
}
.sidebar-user-avatar:hover { opacity: 0.85; }

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10px;
  color: #9b9892;
  margin-top: 1px;
}

/* ─── Nav ─────────────────────────────────────── */
.nav-section { padding: 8px 0; flex: 1; }

.nav-group-label {
  padding: 8px 16px 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #504e48;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13px;
  color: #c4c1bb;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover {
  color: var(--brand-text);
  background: rgba(255,255,255,0.04);
}

.nav-item.active {
  color: var(--slap-yellow);
  background: var(--brand-active-bg);
  border-left-color: var(--slap-yellow);
  font-weight: 600;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-item .nav-arrow {
  margin-left: auto;
  width: 12px; height: 12px;
  transition: transform 0.2s;
}

.nav-item.expanded .nav-arrow { transform: rotate(90deg); }

.nav-children {
  display: none;
  background: rgba(0,0,0,0.18);
}

.nav-children.open { display: block; }

.nav-child-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 7px 40px;
  font-size: 12px;
  color: #b0ada6;
  text-decoration: none;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}

.nav-child-item:hover {
  color: var(--brand-text);
  background: rgba(255,255,255,0.04);
}

.nav-child-item.active {
  color: var(--slap-yellow);
  background: var(--brand-active-bg);
  border-left-color: var(--slap-yellow);
  font-weight: 600;
}

.nav-child-item::before {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-child-item.active::before { opacity: 1; }

/* ─── Logout ─────────────────────────────────── */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #1e1e1c;
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  color: #6b6863;
  cursor: pointer;
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.15s;
}
.logout-btn:hover {
  color: var(--slap-orange);
  border-color: rgba(255,93,61,0.3);
  background: rgba(255,93,61,0.06);
}
.logout-btn svg { width: 14px; height: 14px; }

/* ─── Main Content ─────────────────────────────── */
#content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  opacity: 0;
}
#content.content-ready {
  opacity: 1;
  transition: opacity 0.22s ease;
}

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: #111110;
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 13px;
  color: #78716c;
  margin-top: 4px;
}

/* ─── Cards ──────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid #e7e5e2;
  padding: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid #e7e5e2;
  padding: 20px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #78716c;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: #111110;
}

/* ─── Placeholder ────────────────────────────── */
.placeholder-box {
  border: 2px dashed #d6d3d1;
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  color: #a8a29e;
}

.placeholder-box h3 {
  font-size: 16px;
  font-weight: 600;
  color: #78716c;
  margin-bottom: 8px;
}

.placeholder-box p {
  font-size: 13px;
  line-height: 1.6;
}

/* ─── Login Page ─────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  background: #111110;
  position: relative;
  overflow-y: auto;
}

/* Decorative background blobs */
.login-wrapper::before {
  content: '';
  position: absolute;
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(241,210,75,0.18) 0%, transparent 70%);
  top: -120px; left: -120px;
  pointer-events: none;
}

.login-wrapper::after {
  content: '';
  position: absolute;
  width: 360px; height: 360px;
  background: radial-gradient(circle, rgba(134,113,209,0.14) 0%, transparent 70%);
  bottom: -80px; right: -80px;
  pointer-events: none;
}

.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 0;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
  overflow: hidden;
  position: relative;
  z-index: 1;
  margin: auto;
}

.login-card--form {
  height: 530px;
}

.login-card-top {
  background: var(--slap-yellow);
  padding: 28px 36px 24px;
  flex-shrink: 0;
}

.login-card-body {
  padding: 28px 36px 36px;
  flex: 1;
  overflow-y: auto;
}

.login-logo {
  height: 30px;
  display: block;
}

.login-title {
  font-size: 20px;
  font-weight: 800;
  color: #111110;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.login-subtitle {
  font-size: 13px;
  color: #78716c;
  margin-bottom: 24px;
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #57534e;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e2e0dd;
  border-radius: 8px;
  font-size: 14px;
  color: #111110;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fafaf9;
}

.form-input:focus {
  border-color: var(--slap-yellow);
  box-shadow: 0 0 0 3px rgba(241,210,75,0.25);
  background: #fff;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: #111110;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.2px;
}

.login-btn:hover { background: #2a2a27; }
.login-btn:active { transform: scale(0.99); }
.login-btn:disabled { background: #a8a29e; cursor: not-allowed; }

.login-error {
  font-size: 12px;
  color: var(--slap-orange);
  margin-top: 10px;
  text-align: center;
  min-height: 18px;
  font-weight: 600;
}

/* ─── Buttons ────────────────────────────────── */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--slap-yellow); color: #111110;
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.primary-btn:hover { background: #e8c832; }
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { background: #e7e5e2; color: #a8a29e; cursor: not-allowed; }

.secondary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  background: white; color: #57534e;
  border: 1.5px solid #e2e0dd; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.secondary-btn:hover { border-color: #a8a29e; color: #111110; }
.secondary-btn.active {
  background: var(--slap-yellow); color: #111110;
  border-color: var(--slap-yellow); font-weight: 700;
}

.danger-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  background: var(--slap-orange); color: white;
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background 0.15s;
}
.danger-btn:hover { background: #e04d30; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px; background: none;
  border: 1.5px solid #e2e0dd; border-radius: 6px;
  color: #78716c; cursor: pointer; transition: all 0.15s;
}
.icon-btn:hover { border-color: #a8a29e; color: #111110; background: #f5f5f5; }
.icon-btn svg { width: 14px; height: 14px; }

.filter-btn { padding: 6px 12px; font-size: 12px; }

/* ─── Modal ──────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.visible { display: flex; }

.modal-content {
  background: white;
  border-radius: 14px;
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e7e5e2;
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-header h4 { font-size: 16px; font-weight: 800; color: #111110; }
.modal-close-btn {
  background: none; border: none; font-size: 20px;
  color: #a8a29e; cursor: pointer; line-height: 1;
  padding: 0 4px;
}
.modal-close-btn:hover { color: #111110; }

.modal-body { padding: 20px 24px 24px; }

/* ─── Setor badges ───────────────────────────── */
.setor-badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px; font-size: 10px; font-weight: 700;
}
.setor-comercial      { background: var(--slap-orange-lt); color: #b83820; }
.setor-pedagogico     { background: var(--slap-blue-lt);   color: #1a6a8a; }
.setor-administrativo { background: var(--slap-purple-lt); color: #4e35aa; }
.setor-direcao        { background: var(--slap-yellow-lt); color: #7a6000; }
.setor-professor      { background: #dcfce7;               color: #166534; }
.setor-supervisao     { background: #fce7f3;               color: #9d174d; }
.setor-indefinido     { background: #f5f5f5;               color: #78716c; }

/* ─── Form elements ──────────────────────────── */
.form-select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid #e2e0dd; border-radius: 8px;
  font-size: 13px; color: #111110;
  background: #fafaf9; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-select:focus {
  border-color: var(--slap-yellow);
  box-shadow: 0 0 0 3px rgba(241,210,75,0.25);
  background: #fff;
}

textarea.form-input { resize: vertical; min-height: 80px; }

/* ─── Empty state ────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px; color: #a8a29e;
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; color: #d6d3d1; }
.empty-state p { font-size: 14px; }

/* ─── Search bar ─────────────────────────────── */
.search-bar {
  position: relative;
}
.search-bar input {
  padding-left: 36px;
}
.search-bar svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: #a8a29e; pointer-events: none;
}

/* ─── Step block ─────────────────────────────── */
.step-block {
  border: 1.5px solid #e7e5e2; border-radius: 8px; padding: 16px;
}

/* ─── Toast animation ────────────────────────── */
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Link card ──────────────────────────────── */
.link-card {
  background: white;
  border: 1.5px solid #e7e5e2; border-radius: 10px;
  padding: 16px; position: relative;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.link-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  border-color: var(--slap-yellow);
}

/* ─── Processo card ──────────────────────────── */
.processo-card {
  background: white; border: 1.5px solid #e7e5e2; border-radius: 10px;
  padding: 16px; cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.processo-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  border-color: var(--slap-yellow);
}

/* ─── Mobile ─────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  #sidebar.open { transform: translateX(0); }
  #content { margin-left: 0; padding: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
