/* ─── Variables (RAY brand from logo) ─── */
:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a0a24;
  --sidebar-hover: #2d1440;
  --brand-primary: #961ccb;
  --brand-primary-dark: #6a0dad;
  --brand-primary-hover: #7b17b5;
  --brand-primary-rgb: 150, 28, 203;
  --brand-accent: #ff9900;
  --brand-accent-rgb: 255, 153, 0;
  --brand-gradient-dark: #1a0a24;
  --brand-gradient-mid: #5b1a8c;
  --sidebar-active: var(--brand-primary);
  --topbar-height: 56px;
  --body-bg: #f1f5f9;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08);
  --bs-primary: var(--brand-primary);
  --bs-primary-rgb: var(--brand-primary-rgb);
  --bs-link-color: var(--brand-primary);
  --bs-link-hover-color: var(--brand-primary-hover);
}

[data-bs-theme="dark"] {
  --body-bg: #0f172a;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
}

/* ─── Global ─── */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
}

/* ─── Login Page ─── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand-gradient-dark) 0%, var(--brand-gradient-mid) 55%, var(--brand-primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

[data-bs-theme="dark"] .login-card {
  background: #1e293b;
}

.brand-logo {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.login-brand-logo {
  max-width: 240px;
  margin: 0 auto;
}

.sidebar-brand-logo {
  max-width: 148px;
}

.login-brand-icon {
  width: auto;
  height: auto;
  background: transparent;
  border-radius: 0;
  display: block;
  font-size: inherit;
  color: inherit;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
  pointer-events: none;
}

/* Edge arrow — collapse / expand */
.sidebar-edge-toggle {
  position: fixed;
  left: calc(var(--sidebar-width) - 14px);
  top: 72px;
  z-index: 1055;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.14);
  transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  padding: 0;
  line-height: 1;
}

.sidebar-edge-toggle:hover {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  transform: scale(1.05);
}

.sidebar-edge-toggle i {
  font-size: 0.95rem;
  transition: transform 0.2s ease;
}

body.sidebar-collapsed .sidebar-edge-toggle {
  left: 10px;
}

[data-bs-theme="dark"] .sidebar-edge-toggle {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1035;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.brand-icon {
  width: auto;
  height: auto;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: inherit;
  color: inherit;
}

.sidebar-divider {
  border-color: rgba(255,255,255,0.15);
}

.sidebar-section-title {
  padding: 1.2rem 1rem 0.4rem 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  list-style: none;
}

/* Accordion / dropdown menu groups */
.sidebar-group {
  margin-bottom: 2px;
}

.sidebar-group-toggle {
  width: 100%;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  color: rgba(255,255,255,0.78) !important;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.65rem 0.85rem !important;
  margin-bottom: 2px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-group-toggle:hover {
  color: #fff !important;
  background: var(--sidebar-hover);
}

.sidebar-group-toggle:not(.collapsed) {
  color: #fff !important;
  background: rgba(255,255,255,0.08);
}

.sidebar-group-label {
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.sidebar-chevron {
  font-size: 0.7rem;
  opacity: 0.65;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.sidebar-group-toggle:not(.collapsed) .sidebar-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

.sidebar-submenu {
  padding: 0.15rem 0 0.35rem 0.35rem;
  margin: 0 0 0.25rem 0.55rem;
  border-left: 1px solid rgba(255,255,255,0.12);
}

.sidebar-submenu .sidebar-link {
  padding: 0.45rem 0.75rem !important;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  margin-left: 0.35rem;
}

.sidebar-submenu .sidebar-link i {
  font-size: 0.9rem;
  opacity: 0.85;
}

.sidebar-link {
  color: rgba(255,255,255,0.65) !important;
  border-radius: 8px;
  padding: 0.6rem 1rem !important;
  margin-bottom: 2px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex !important;
  align-items: center;
}

.sidebar-link:hover {
  color: #fff !important;
  background: var(--sidebar-hover);
}

.sidebar-link.active {
  color: #fff !important;
  background: var(--sidebar-active);
  box-shadow: 0 2px 8px rgba(79,70,229,0.4);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ─── Page Content ─── */
.page-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-content.expanded,
body.sidebar-collapsed .page-content {
  margin-left: 0;
  width: 100%;
}

#sidebarToggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155 !important;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

#sidebarToggle:hover {
  background: #f1f5f9;
  color: var(--brand-primary) !important;
}

[data-bs-theme="dark"] #sidebarToggle {
  color: #e2e8f0 !important;
}

[data-bs-theme="dark"] #sidebarToggle:hover {
  background: #334155;
}

/* ─── Top Navbar ─── */
.top-navbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

[data-bs-theme="dark"] .top-navbar {
  background: #1e293b;
  border-color: #334155;
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
}

/* ─── Avatars ─── */
.avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  flex-shrink: 0;
}

/* ─── Stat Cards ─── */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #e2e8f0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

[data-bs-theme="dark"] .stat-card {
  background: #1e293b;
  border-color: #334155;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: #1e293b;
}

[data-bs-theme="dark"] .stat-value {
  color: #f1f5f9;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

/* ─── Activity ─── */
.activity-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-item:last-child {
  border-bottom: none !important;
}

/* ─── Hover Background ─── */
.hover-bg {
  transition: background 0.15s ease;
}

.hover-bg:hover {
  background: #f8fafc;
}

[data-bs-theme="dark"] .hover-bg:hover {
  background: #334155;
}

/* ─── Cards ─── */
.card {
  border-radius: 12px;
}

[data-bs-theme="dark"] .card {
  background: #1e293b;
  border-color: #334155;
}

/* ─── Tables ─── */
.table > thead {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.table > tbody > tr {
  transition: background 0.15s ease;
}

/* ─── Forms ─── */
.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--brand-primary-rgb), 0.15);
}

/* ─── Badges ─── */
.badge {
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.35em 0.65em;
  border-radius: 6px;
}

/* ─── Buttons ─── */
.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-primary:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

/* ─── Real-time notification toast ─── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
}

/* ─── Scrollbar ─── */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}

/* ─── Responsive ─── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    pointer-events: none;
  }
  .sidebar.show {
    transform: translateX(0);
    pointer-events: auto;
  }
  .sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    pointer-events: none;
  }
  .page-content,
  .page-content.expanded,
  body.sidebar-collapsed .page-content {
    margin-left: 0;
    width: 100%;
  }
  .sidebar-edge-toggle {
    display: none;
  }
}

/* ─── Signup Page ─── */
.signup-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand-gradient-dark) 0%, var(--brand-gradient-mid) 55%, var(--brand-primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}

.signup-wrapper {
  width: 100%;
  max-width: 680px;
  padding: 1rem;
}

.signup-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

[data-bs-theme="dark"] .signup-card {
  background: #1e293b;
}

/* Signup Steps */
.signup-steps {
  position: relative;
}

.signup-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: 0 2px;
}

.signup-step small {
  font-size: 0.65rem;
  line-height: 1.2;
  text-align: center;
  max-width: 6.5rem;
  color: #64748b;
}

.signup-step.active small,
.signup-step.completed small {
  color: #0f172a;
  font-weight: 600;
}

@media (min-width: 576px) {
  .signup-step small {
    font-size: 0.72rem;
    max-width: 8rem;
  }
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #64748b;
  transition: all 0.3s ease;
  margin-bottom: 4px;
}

.signup-step.active .step-circle {
  background: var(--brand-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(var(--brand-primary-rgb), 0.4);
}

.signup-step.completed .step-circle {
  background: #059669;
  color: #fff;
}

.step-progress-bar {
  position: absolute;
  top: 18px;
  left: 12%;
  right: 12%;
  height: 3px;
  background: #e2e8f0;
  z-index: 1;
  border-radius: 3px;
}

.step-progress-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

/* Form Steps */
.form-step {
  display: none;
}

.form-step.active {
  display: block;
  animation: fadeInUp 0.3s ease;
}

/* Role Cards */
.role-card:checked + label,
.tier-card:checked + label {
  border-color: var(--brand-primary) !important;
  background: rgba(var(--brand-primary-rgb), 0.05) !important;
  box-shadow: 0 0 0 2px rgba(var(--brand-primary-rgb), 0.3);
}

/* Pending Page */
.pending-icon {
  display: inline-block;
}

.spinner-ring {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

.status-badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* Sidebar badge */
.sidebar-link .badge {
  font-size: 0.65rem;
  padding: 0.25em 0.5em;
}

.sidebar-link {
  display: flex;
  align-items: center;
}

/* ─── Animations ─── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card,
.card {
  animation: fadeInUp 0.4s ease;
}

/* ─── Footer ─── */
footer {
  flex-shrink: 0;
}

[data-bs-theme="dark"] footer {
  background: #1e293b !important;
  border-color: #334155 !important;
}

[data-bs-theme="dark"] .bg-white {
  background: #1e293b !important;
}

[data-bs-theme="dark"] .bg-light {
  background: #0f172a !important;
}

[data-bs-theme="dark"] .border-bottom {
  border-color: #334155 !important;
}

[data-bs-theme="dark"] .text-dark {
  color: #f1f5f9 !important;
}

/* Document Cards */
.doc-card {
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.doc-card:hover {
  border-color: var(--brand-primary) !important;
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.1) !important;
}
.doc-icon {
  min-width: 40px;
  min-height: 40px;
}

/* --- Onboarding milestones (post-registration) --- */
.onboarding-ring {
  --pct: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--brand-primary) calc(var(--pct) * 1%), #e2e8f0 0);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.onboarding-ring::before {
  content: '';
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  grid-area: 1 / 1;
}
.onboarding-ring-value {
  grid-area: 1 / 1;
  z-index: 1;
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f172a;
}
[data-bs-theme="dark"] .onboarding-ring::before { background: #1e293b; }
[data-bs-theme="dark"] .onboarding-ring-value { color: #f1f5f9; }

.onboarding-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.onboarding-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: inherit;
  min-width: 88px;
  max-width: 110px;
  flex: 1 1 0;
}
.onboarding-step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid #cbd5e1;
  background: #fff;
  color: #64748b;
  margin-bottom: 0.4rem;
}
.onboarding-step.is-done .onboarding-step-circle {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
.onboarding-step.is-pending .onboarding-step-circle {
  border-color: var(--brand-accent);
  color: #9a6700;
}
.onboarding-step-label {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  color: #475569;
}
.onboarding-step.is-done .onboarding-step-label { color: #0f172a; }
.onboarding-step-line {
  flex: 0 0 18px;
  height: 2px;
  background: #e2e8f0;
  margin-top: 17px;
  align-self: flex-start;
}
.onboarding-step-line.is-hot { background: var(--brand-primary); }
@media (max-width: 575.98px) {
  .onboarding-step { min-width: 72px; }
  .onboarding-step-label { font-size: 0.65rem; }
}
