/**
 * SafariPulse HR — Premium UI components
 */

/* ── Shell layout ─────────────────────────────────────────── */
.app-shell {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.app-sidebar.is-collapsed {
  width: var(--sidebar-collapsed);
}

.app-sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.15rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: auto;
  text-decoration: none;
  color: inherit;
  text-align: center;
}

.app-sidebar-brand-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.app-sidebar-brand img {
  width: 132px;
  max-width: 88%;
  height: auto;
  max-height: 112px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.app-sidebar-brand-text {
  font-weight: 700;
  font-size: 9px;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(241, 245, 249, 0.95);
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  max-width: 100%;
}

.app-sidebar.is-collapsed .app-sidebar-brand {
  padding: 0.85rem 0.35rem;
}

.app-sidebar.is-collapsed .app-sidebar-brand img {
  width: 44px;
  max-height: 44px;
}

.app-sidebar.is-collapsed .app-sidebar-brand-text,
.app-sidebar.is-collapsed .nav-section-title,
.app-sidebar.is-collapsed .nav-link-text,
.app-sidebar.is-collapsed .nav-chevron {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.app-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.5rem 1.5rem;
  scrollbar-width: thin;
}

.nav-section { margin-bottom: 0.35rem; }

.nav-section-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: rgba(241, 245, 249, 0.75);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nav-chevron {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform var(--transition-fast);
}

.nav-section.is-open .nav-chevron { transform: rotate(180deg); }

.nav-section-items { display: none; padding: 0.15rem 0 0.35rem; }
.nav-section.is-open .nav-section-items { display: block; }

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.58rem 0.75rem;
  margin: 0.1rem 0;
  border-radius: var(--radius-sm);
  color: rgba(241, 245, 249, 0.88);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.nav-link-item i {
  font-size: 1.05rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.nav-link-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.nav-link-item.active {
  background: rgba(var(--brand-primary-rgb), 0.35);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brand-primary);
}

.app-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-base);
}

body.sidebar-collapsed .app-main-wrapper,
.app-sidebar.is-collapsed ~ .app-main-wrapper {
  margin-left: var(--sidebar-collapsed);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--bg-topbar);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
}

.app-topbar-toggle {
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.app-topbar-search { flex: 1; max-width: 420px; position: relative; }

.app-topbar-search .form-control {
  padding-left: 2.35rem;
  border-radius: 999px;
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.app-topbar-search .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

[data-theme="light"] .theme-toggle-btn .icon-moon { display: inline; }
[data-theme="light"] .theme-toggle-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-sun { display: inline; }

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.6rem 0.35rem 0.35rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  text-decoration: none;
  max-width: 200px;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.app-content { flex: 1; padding: 1.5rem 1.25rem 2rem; width: 100%; }

.page-title {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
  color: var(--text-primary);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-primary);
}

.kpi-card {
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  height: 100%;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-accent, var(--brand-primary));
}

.kpi-card .kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); }
.kpi-card .kpi-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.35rem; }

.kpi-card-primary { --kpi-accent: var(--brand-primary); }
.kpi-card-success { --kpi-accent: var(--success); }
.kpi-card-warning { --kpi-accent: var(--warning); }
.kpi-card-info { --kpi-accent: var(--info); }
.kpi-card-violet { --kpi-accent: var(--brand-accent); }
.kpi-card-teal { --kpi-accent: var(--brand-secondary); }
.kpi-card-danger { --kpi-accent: var(--danger); }

.form-control, .form-select {
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.18);
}

.wizard-steps { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.wizard-step {
  flex: 1; min-width: 120px; text-align: center; padding: 0.65rem;
  border-radius: var(--radius-md); border: 1px solid var(--border-color);
  background: var(--bg-subtle); font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
}
.wizard-step.active {
  background: rgba(var(--brand-primary-rgb), 0.12);
  border-color: var(--brand-primary); color: var(--brand-primary);
}
.wizard-step.done { background: rgba(16,185,129,0.1); border-color: var(--success); color: var(--success); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border: none; font-weight: 600;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  --bs-table-border-color: var(--border-color);
  --bs-table-striped-bg: var(--bg-subtle);
  --bs-table-hover-bg: var(--bg-hover);
}

table.dataTable thead th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.dropdown-menu {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.dropdown-item { color: var(--text-primary); }
.dropdown-item:hover { background: var(--bg-hover); }

.global-search-dropdown {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1050;
  max-height: 320px;
  overflow-y: auto;
}

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }

.toast-container-premium {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(380px, calc(100vw - 32px));
}

.toast-premium {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 1rem;
}

.toast-premium.is-success { border-left-color: var(--success); }
.toast-premium.is-error { border-left-color: var(--danger); }

.spinner-premium {
  width: 1.25rem; height: 1.25rem;
  border: 2px solid var(--border-color);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-kpi { height: 88px; border-radius: var(--radius-lg); background: var(--bg-subtle); }

body.login-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(var(--brand-primary-rgb), 0.14), transparent 55%),
    var(--bg-body);
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  flex: 0 0 auto;
}

.login-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  background: var(--bg-card);
  overflow: hidden;
}

.login-header {
  text-align: center;
  padding: 0;
  background: #0b1220;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.login-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 108px;
  max-height: 108px;
  padding: 1.25rem 1.5rem 0.75rem;
  overflow: hidden;
}

.login-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 72px;
  margin: 0 auto;
  object-fit: contain;
}

.login-header-tagline {
  margin: 0;
  padding: 0 1.5rem 1.1rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.62);
}

.login-card .card-body {
  padding: 1.5rem 1.5rem 1.75rem;
}

.login-card .card-body h5 {
  color: var(--text-primary);
}

.login-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-header-fallback {
  display: block;
  font-weight: 700;
  font-size: 1.25rem;
  color: #ffffff;
}

@media (max-width: 575.98px) {
  body.login-page.app-shell {
    padding: 1rem 0.75rem 1.5rem;
  }

  .login-wrap {
    max-width: 100%;
  }

  .login-logo-wrap {
    min-height: 92px;
    max-height: 92px;
    padding: 1rem 1rem 0.5rem;
  }

  .login-logo {
    max-height: 60px;
  }

  .login-card .card-body {
    padding: 1.25rem 1.15rem 1.5rem;
  }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1035;
}

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.is-mobile-open { transform: translateX(0); }
  .app-main-wrapper { margin-left: 0 !important; }
  body.sidebar-mobile-open .sidebar-backdrop { display: block; }
}

[data-theme="dark"] .list-group-item { background: var(--bg-card); border-color: var(--border-color); color: var(--text-primary); }
[data-theme="dark"] .modal-content { background: var(--bg-elevated); border-color: var(--border-color); color: var(--text-primary); }

/* Never use hardcoded white surfaces in dark mode — always theme tokens */
[data-theme="dark"] .lb-summary-card,
[data-theme="dark"] .lv-summary-card,
[data-theme="dark"] .wp-guide-card,
[data-theme="dark"] .sr-guide-card,
[data-theme="dark"] .lr-guide-card,
[data-theme="dark"] .ar-guide-card,
[data-theme="dark"] .hr-guide-card,
[data-theme="dark"] .lb-calc-guide,
[data-theme="dark"] .wp-mobile-card,
[data-theme="dark"] .sr-mobile-card,
[data-theme="dark"] .lr-mobile-card,
[data-theme="dark"] .ar-mobile-card {
  background: var(--bg-card);
  color: var(--text-primary);
}

[data-theme="dark"] .lb-summary-value,
[data-theme="dark"] .lv-summary-value {
  color: var(--text-primary);
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--border-color); }
[data-theme="dark"] .btn-close { filter: invert(1); }

[data-theme="dark"] .notification-dropdown-list .dropdown-item.bg-light,
[data-theme="dark"] .notification-dropdown-list .dropdown-item.notif-unread {
  background: var(--bg-hover) !important;
  color: var(--text-primary);
}
