/* Teksa Theme (Figma node 781-9408)
   This file intentionally overrides Metronic defaults while keeping the existing asset pipeline.
*/

:root {
  --teksa-bg: #fafafa;
  --teksa-white: #ffffff;
  --teksa-outline: #efeff5;
  --teksa-border: #efeff5;
  --teksa-primary-900: #0d4466;
  --teksa-primary-500: #1ea1f3;
  --teksa-primary-50: #e9f6fe;
  --teksa-grey-700: #586a84;
  --teksa-neutral-70: #404040;
  --teksa-muted-600: #6b7280;

  --teksa-radius-8: 8px;
  --teksa-radius-12: 12px;
  --teksa-radius-16: 16px;
  --teksa-radius-24: 24px;
  --teksa-radius-32: 32px;
}

body.teksa-theme {
  background: var(--teksa-bg);
  font-family: "IBM Plex Sans Arabic", "Readex Pro", "Tajawal", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.teksa-shell {
  display: flex;
  gap: 32px;
  padding: 24px 32px;
  min-height: 100vh;
}

html[dir="rtl"] .teksa-shell {
  /* Some upstream styles can override flex-direction; enforce RTL ordering explicitly. */
  flex-direction: row-reverse;
}

html[dir="rtl"] .teksa-shell > .teksa-sidebar {
  order: 2;
}

html[dir="rtl"] .teksa-shell > .teksa-main {
  order: 1;
}

.teksa-sidebar {
  background: var(--teksa-primary-900);
  border-radius: var(--teksa-radius-24);
  padding: 48px 30px;
  width: 277px;
  flex: 0 0 277px;
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  overflow: hidden;
}

.teksa-sidebar__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.teksa-sidebar__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 48px;
  position: relative;
  z-index: 2;
}

.teksa-sidebar__logo img {
  height: 42px;
  width: 132px;
  display: block;
}

.teksa-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 2;
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.teksa-sidebar__nav::-webkit-scrollbar {
  width: 0;
  background: transparent;
}

.teksa-nav-group {
  display: block;
}

.teksa-nav-group > summary {
  list-style: none;
  cursor: pointer;
}

.teksa-nav-group > summary::-webkit-details-marker {
  display: none;
}

.teksa-nav-item {
  display: flex;
  align-items: center;
  /* Keep markup as-is (label then icon) but render icon on the correct side:
     - LTR: icon on left
     - RTL: icon on right (because `direction: rtl` flips the inline axis) */
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 12px;
  border-radius: var(--teksa-radius-12);
  padding: 16px;
  color: var(--teksa-white);
  text-decoration: none;
}

.teksa-nav-item--group {
  user-select: none;
  /* Override the generic nav-item rule so we can place:
     - icon on inline-start
     - chevron on inline-end (right in LTR, left in RTL)
  */
  flex-direction: row;
  justify-content: flex-start;
}

.teksa-nav-item--group .teksa-nav-item__icon {
  order: 1;
}

.teksa-nav-item--group .teksa-nav-item__label {
  order: 2;
}

.teksa-nav-item--group .teksa-nav-item__chevron {
  order: 3;
  margin-inline-start: auto;
}

.teksa-nav-group[open] > .teksa-nav-item--group {
  background: rgba(255, 255, 255, 0.10);
}

.teksa-nav-item__chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.9;
}

.teksa-nav-group[open] .teksa-nav-item__chevron {
  transform: rotate(-135deg);
}

.teksa-nav-sub {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
  padding-inline-start: 44px;
  position: relative;
}

.teksa-nav-sub::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: 24px;
  width: 2px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 2px;
}

.teksa-nav-subitem {
  display: block;
  position: relative;
  padding: 14px 18px;
  border-radius: var(--teksa-radius-16);
  color: rgba(255, 255, 255, 0.60);
  text-decoration: none;
  font-size: 13px;
  line-height: 22px;
  text-align: start;
  background: transparent;
}

.teksa-nav-subitem::before {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-start: -20px;
  width: 20px;
  height: 26px;
  border-inline-start: 2px solid rgba(255, 255, 255, 0.18);
  border-bottom: 2px solid rgba(255, 255, 255, 0.18);
  border-bottom-left-radius: 14px;
}

html[dir="rtl"] .teksa-nav-subitem::before {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 14px;
}

.teksa-nav-subitem:last-child::after {
  content: "";
  position: absolute;
  inset-inline-start: -21px;
  top: calc(50% + 13px);
  bottom: -20px;
  width: 6px;
  background: var(--teksa-primary-900);
}

.teksa-nav-subitem.is-active {
  background: rgba(255, 255, 255, 0.78);
  color: var(--teksa-primary-900);
}

.teksa-nav-subitem.is-active::before {
  border-inline-start-color: rgba(255, 255, 255, 0.40);
  border-bottom-color: rgba(255, 255, 255, 0.40);
}

.teksa-nav-subitem:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.teksa-nav-item__label {
  font-size: 14px;
  line-height: 24px;
  text-align: start;
}

.teksa-nav-item__icon {
  width: 24px;
  height: 24px;
}

.teksa-nav-item.is-active {
  background: var(--teksa-white);
  border: 0.5px solid rgba(245, 239, 235, 0.16);
  color: var(--teksa-primary-900);
}

/* When a menu item is selected, force the SVG/img icon to render black. */
.teksa-nav-item.is-active .teksa-nav-item__icon {
  filter: brightness(0) saturate(100%);
}

/* Dashboard icon: force it to white when NOT selected. */
.teksa-nav-item:not(.is-active) .teksa-nav-item__icon[src$="nav-dashboard.svg"] {
  filter: brightness(0) saturate(100%) invert(1);
}

.teksa-sidebar__version {
  position: relative;
  z-index: 2;
  padding: 12px 16px 8px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  -webkit-user-select: all;
  user-select: all;
}

.teksa-sidebar__decor {
  position: absolute;
  inset-inline-end: -250px;
  bottom: -100px;
  width: 640px;
  height: 420px;
  opacity: 0.55;
  pointer-events: none;
  z-index: 1;
}

html[dir="rtl"] .teksa-sidebar__decor {
  inset-inline-start: -250px;
  inset-inline-end: auto;
}

.teksa-sidebar__decor img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: rotate(130deg) scale(.9);
  transform-origin: center;
}

.teksa-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.teksa-topbar {
  background: var(--teksa-white);
  border: 1px solid var(--teksa-outline);
  border-radius: var(--teksa-radius-16);
  padding: 16px 40px;
}

.teksa-topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.teksa-topbar__right {
  display: flex;
  align-items: center;
}

/* =====================
   Teksa Auth (Sign-in / OTP) – Figma node 698-11847
   ===================== */

.teksa-auth-body {
  background: var(--teksa-bg);
  min-height: 100vh;
}

.teksa-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.teksa-auth.teksa-auth--center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* -- Card container -- */
.teksa-auth-card {
  position: relative;
  width: 1123px;
  max-width: 100%;
  min-height: 680px;
  background: #e9f6fe !important;
  background-color: #e9f6fe !important;
  border-radius: 40px;
  overflow: hidden;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  padding: 56px 40px 48px;
  box-sizing: border-box;
  margin: 0 auto;
}

/* -- Logo -- */
.teksa-auth-card__logo {
  display: flex;
  justify-content: center;
  margin-bottom: 36px;
  position: relative;
  z-index: 2;
}

.teksa-auth-card__logo svg {
  height: 75px;
  width: auto;
}

/* -- Form wrapper -- */
.teksa-auth-card__form-wrap {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 643px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 24px;
}

/* -- Title -- */
.teksa-auth__title {
  width: 100%;
  text-align: center;
  color: #000620;
  font-size: 32px;
  font-weight: 600;
  line-height: 44px;
  letter-spacing: -0.64px;
  margin: 0;
}

/* -- Form fields -- */
.teksa-auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.teksa-auth-field {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

.teksa-auth-field__label {
  font-size: 20px;
  font-weight: 400;
  line-height: 32px;
  color: var(--teksa-primary-900);
  text-align: end;
}

.teksa-auth-field__input-wrap {
  width: 100%;
  height: 72px;
  background: #ffffff !important;
  background-color: #ffffff !important;
  border-radius: 16px;
  overflow: visible;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px;
  padding: 16px;
  box-sizing: border-box;
  position: relative;
}

.teksa-auth-field__control {
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  border: 0 !important;
  background: transparent !important;
  font-size: 20px;
  line-height: 32px;
  color: #0f172a;
  outline: none !important;
  text-align: end;
  font-family: inherit;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
}

.teksa-auth-field__control::placeholder {
  color: #adb5bd;
}

.teksa-auth-field__control:focus {
  box-shadow: none !important;
  border: 0 !important;
  outline: none !important;
}

/* Override Bootstrap/Metronic globals for auth form elements */
.teksa-auth-card input,
.teksa-auth-card select,
.teksa-auth-card button {
  box-sizing: border-box;
}

.teksa-auth-field__input-wrap > input,
.teksa-auth-field__input-wrap > select {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  width: auto !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.teksa-auth-field__input-wrap > button {
  flex: 0 0 auto !important;
}

/* -- Password toggle -- */
.teksa-auth-field__toggle {
  border: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  line-height: 1;
  outline: none;
  box-shadow: none !important;
}

.teksa-auth-field__toggle svg {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  color: #adb5bd;
  display: block;
  stroke: currentColor;
  fill: none;
}

/* -- Submit button -- */
.teksa-auth-submit {
  border: 0;
  border-radius: 8px;
  padding: 20px 24px;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.34px;
  background: #1EA1F3 !important;
  background-color: #1EA1F3 !important;
  color: #ffffff !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: background 0.15s;
  font-family: inherit;
  width: 100%;
}

.teksa-auth-submit:hover {
  background: #1790d9 !important;
  background-color: #1790d9 !important;
}

.teksa-auth-submit:active {
  background: #1280c2 !important;
  background-color: #1280c2 !important;
}

/* -- Alert -- */
.teksa-auth-alert {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}

.teksa-auth-alert--error {
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.18);
}

.teksa-auth-alert--success {
  background: rgba(34, 197, 94, 0.10);
  color: #166534;
  border: 1px solid rgba(34, 197, 94, 0.20);
}

/* -- Link -- */
.teksa-auth-link {
  color: var(--teksa-primary-500);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.teksa-auth-link:hover {
  text-decoration: underline;
}

/* -- Decorative wave -- */
.teksa-auth-card__decor {
  position: absolute;
  bottom: -40px;
  left: -80px;
  width: 560px;
  height: 520px;
  pointer-events: none;
  z-index: 1;
}

/* -- Validation messages -- */
.teksa-auth-field .field-validation-error {
  color: #dc3545;
  font-size: 13px;
  text-align: end;
  width: 100%;
}

/* -- Responsive -- */
@media (max-width: 1200px) {
  .teksa-auth-card {
    width: 900px;
    min-height: 600px;
    padding: 48px 32px 40px;
    border-radius: 32px;
  }
}

@media (max-width: 768px) {
  .teksa-auth {
    padding: 16px;
  }

  .teksa-auth-card {
    width: 100%;
    border-radius: 24px;
    padding: 32px 20px 32px;
    min-height: auto;
  }

  .teksa-auth-card__logo svg {
    height: 50px;
  }

  .teksa-auth__title {
    font-size: 24px;
    line-height: 34px;
  }

  .teksa-auth-field__label {
    font-size: 16px;
    line-height: 26px;
  }

  .teksa-auth-field__input-wrap {
    height: 56px;
    padding: 12px;
    border-radius: 12px;
  }

  .teksa-auth-field__control {
    font-size: 16px;
  }

  .teksa-auth-submit {
    font-size: 16px;
    padding: 16px 20px;
  }

  .teksa-auth-card__decor {
    display: none;
  }
}

html[dir="rtl"] .teksa-topbar__inner {
  flex-direction: row-reverse;
}

.teksa-topbar__left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

html[dir="rtl"] .teksa-topbar__left {
  flex-direction: row-reverse;
}

.teksa-topbar__avatar {
  display: flex;
  align-items: center;
  gap: 8px;
}

html[dir="rtl"] .teksa-topbar__avatar {
  flex-direction: row-reverse;
}

.teksa-topbar__avatar img {
  display: block;
}

.teksa-topbar__avatar > img:first-child {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
}

.teksa-topbar__chevron {
  width: 10px;
  height: 10px;
}

.teksa-topbar__icon {
  border: 0;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.teksa-topbar__icon img {
  width: 24px;
  height: 24px;
}

.teksa-topbar__lang-btn {
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--teksa-grey-700);
  font-size: 14px;
}

html[dir="rtl"] .teksa-topbar__lang-btn {
  flex-direction: row-reverse;
}

.teksa-topbar__lang-btn img {
  width: 21px;
  height: 15px;
}

.teksa-topbar__search {
  background: rgba(232, 232, 232, 0.3);
  border-radius: var(--teksa-radius-8);
  padding: 12px 16px;
  width: 264px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
}

html[dir="rtl"] .teksa-topbar__search {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

.teksa-topbar__search img {
  width: 20px;
  height: 20px;
}

.teksa-topbar__search input {
  border: 0;
  outline: none;
  background: transparent;
  width: 100%;
  text-align: start;
  font-size: 14px;
  color: #5a5a5a;
}

.teksa-topbar__user {
  font-size: 14px;
  font-weight: 600;
  color: var(--teksa-primary-900);
  text-align: start;
}

.teksa-content {
  min-width: 0;
}

.teksa-dashboard-grid {
  display: grid;
  grid-template-columns: 488px 558px 465px;
  gap: 24px;
  align-items: start;
}

.teksa-dashboard-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

@media (max-width: 1600px) {
  .teksa-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* =====================
   Mobile Sidebar (Drawer/Panel)
   ===================== */

/* Hamburger toggle button - hidden on desktop, shown on mobile */
.teksa-sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--teksa-radius-8);
  transition: background-color 0.2s ease;
}

.teksa-sidebar-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.teksa-sidebar-toggle__bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--teksa-primary-900);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Backdrop overlay for mobile sidebar */
.teksa-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

@media (max-width: 1199px) {
  /* Show hamburger toggle on mobile/tablet */
  .teksa-sidebar-toggle {
    display: flex;
  }

  /* Shell - full width content on mobile */
  .teksa-shell {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }

  /* Sidebar as overlay panel on mobile */
  .teksa-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: 280px;
    height: 100vh;
    border-radius: 0;
    padding: 24px 20px;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  html[dir="rtl"] .teksa-sidebar {
    transform: translateX(100%);
  }

  /* Sidebar visible state */
  .teksa-sidebar.is-open {
    transform: translateX(0);
  }

  html[dir="rtl"] .teksa-sidebar.is-open {
    transform: translateX(0);
  }

  /* Show backdrop when sidebar is open */
  .teksa-sidebar-backdrop {
    display: block;
  }

  .teksa-sidebar-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
  }

  /* Main content takes full width */
  .teksa-main {
    width: 100%;
  }

  /* Hamburger animation when menu is open */
  .teksa-sidebar-toggle[aria-expanded="true"] .teksa-sidebar-toggle__bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .teksa-sidebar-toggle[aria-expanded="true"] .teksa-sidebar-toggle__bar:nth-child(2) {
    opacity: 0;
  }

  .teksa-sidebar-toggle[aria-expanded="true"] .teksa-sidebar-toggle__bar:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }

  /* Adjust topbar padding on mobile */
  .teksa-topbar {
    padding: 12px 16px;
  }

  .teksa-topbar__search {
    width: 100%;
    min-width: 0;
  }
}

.teksa-card {
  background: var(--teksa-white);
  border-radius: var(--teksa-radius-16);
  padding: 16px;
}

.teksa-card--radius-24 {
  border-radius: var(--teksa-radius-24);
}

.teksa-card--radius-32 {
  border-radius: var(--teksa-radius-32);
}

.teksa-card__title {
  color: var(--teksa-primary-900);
  font-size: 20px;
  font-weight: 600;
  line-height: 30px;
  text-align: start;
}

.teksa-card__subtitle {
  color: #a4a4a4;
  font-size: 14px;
  line-height: 30px;
  text-align: start;
}

.teksa-table {
  border: 1px solid var(--teksa-outline);
  border-radius: var(--teksa-radius-16);
  overflow: hidden;
}

.teksa-table__header {
  background: var(--teksa-primary-50);
  padding: 6px;
  border-radius: var(--teksa-radius-16);
}

.teksa-table__grid {
  display: grid;
  grid-template-columns: 1fr 112px 67px 74px 33px;
  gap: 0;
  align-items: center;
}

.teksa-table__cell {
  padding: 12px 8px;
  font-size: 12px;
  color: #000;
  text-align: start;
}

.teksa-text-start {
  text-align: start !important;
}

.teksa-table__cell--head {
  font-weight: 600;
  color: var(--teksa-primary-900);
}

.teksa-table__row {
  padding: 0 16px;
  border-top: 1px solid #f3f4f6;
}

.teksa-table__row:first-child {
  border-top: 0;
}

/* ============ Image size discipline (feature 026) ============ */
.img-avatar      { width: 40px;  height: 40px;  object-fit: cover;   border-radius: 50%; }
.img-avatar-lg   { width: 80px;  height: 80px;  object-fit: cover;   border-radius: 50%; }
.img-profile     { max-width: 200px; max-height: 200px; object-fit: cover;   border-radius: 8px; }
.img-thumb       { max-width: 120px; max-height: 120px; object-fit: cover;   border-radius: 6px; cursor: pointer; }
.img-product     { max-width: 240px; max-height: 240px; object-fit: contain; border-radius: 6px; }

/* Broken-image placeholder — applied by image-fallback.js when load fails.
   image-fallback.js removes `src` to stop the browser's default broken-image
   glyph, which also strips the element's intrinsic dimensions. Explicit
   width/height on .img-broken ensures the placeholder still occupies the
   class's intended size (no layout collapse, no shift). For the three
   max-bounded variants (.img-profile/.img-thumb/.img-product) we pick the
   class's upper bound as the broken-state size — treating it as the
   "worst-case reserved space" so the layout stays consistent. */
.img-avatar.img-broken,
.img-avatar-lg.img-broken,
.img-profile.img-broken,
.img-thumb.img-broken,
.img-product.img-broken {
  background-color: #f1f3f5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23adb5bd' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='18' height='18' rx='2'/><circle cx='8.5' cy='8.5' r='1.5'/><path d='M21 15l-5-5L5 21'/><line x1='3' y1='3' x2='21' y2='21'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 55% 55%;
  border: 1px solid #e9ecef;
}
.img-profile.img-broken { width: 200px; height: 200px; }
.img-thumb.img-broken   { width: 120px; height: 120px; }
.img-product.img-broken { width: 240px; height: 240px; }
