/* Hooshmand Kahroba login branding for ThingsBoard CE. See CHANGELOG C-010.
   Injected by nginx into index.html. Only active while body.hk-auth is set by login.js,
   so the rest of the ThingsBoard UI is untouched. Depends on ThingsBoard 4.3 login markup
   (.tb-login-content, .tb-login-form, ...): re-check after every ThingsBoard upgrade. */

@font-face {
  font-family: "HK Inter";
  src: url("/hk-brand/fonts/Inter-var.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}
@font-face {
  font-family: "HK Montserrat";
  src: url("/hk-brand/fonts/Montserrat-var.woff2") format("woff2");
  font-weight: 600 700;
  font-display: swap;
}
@font-face {
  font-family: "HK Vazirmatn";
  src: url("/hk-brand/fonts/Vazirmatn-arabic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "HK Vazirmatn";
  src: url("/hk-brand/fonts/Vazirmatn-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

body.hk-auth {
  --hk-bg: #08111f;
  --hk-bg-2: #0d1d33;
  --hk-card: rgba(17, 27, 43, 0.86);
  --hk-card-border: rgba(150, 180, 230, 0.16);
  --hk-field: rgba(255, 255, 255, 0.035);
  --hk-field-border: rgba(160, 185, 225, 0.22);
  --hk-text: #eef3fa;
  --hk-muted: #9aabc2;
  --hk-blue: #2f86ff;
  --hk-blue-2: #1c6cf0;
  --hk-link: #4a93ff;
  --hk-font: "HK Inter", "Segoe UI", Roboto, Arial, sans-serif;
  --hk-font-title: "HK Montserrat", "HK Inter", "Segoe UI", Roboto, Arial, sans-serif;

  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(47, 134, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(28, 108, 240, 0.12), transparent 60%),
    linear-gradient(160deg, var(--hk-bg-2) 0%, var(--hk-bg) 55%, #060d18 100%) !important;
  font-family: var(--hk-font);
}

/* diagonal light streak, as in the reference design */
body.hk-auth::before {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  top: -30vh;
  right: 6vw;
  width: 3px;
  height: 90vh;
  transform: rotate(38deg);
  background: linear-gradient(to bottom, transparent, rgba(80, 150, 255, 0.85), transparent);
  box-shadow: 0 0 24px 4px rgba(47, 134, 255, 0.35);
}

/* ---------- login page layout ---------- */
body.hk-auth .tb-login-content {
  position: relative;
  z-index: 1;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 500px);
  align-items: center;
  gap: clamp(32px, 4vw, 72px);
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  margin: 0 !important;
  padding: clamp(24px, 4vh, 56px) clamp(24px, 4.5vw, 88px);
  background: transparent !important;
  overflow-y: auto;
  color: var(--hk-text);
}

/* ---------- left hero panel ---------- */
.hk-hero {
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: var(--hk-text);
}
.hk-brand {
  display: flex;
  align-items: center;
  gap: 28px;
}
.hk-brand-logo {
  width: clamp(96px, 9vw, 150px);
  height: auto;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
}
.hk-brand-sep {
  width: 1px;
  align-self: stretch;
  margin: 8px 0;
  background: rgba(255, 255, 255, 0.28);
}
.hk-brand-name {
  font-family: var(--hk-font-title);
  font-weight: 700;
  font-size: clamp(22px, 2.3vw, 36px);
  letter-spacing: 0.06em;
  line-height: 1.15;
}
.hk-brand-sub {
  margin-top: 8px;
  font-size: clamp(14px, 1.3vw, 21px);
  letter-spacing: 0.32em;
  color: #c9d4e3;
}
.hk-tagline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  margin-block: clamp(20px, 3.5vh, 36px) 0;
  margin-inline: 6px 0;
  font-size: clamp(14px, 1.2vw, 19px);
  color: #d5deea;
}
.hk-tagline i {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.35);
}
.hk-visual {
  margin: clamp(12px, 3vh, 32px) 0 0;
  margin-inline-start: calc(-1 * clamp(24px, 4.5vw, 88px));
  -webkit-mask-image: linear-gradient(to right, #000 75%, transparent 100%), linear-gradient(to bottom, transparent 0%, #000 12%, #000 85%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, #000 75%, transparent 100%), linear-gradient(to bottom, transparent 0%, #000 12%, #000 85%, transparent 100%);
  mask-composite: intersect;
}
.hk-visual img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: cover;
  object-position: center top;
}
.hk-features {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: clamp(12px, 3vh, 32px);
}
.hk-feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  color: var(--hk-text);
}
.hk-feature + .hk-feature {
  border-inline-start: 1px solid rgba(255, 255, 255, 0.14);
}
.hk-feature svg {
  width: 30px;
  height: 30px;
  margin-bottom: 6px;
  color: var(--hk-link);
}
.hk-feature small {
  font-size: 12px;
  font-weight: 400;
  color: var(--hk-muted);
}

/* ---------- login card ---------- */
body.hk-auth .tb-login-content > mat-card,
body.hk-auth .tb-password-card,
body.hk-auth .tb-two-factor-auth-login-card,
body.hk-auth .tb-expired-link-card {
  --mat-card-elevated-container-color: var(--hk-card);
  --mdc-elevated-card-container-color: var(--hk-card);
  background: var(--hk-card) !important;
  border: 1px solid var(--hk-card-border);
  border-radius: 22px !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--hk-text);
  font-family: var(--hk-font);
}
body.hk-auth .tb-login-content > mat-card {
  position: relative;
  width: 100%;
  max-height: none !important;
  overflow: visible !important;
  justify-self: end;
}
body.hk-auth .tb-login-content > mat-card > mat-card-content {
  padding: clamp(28px, 4vh, 44px) clamp(24px, 3vw, 48px) 28px !important;
}
/* ThingsBoard fixes the form at 480px with a scoped (high specificity) rule */
body.hk-auth .tb-login-content .tb-login-form.tb-login-form {
  width: 100% !important;
  max-width: 100%;
  box-sizing: border-box;
}

/* replace the ThingsBoard logo and title with our header */
body.hk-auth .tb-login-form .hk-hidden,
body.hk-auth .tb-login-form .oauth-container:not(.tb-default) > .title {
  display: none !important;
}
.hk-card-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: clamp(16px, 3vh, 28px);
}
.hk-card-logo {
  width: clamp(96px, 15vh, 136px);
  height: auto;
  margin-bottom: clamp(14px, 2.5vh, 22px);
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.45));
}
body.hk-auth .hk-card-head .hk-card-title {
  margin: 0 !important;
  font-family: var(--hk-font) !important;
  font-weight: 600 !important;
  font-size: clamp(24px, 3.4vh, 30px) !important;
  line-height: 1.25 !important;
  letter-spacing: 0 !important;
  color: var(--hk-text);
}
body.hk-auth .hk-card-head .hk-card-sub {
  margin: 8px 0 0 !important;
  font-family: var(--hk-font) !important;
  font-size: 16px !important;
  line-height: 1.4 !important;
  color: #c3cedd;
}

/* form fields (Angular Material outlined) */
body.hk-auth .tb-login-content mat-form-field,
body.hk-auth .tb-password-card mat-form-field,
body.hk-auth .tb-two-factor-auth-login-card mat-form-field {
  --mat-form-field-outlined-outline-color: var(--hk-field-border);
  --mat-form-field-outlined-hover-outline-color: rgba(160, 185, 225, 0.4);
  --mat-form-field-outlined-focus-outline-color: var(--hk-blue);
  --mat-form-field-outlined-error-outline-color: #ff6b6b;
  --mat-form-field-outlined-input-text-color: var(--hk-text);
  --mat-form-field-outlined-label-text-color: var(--hk-muted);
  --mat-form-field-outlined-hover-label-text-color: #c3cedd;
  --mat-form-field-outlined-focus-label-text-color: var(--hk-link);
  --mat-form-field-outlined-container-shape: 10px;
  --mat-form-field-outlined-caret-color: var(--hk-link);
  --mat-form-field-leading-icon-color: var(--hk-muted);
  --mat-form-field-trailing-icon-color: var(--hk-muted);
  --mdc-outlined-text-field-outline-color: var(--hk-field-border);
  --mdc-outlined-text-field-hover-outline-color: rgba(160, 185, 225, 0.4);
  --mdc-outlined-text-field-focus-outline-color: var(--hk-blue);
  --mdc-outlined-text-field-input-text-color: var(--hk-text);
  --mdc-outlined-text-field-label-text-color: var(--hk-muted);
  --mdc-outlined-text-field-focus-label-text-color: var(--hk-link);
  --mdc-outlined-text-field-container-shape: 10px;
  --mdc-outlined-text-field-caret-color: var(--hk-link);
  font-family: var(--hk-font);
  margin-bottom: 6px;
}
body.hk-auth .tb-login-content .mat-mdc-text-field-wrapper,
body.hk-auth .tb-password-card .mat-mdc-text-field-wrapper,
body.hk-auth .tb-two-factor-auth-login-card .mat-mdc-text-field-wrapper {
  background: var(--hk-field);
  border-radius: 10px;
}
body.hk-auth .tb-login-content .mat-mdc-form-field-icon-prefix .mat-icon,
body.hk-auth .tb-login-content .mat-mdc-form-field-icon-suffix .mat-icon,
body.hk-auth .tb-login-content tb-toggle-password .mat-icon {
  color: var(--hk-muted) !important;
}
body.hk-auth .tb-login-content input.mat-mdc-input-element {
  color: var(--hk-text) !important;
  caret-color: var(--hk-link);
}
/* keep browser autofill from painting fields white/yellow */
body.hk-auth .tb-login-content input:-webkit-autofill {
  -webkit-text-fill-color: var(--hk-text) !important;
  -webkit-box-shadow: 0 0 0 1000px #121d2e inset !important;
  transition: background-color 9999s ease-out 0s;
}

/* primary button */
body.hk-auth .tb-login-content .tb-action-button,
body.hk-auth .tb-password-card button[color="accent"],
body.hk-auth .tb-two-factor-auth-login-card button[color="accent"] {
  height: 54px !important;
  border-radius: 10px !important;
  background: linear-gradient(90deg, var(--hk-blue) 0%, var(--hk-blue-2) 100%) !important;
  color: #fff !important;
  font-family: var(--hk-font) !important;
  font-size: 18px !important;
  font-weight: 500 !important;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(28, 108, 240, 0.35) !important;
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}
body.hk-auth .tb-login-content .tb-action-button:hover:not([disabled]) {
  filter: brightness(1.08);
  box-shadow: 0 12px 32px rgba(28, 108, 240, 0.5) !important;
}
body.hk-auth .tb-login-content .tb-action-button[disabled] {
  filter: grayscale(0.4) brightness(0.8);
}
body.hk-auth .tb-login-content .tb-action-button .mdc-button__label::after {
  content: "\2192";
  margin-left: 12px;
  font-size: 20px;
}
body.hk-auth .tb-login-content .tb-login-form .tb-action-button {
  margin: 22px 0 14px !important;
}

/* links */
body.hk-auth .tb-login-content .tb-reset-password,
body.hk-auth .tb-password-card a,
body.hk-auth .tb-password-card button.mat-mdc-button:not([color="accent"]) {
  color: var(--hk-link) !important;
  font-family: var(--hk-font) !important;
  font-weight: 500 !important;
  font-size: 14px !important;
}

/* footer */
.hk-card-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: clamp(18px, 3.5vh, 36px);
  font-size: 14px;
  color: var(--hk-muted);
  white-space: nowrap;
}
.hk-card-foot::before,
.hk-card-foot::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
}

/* other auth pages (reset / create password, 2FA, expired link) */
body.hk-auth .tb-password-content,
body.hk-auth .tb-two-factor-auth-login-content,
body.hk-auth .tb-expired-link-content {
  position: relative;
  z-index: 1;
  background: transparent !important;
}
body.hk-auth .tb-password-card,
body.hk-auth .tb-two-factor-auth-login-card,
body.hk-auth .tb-expired-link-card {
  padding: 8px;
}
.hk-mini-logo {
  display: block;
  width: 72px;
  height: auto;
  margin: 20px auto 0;
}

/* ---------- language switch ---------- */
.hk-lang {
  position: absolute;
  top: 16px;
  inset-inline-end: 16px;
  z-index: 2;
  display: flex;
  padding: 3px;
  border: 1px solid var(--hk-card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}
.hk-lang button {
  min-width: 46px;
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--hk-muted);
  font: 500 13px/1.2 var(--hk-font);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.hk-lang button[lang="fa"] {
  font-family: "HK Vazirmatn", var(--hk-font);
}
.hk-lang button:hover {
  color: var(--hk-text);
}
.hk-lang button.hk-active {
  background: var(--hk-blue-2);
  color: #fff;
}
.hk-lang button:focus-visible {
  outline: 2px solid var(--hk-link);
  outline-offset: 1px;
}

/* ---------- Persian (RTL) ---------- */
body.hk-fa {
  --hk-font: "HK Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  --hk-font-title: "HK Vazirmatn", "Segoe UI", Tahoma, sans-serif;
}
/* ThingsBoard form texts too, but never the icon fonts */
body.hk-fa .tb-login-content :not(mat-icon):not(.mat-icon):not(.material-icons),
body.hk-fa .tb-password-content :not(mat-icon):not(.mat-icon):not(.material-icons),
body.hk-fa .tb-two-factor-auth-login-content :not(mat-icon):not(.mat-icon):not(.material-icons),
body.hk-fa .tb-expired-link-content :not(mat-icon):not(.mat-icon):not(.material-icons) {
  font-family: var(--hk-font) !important;
}
/* letter spacing breaks Persian letter joining */
body.hk-fa .hk-brand-name,
body.hk-fa .hk-brand-sub,
body.hk-fa .tb-login-content .tb-action-button {
  letter-spacing: 0 !important;
}
body.hk-fa .hk-brand-name {
  font-size: clamp(26px, 2.6vw, 40px);
  font-weight: 700;
}
body.hk-fa .hk-brand-sub {
  font-size: clamp(15px, 1.4vw, 22px);
}
body.hk-fa .hk-feature small {
  font-size: 13px;
}
body.hk-fa .tb-login-content .tb-action-button .mdc-button__label::after {
  content: "\2190";
  margin-left: 0;
  margin-right: 12px;
}
/* user names and passwords are typed left-to-right */
body.hk-fa .tb-login-content #username-input,
body.hk-fa .tb-login-content #password-input {
  direction: ltr;
  text-align: right;
}
body.hk-fa .hk-visual {
  -webkit-mask-image: linear-gradient(to left, #000 75%, transparent 100%), linear-gradient(to bottom, transparent 0%, #000 12%, #000 85%, transparent 100%);
  mask-image: linear-gradient(to left, #000 75%, transparent 100%), linear-gradient(to bottom, transparent 0%, #000 12%, #000 85%, transparent 100%);
}

/* ---------- boot loader: replaces ThingsBoard's three bouncing dots (C-019) ----------
   #tb-loading-spinner is static markup in ThingsBoard's index.html, shown until the app has started.
   This stylesheet is render-blocking in <head>, so the dots never appear. */
#tb-loading-spinner.tb-loading-spinner {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  background:
    radial-gradient(700px 500px at 50% 42%, rgba(47, 134, 255, 0.16), transparent 62%),
    linear-gradient(160deg, #0d1d33 0%, #08111f 58%, #060d18 100%);
}
#tb-loading-spinner.tb-loading-spinner > div {
  display: none !important;
}
#tb-loading-spinner.tb-loading-spinner::before {
  content: "";
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: url("/hk-brand/logo.png") center / cover no-repeat;
  animation: hk-boot-pulse 0.6s ease-in-out infinite; /* user request: 600 ms per pulse */
}
#tb-loading-spinner.tb-loading-spinner::after {
  content: "Hooshmand Kahroba";
  min-width: 190px;
  padding-bottom: 18px;
  color: #d6e4f5;
  font: 600 17px/1.5 "HK Vazirmatn", "HK Inter", "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0.05em;
  text-align: center;
  /* moving progress line under the name: a highlight sliding over a faint track */
  background:
    linear-gradient(90deg, transparent, #2f86ff, #22d3ee, transparent) 0 100% / 45% 3px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)) 0 100% / 100% 3px no-repeat;
  animation: hk-boot-bar 0.9s ease-in-out infinite;
}
html[data-hk-lang="fa"] #tb-loading-spinner.tb-loading-spinner::after {
  content: "هوشمند کهربا";
  letter-spacing: 0;
}
/* a short refresh shows the loader for well under a second (C-019: 0.76 s measured), so every
   cycle is short and starts visibly: shrunk logo growing out, light ring rippling away */
@keyframes hk-boot-pulse {
  0% { transform: scale(0.93); box-shadow: 0 0 0 0 rgba(47, 134, 255, 0.65), 0 0 24px rgba(47, 134, 255, 0.25); }
  55% { transform: scale(1.07); box-shadow: 0 0 0 20px rgba(47, 134, 255, 0), 0 0 52px rgba(47, 134, 255, 0.55); }
  100% { transform: scale(0.93); box-shadow: 0 0 0 0 rgba(47, 134, 255, 0), 0 0 24px rgba(47, 134, 255, 0.25); }
}
@keyframes hk-boot-bar {
  0% { background-position: -60% 100%, 0 100%; }
  100% { background-position: 160% 100%, 0 100%; }
}
/* No prefers-reduced-motion exception on purpose: many Windows installs run with animation effects off
   ("best performance"), which made the loader completely static; the product owner asked for the pulse (C-019). */

/* ---------- signed-in app: remove ThingsBoard branding (C-014) ---------- */
tb-logo.tb-logo-title img:not(.hk-app-logo) {
  display: none !important;
}
.hk-app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-family: "HK Vazirmatn", "HK Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.hk-app-brand .hk-app-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
section.tb-powered-by-footer {
  display: none !important;
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  body.hk-auth .tb-login-content {
    grid-template-columns: minmax(0, 520px);
    justify-content: center;
  }
  .hk-hero {
    display: none;
  }
  body.hk-auth .tb-login-content > mat-card {
    justify-self: stretch;
  }
}
@media (max-width: 560px) {
  body.hk-auth .tb-login-content {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }
  body.hk-auth .tb-login-content > mat-card > mat-card-content {
    padding: 24px 18px 20px !important;
  }
}
