/* filepath: public/css/admin.css */
/* ═══════════════════════════════════════
   Admin Pages — BEM CSS
   ═══════════════════════════════════════ */

/* ── Shared: Toggle Switch ── */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle--on { background: #6366f1; }
.toggle--off { background: #cbd5e1; }
.toggle__knob {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle__knob--on { left: 22px; }
.toggle__knob--off { left: 2px; }

/* ── Shared: Section Header (inside card, no padding) ── */
.section-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header__icon { color: #6366f1; }
.section-header__title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.section-header__subtitle {
  font-size: .78rem;
  color: #94a3b8;
  margin: 0;
}
.section-header__right { margin-left: auto; }

/* ── Shared: Empty State ── */
.empty-state {
  padding: 32px 20px;
  text-align: center;
  color: #94a3b8;
}
.empty-state--lg { padding: 48px 20px; }
.empty-state__icon {
  font-size: 2rem;
  margin-bottom: 10px;
  display: block;
  opacity: .4;
}
.empty-state__icon--lg { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state__icon--sm { font-size: 1.5rem; margin-bottom: 8px; }
.empty-state__text { margin: 0; }
.empty-state__text--bold { font-weight: 500; }
.empty-state__text--mb { margin-bottom: 20px; }

/* ── Shared: Info Table (key-value rows) ── */
.info-table {
  width: 100%;
  font-size: .85rem;
  border-collapse: collapse;
}
.info-table--lg { font-size: .88rem; }
.info-table__row { border-bottom: 1px solid #f1f5f9; }
.info-table__label {
  padding: 8px 0;
  color: #64748b;
  width: 45%;
}
.info-table__label--narrow { width: 35%; }
.info-table__value {
  padding: 8px 0;
  font-weight: 600;
}
.info-table__value--normal { font-weight: 500; }
.info-table__value--prewrap { white-space: pre-wrap; }

/* ── Shared: Flex Utilities ── */
.flex-row { display: flex; align-items: center; }
.flex-row--between { justify-content: space-between; }
.flex-row--gap-6 { gap: 6px; }
.flex-row--gap-8 { gap: 8px; }
.flex-row--gap-10 { gap: 10px; }
.flex-row--gap-12 { gap: 12px; }
.flex-row--wrap { flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; }
.flex-col--gap-8 { gap: 8px; }
.flex-col--gap-12 { gap: 12px; }
.flex-col--gap-14 { gap: 14px; }
.flex-col--gap-16 { gap: 16px; }
.flex-col--gap-20 { gap: 20px; }
.flex-1 { flex: 1; min-width: 0; }

/* ── Shared: Spacing ── */
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-4 { margin-top: 4px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mr-4 { margin-right: 4px; }
.mr-6 { margin-right: 6px; }
.mr-8 { margin-right: 8px; }
.ml-4 { margin-left: 4px; }
.ml-8 { margin-left: 8px; }

/* ── Shared: Text Helpers ── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #94a3b8; }
.text-muted-dark { color: #64748b; }
.text-dark { color: #1e293b; }
.text-primary { color: #6366f1; }
.text-success { color: #059669; }
.text-danger { color: #ef4444; }
.text-capitalize { text-transform: capitalize; }
.text-mono { font-family: monospace; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-xs { font-size: .75rem; }
.font-sm { font-size: .82rem; }
.font-md { font-size: .85rem; }
.font-base { font-size: .88rem; }

/* ── Shared: Padding/Overflow ── */
.p-0 { padding: 0; }
.overflow-hidden { overflow: hidden; }

/* ── Shared: Cursor ── */
.cursor-pointer { cursor: pointer; }

/* ── Shared: Icon Margin (small gap before/after icon) ── */
.icon-mr { margin-right: 6px; }

/* ═══════════════════════════════════════
   Billing Page
   ═══════════════════════════════════════ */

.billing__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.billing__section-label {
  font-size: .75rem;
  color: #94a3b8;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.billing__plan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.billing__plan-badge {
  font-size: 1rem;
  padding: 6px 16px;
}
.billing__plan-desc {
  font-size: .85rem;
  color: #64748b;
}

.billing__usage-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
  line-height: 1;
}
.billing__usage-total {
  font-size: 1rem;
  font-weight: 400;
  color: #94a3b8;
}

.billing__progress-track {
  background: #f1f5f9;
  border-radius: 8px;
  height: 12px;
  margin: 12px 0 6px;
  overflow: hidden;
}
.billing__progress-fill {
  height: 100%;
  border-radius: 8px;
  transition: width .5s;
}
.billing__usage-pct {
  font-size: .8rem;
  color: #64748b;
}

.billing__quota-warn {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: .82rem;
  color: #dc2626;
}

.billing__usage-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  font-size: .82rem;
  color: #64748b;
}
.billing__usage-footer-row {
  display: flex;
  justify-content: space-between;
}
.billing__usage-footer-row + .billing__usage-footer-row { margin-top: 6px; }
.billing__usage-footer-val {
  font-weight: 600;
  color: #1e293b;
}

.billing__actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.billing__btn-text { font-size: .8rem; }
.billing__btn-cancel {
  font-size: .8rem;
  color: #ef4444;
  border-color: #fecaca;
}

.billing__current-badge {
  display: block;
  font-size: .7rem;
  color: #6366f1;
  margin-top: 2px;
}

.billing__feature-check { color: #22c55e; font-size: 1rem; }
.billing__feature-cross { color: #e2e8f0; font-size: 1rem; }

/* API Keys */
.billing__api-code {
  font-size: .8rem;
  background: #f8fafc;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}
.billing__revoke-btn {
  color: #ef4444;
  border-color: #fecaca;
  font-size: .75rem;
}

.billing__loading {
  padding: 24px;
  text-align: center;
  color: #94a3b8;
}

/* Plan Modal */
.billing__plan-option {
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all .15s;
}
.billing__plan-option--selected {
  border: 2px solid #6366f1;
  background: #f5f3ff;
}
.billing__plan-option--unselected {
  border: 2px solid #e2e8f0;
  background: #fff;
}
.billing__plan-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: #1e293b;
}
.billing__plan-meta {
  font-size: .83rem;
  color: #64748b;
  margin-top: 2px;
}
.billing__plan-quota {
  font-size: .83rem;
  color: #64748b;
  margin-top: 4px;
}
.billing__plan-price {
  font-size: 1.4rem;
  font-weight: 800;
  color: #6366f1;
}
.billing__plan-per-month {
  font-size: .75rem;
  color: #94a3b8;
}
.billing__ssl-note {
  font-size: .78rem;
  color: #94a3b8;
  margin: 4px 0 0;
  text-align: center;
}

/* Cancel Modal */
.billing__cancel-body {
  text-align: center;
  padding: 8px 0;
}
.billing__cancel-icon {
  font-size: 2.5rem;
  color: #f59e0b;
  margin-bottom: 12px;
  display: block;
}
.billing__cancel-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 8px;
}
.billing__cancel-desc {
  color: #64748b;
  font-size: .88rem;
}
.billing__btn-confirm-cancel {
  background: #ef4444;
  border-color: #ef4444;
}

/* New API Key Modal */
.billing__api-created-msg {
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: .82rem;
  color: #166534;
}
.billing__api-key-display {
  display: flex;
  align-items: center;
  gap: 8px;
}
.billing__api-key-code {
  flex: 1;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: .85rem;
  word-break: break-all;
}

/* Billing Info form grid */
.billing__form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.billing__form-full { grid-column: 1 / -1; }

.billing__no-info {
  color: #94a3b8;
  font-size: .88rem;
  margin: 0;
}

/* Invoice */
.billing__invoice-no {
  font-weight: 600;
  font-family: monospace;
  font-size: .85rem;
}

/* ═══════════════════════════════════════
   Approval Flows Page
   ═══════════════════════════════════════ */

.approval__toggle-card { margin-bottom: 16px; }

.approval__toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.approval__toggle-label {
  font-weight: 700;
  font-size: .95rem;
  color: #1e293b;
}
.approval__toggle-desc {
  font-size: .82rem;
  color: #94a3b8;
  margin-top: 4px;
}
.approval__toggle-status {
  font-size: .85rem;
  font-weight: 600;
}
.approval__toggle-status--enabled { color: #059669; }
.approval__toggle-status--disabled { color: #94a3b8; }

/* Empty state */
.approval__empty {
  text-align: center;
  padding: 40px 20px;
}
.approval__empty-icon {
  font-size: 2.5rem;
  color: #e2e8f0;
  margin-bottom: 14px;
  display: block;
}
.approval__empty-title {
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
}
.approval__empty-desc {
  font-size: .83rem;
  color: #94a3b8;
  margin-bottom: 20px;
}

/* Flow summary card */
.approval__flow-card {
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  border: 1.5px solid #e2e8f0;
}
.approval__flow-card:hover {
  border-color: #6366f1;
  box-shadow: 0 4px 20px rgba(99,102,241,.1);
}

.approval__flow-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}
.approval__flow-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #eef2ff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.approval__flow-icon { color: #6366f1; font-size: 1.1rem; }
.approval__flow-name {
  font-weight: 700;
  font-size: 1rem;
  color: #1e293b;
}
.approval__flow-level-count {
  font-size: .78rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* Level preview list */
.approval__level-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.approval__level-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
}

.approval__level-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .75rem;
  flex-shrink: 0;
}
.approval__level-name {
  font-weight: 600;
  font-size: .87rem;
  color: #1e293b;
}
.approval__level-approver {
  font-size: .76rem;
  color: #94a3b8;
  margin-left: 8px;
}

.approval__level-badge {
  font-size: .72rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
}
.approval__level-badge--amount {
  background: #eff6ff;
  color: #3b82f6;
}
.approval__level-badge--all {
  background: #f0fdf4;
  color: #059669;
}

.approval__arrow-hidden {
  font-size: .65rem;
  color: #cbd5e1;
  position: absolute;
  margin-left: -999px;
}

/* Configure modal */
.approval__cfg-levels-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.approval__cfg-levels-label {
  margin-bottom: 0;
  font-weight: 700;
}

.approval__cfg-empty {
  text-align: center;
  padding: 24px 0;
  color: #94a3b8;
  background: #f8fafc;
  border-radius: 10px;
  border: 1.5px dashed #e2e8f0;
}
.approval__cfg-empty-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
  display: block;
  opacity: .4;
}
.approval__cfg-empty-text { font-size: .85rem; }

/* Editable level row */
.approval__cfg-level {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.approval__cfg-level:hover {
  border-color: var(--level-color, #6366f1);
}

.approval__cfg-level-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .8rem;
  flex-shrink: 0;
}
.approval__cfg-level-name {
  font-weight: 700;
  font-size: .88rem;
  color: #1e293b;
}
.approval__cfg-level-meta {
  font-size: .75rem;
  color: #64748b;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.approval__cfg-level-badge {
  font-size: .72rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.approval__cfg-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #cbd5e1;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color .15s;
}
.approval__cfg-remove-btn:hover { color: #ef4444; }

/* Level edit modal */
.approval__hint {
  font-size: .75rem;
  color: #94a3b8;
  margin-top: 4px;
}
.approval__auto-info {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: .82rem;
  color: #64748b;
}

/* ═══════════════════════════════════════
   Departments Page
   ═══════════════════════════════════════ */

.dept__tree-card { margin-bottom: 20px; }
.dept__tree-empty {
  padding: 32px;
  text-align: center;
  color: #94a3b8;
}
.dept__tree-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
}

.dept__root-row { background: #f8fafc; }
.dept__root-name { font-weight: 700; }
.dept__root-icon { margin-right: 8px; color: #6366f1; }

.dept__no-parent {
  color: #94a3b8;
  font-size: .8rem;
}

.dept__child-name { padding-left: 32px; }
.dept__child-icon { margin-right: 8px; color: #94a3b8; }

.dept__action-gap { margin-right: 6px; }

/* User assignment */
.dept__user-name {
  font-weight: 600;
  font-size: .88rem;
}
.dept__user-role {
  font-size: .75rem;
  color: #94a3b8;
}
.dept__user-email {
  font-size: .85rem;
  color: #64748b;
}
.dept__user-dept { font-size: .85rem; }
.dept__assign-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.dept__assign-select {
  flex: 1;
  padding: 6px 8px;
  font-size: .82rem;
}
.dept__spinner { color: #6366f1; }

/* Department Modal (custom, not using shared Modal) */
.dept__modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dept__modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.5);
}
.dept__modal-box {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.dept__modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.dept__modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.dept__modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 18px;
}
.dept__form-group { margin-bottom: 14px; }
.dept__form-group--last { margin-bottom: 20px; }
.dept__form-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════
   Users Page
   ═══════════════════════════════════════ */

.users__card {
  padding: 0;
  overflow: hidden;
}

.users__dept-cell {
  font-size: .85rem;
  color: #4a5568;
}
.users__dept-empty { color: #a0aec0; }

.users__device-list {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.users__device-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
}
.users__device-badge--ios { background: #000; color: #fff; }
.users__device-badge--android { background: #3ddc84; color: #000; }
.users__device-badge--web { background: #6366f1; color: #fff; }
.users__no-device {
  color: #cbd5e1;
  font-size: .8rem;
}

.users__date-cell {
  font-size: .8rem;
  color: #64748b;
}
.users__action-row {
  display: flex;
  gap: 6px;
}
.users__btn-sm {
  padding: 4px 10px;
  font-size: .75rem;
}

/* Pagination */
.users__pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  font-size: .82rem;
  color: #64748b;
}
.users__pagination-btns {
  display: flex;
  gap: 4px;
}
.users__pagination-btn {
  padding: 4px 12px;
  font-size: .78rem;
}
.users__page-num {
  padding: 4px 10px;
  font-size: .78rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}
.users__page-num--active {
  background: #6366f1;
  color: #fff;
  font-weight: 700;
}
.users__page-num--inactive {
  background: transparent;
  color: #64748b;
  font-weight: 400;
}

/* Modal forms */
.users__form-grid { display: grid; gap: 14px; }
.users__device-section { margin-top: 4px; }
.users__device-label { margin-bottom: 8px; }
.users__device-icon { margin-right: 6px; color: #6366f1; }
.users__device-list-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.users__device-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-size: .82rem;
}
.users__device-platform-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}
.users__device-platform-icon--ios { color: #333; }
.users__device-platform-icon--android { color: #3ddc84; }
.users__device-platform-icon--web { color: #6366f1; }
.users__device-info-name {
  font-weight: 600;
  color: #1e293b;
}
.users__device-info-meta {
  color: #94a3b8;
  font-size: .75rem;
}

/* ═══════════════════════════════════════
   Tenant Settings Page
   ═══════════════════════════════════════ */

.settings__tab-bar {
  display: inline-flex;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 20px;
}
.settings__tab {
  padding: 8px 20px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s;
}
.settings__tab--active {
  background: #6366f1;
  color: #fff;
}
.settings__tab--inactive {
  background: transparent;
  color: #64748b;
}
.settings__tab-icon { margin-right: 6px; }

.settings__card { max-width: 600px; }

.settings__toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid #f1f5f9;
}
.settings__toggle-content {
  flex: 1;
  margin-right: 16px;
}
.settings__toggle-label {
  font-weight: 600;
  font-size: .88rem;
  color: #1e293b;
}
.settings__toggle-desc {
  font-size: .78rem;
  color: #94a3b8;
  margin-top: 2px;
}

.settings__select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: .88rem;
  background: #fff;
  color: #1e293b;
  cursor: pointer;
  outline: none;
}

.settings__notify-section { margin-bottom: 8px; }
.settings__notify-section--email { margin-top: 24px; margin-bottom: 8px; }
.settings__notify-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.settings__notify-icon { color: #6366f1; }
.settings__notify-title {
  font-weight: 700;
  font-size: .92rem;
  color: #1e293b;
}
.settings__notify-desc {
  font-size: .78rem;
  color: #94a3b8;
  margin-bottom: 8px;
}

.settings__save-section { margin-top: 20px; }

/* ═══════════════════════════════════════
   Responsive Overrides
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
  .billing__grid { grid-template-columns: 1fr; }
  .billing__form-grid { grid-template-columns: 1fr; }
}
