/* ================================================================
   vCounter — Custom Design System
   UI/UX Pro Max: Accessible & Ethical | Healthcare | RTL Persian
   ================================================================ */

/* ── 1. Tokens ─────────────────────────────────────────────── */
:root {
  --vc-radius-sm:  0.5rem;
  --vc-radius-md:  0.75rem;
  --vc-radius-lg:  1rem;
  --vc-radius-xl:  1.25rem;
  --vc-radius-2xl: 1.5rem;
  --vc-transition: 200ms ease;
  --vc-avatar-size: 2.25rem;
  --vc-shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.04);
  --vc-shadow-md: 0 4px 12px rgba(15,23,42,.08), 0 12px 28px rgba(15,23,42,.08);
}

/* ── 2. Typography ─────────────────────────────────────────── */
html { font-size: 14px; }

@media (min-width: 768px) { html { font-size: 16px; } }

/* ── 3. Accessibility: Focus rings (WCAG 2.1 AA) ───────────── */
:focus-visible {
  outline: 3px solid var(--bs-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── 4. RTL Form Fixes ─────────────────────────────────────── */
.form-floating > .form-control::placeholder,
.form-floating > .form-control-plaintext::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control:focus::placeholder,
.form-floating > .form-control-plaintext:focus::placeholder {
  text-align: start;
}

/* ── 5. Reduced Motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── 6. App menu toggler icon (open vs closed) ─────────────── */
.app-toggler {
  position: relative;
  z-index: 100000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-toggler svg {
  display: block;
  transition: transform var(--vc-transition);
  will-change: transform;
}

/* Desktop (>1480): expanded → collapse chevron; mini → expand */
@media (min-width: 1481px) {
  .app-toggler svg {
    transform: rotate(180deg);
  }

  .app-toggler.active svg {
    transform: rotate(0deg);
  }
}

/* Drawer mode (≤1480): closed → expand; open → collapse */
@media (max-width: 1480px) {
  .app-toggler svg {
    transform: rotate(0deg);
  }

  .app-toggler.active svg {
    transform: rotate(180deg);
  }

  /* Keep menu above dimmed backdrop so it doesn't feel stuck */
  .app-menubar-tabs.open {
    z-index: 100001;
  }
}

/* ── 7. Header User Area ───────────────────────────────────── */
.vc-user-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vc-user-greeting {
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
  line-height: 1;
}

.vc-user-greeting strong {
  color: var(--bs-heading-color);
}

@media (max-width: 575px) {
  .vc-user-greeting { display: none; }
}

.vc-avatar-btn {
  appearance: none;
  background: none;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: border-color var(--vc-transition);
}

.vc-avatar-btn:hover,
.vc-avatar-btn[aria-expanded="true"] {
  border-color: var(--bs-primary);
}

.vc-avatar {
  width: var(--vc-avatar-size);
  height: var(--vc-avatar-size);
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  user-select: none;
  pointer-events: none;
  flex-shrink: 0;
}

.vc-avatar-img {
  object-fit: cover;
  background: transparent;
  padding: 0;
}

.vc-avatar-preview {
  --vc-avatar-size: 4.5rem;
  font-size: 1.25rem;
}

.vc-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  min-height: 40px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bs-primary);
  border: 1.5px solid var(--bs-primary);
  border-radius: var(--vc-radius-md);
  text-decoration: none;
  transition: background-color var(--vc-transition), color var(--vc-transition);
}

.vc-login-btn:hover,
.vc-login-btn:focus-visible {
  background-color: var(--bs-primary);
  color: #fff;
  text-decoration: none;
}

/* ── 7. OTP login step ─────────────────────────────────────── */
.vc-otp-step {
  max-width: 22rem;
  margin-inline: auto;
  text-align: center;
}

.vc-otp-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.vc-otp-subtitle {
  color: var(--bs-secondary-color);
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
}

.vc-otp-boxes {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  direction: ltr;
}

.vc-otp-digit {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--vc-radius-md);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
  line-height: 1;
  caret-color: var(--bs-primary);
  transition: border-color var(--vc-transition), box-shadow var(--vc-transition);
}

.vc-otp-digit:focus {
  outline: none;
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.2);
}

.vc-otp-countdown {
  min-height: 1.25rem;
  font-size: 0.875rem;
}

.vc-otp-resend-btn:disabled,
.vc-otp-resend-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
  text-decoration: none;
}

.vc-otp-change-number {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
  text-decoration: none;
}

.vc-otp-change-number:hover,
.vc-otp-change-number:focus-visible {
  color: var(--bs-primary);
  text-decoration: none;
}

.vc-otp-change-number::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-inline-end: 1.5px solid currentColor;
  border-block-end: 1.5px solid currentColor;
  transform: rotate(135deg);
  margin-inline-start: 0.15rem;
}

@media (max-width: 399px) {
  .vc-otp-digit {
    width: 2.35rem;
    height: 2.35rem;
    font-size: 1.125rem;
  }

  .vc-otp-boxes {
    gap: 0.35rem;
  }
}

/* ── Role page-access tree ───────────────────────────────── */
.access-tree-panel {
  max-height: 560px;
  overflow: auto;
}

.access-tree,
.access-tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.access-tree-children {
  margin-inline-start: 1.25rem;
  padding-inline-start: 0.75rem;
  border-inline-start: 1px dashed var(--bs-border-color);
}

.access-tree-node {
  margin: 0.15rem 0;
}

.access-tree-node[hidden] {
  display: none !important;
}

.access-tree-row {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.28rem 0.4rem;
  border-radius: var(--vc-radius-sm);
  border-inline-start: 1px dashed transparent;
}

.access-tree-node[data-depth]:not([data-depth="0"]) > .access-tree-row {
  border-inline-start-color: var(--bs-border-color);
}

.access-tree-row:hover {
  background: rgba(var(--bs-primary-rgb), 0.04);
}

.access-tree-toggle {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--bs-secondary-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform var(--vc-transition), background var(--vc-transition);
}

.access-tree-toggle:hover {
  background: rgba(var(--bs-primary-rgb), 0.08);
  color: var(--bs-primary);
}

.access-tree-toggle[aria-expanded="false"] {
  transform: rotate(90deg);
}

.access-tree-toggle-spacer {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
}

.access-tree-check {
  flex: 1 1 auto;
  min-width: 0;
}

.access-tree-check .form-check-input {
  margin-top: 0.2rem;
}

.access-tree-title {
  font-weight: 500;
}

.access-tree-key {
  display: inline-block;
  margin-inline-start: 0.35rem;
  font-size: 0.8em;
  word-break: break-all;
}

.access-tree-folder-label {
  font-weight: 600;
  color: var(--bs-heading-color);
  padding-top: 0.15rem;
}

.access-tree > .access-tree-node > .access-tree-row {
  background: rgba(var(--bs-secondary-rgb), 0.06);
  margin-bottom: 0.15rem;
}

.access-tree > .access-tree-node > .access-tree-row .access-tree-title,
.access-tree > .access-tree-node > .access-tree-row .access-tree-folder-label {
  font-weight: 700;
}
