/* ============================================================
   K-NET custom theme - layered on top of Tabler / Bootstrap 5
   ============================================================ */
:root {
  --knet-primary: #1c3faa;
  --knet-primary-light: #3b82f6;
  --knet-primary-dark: #0b2378;
  --knet-bg: #eaf1fb;
  --knet-bg-accent: #d4e3fb;
  --knet-radius: 18px;
  --knet-shadow: 0 12px 30px rgba(28, 63, 170, 0.10);
  --knet-soft-shadow: 0 4px 12px rgba(28, 63, 170, 0.08);
  scroll-behavior: smooth;
}

html {
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   Auth stage (full-viewport background)
   ============================================================ */
.knet-stage {
  min-height: 100dvh;          /* dynamic viewport height — accounts for mobile browser chrome */
  min-height: 100vh;           /* fallback for older browsers */
  background: linear-gradient(160deg, var(--knet-bg) 0%, #ffffff 60%, var(--knet-bg-accent) 100%);
  position: relative;
  overflow-x: hidden;
}

/* Decorative blobs — clipped so they never cause horizontal scroll */
.knet-stage::before,
.knet-stage::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
.knet-stage::before {
  width: 280px; height: 280px;
  top: -90px; left: -90px;
  background: radial-gradient(circle, rgba(28,63,170,0.18), transparent 70%);
}
.knet-stage::after {
  width: 360px; height: 360px;
  bottom: -120px; right: -120px;
  background: radial-gradient(circle, rgba(59,130,246,0.25), transparent 70%);
}

/* ============================================================
   Auth wrapper — vertically + horizontally centred
   ============================================================ */
.knet-auth-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  min-height: 100vh;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
}

.knet-auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 24px 64px rgba(28, 63, 170, 0.18), 0 4px 16px rgba(0,0,0,0.08);
  overflow: hidden;
}

/* Gradient hero section at top of auth card */
.knet-auth-hero {
  background: linear-gradient(135deg, var(--knet-primary-dark) 0%, #1c3faa 55%, #2d5be3 100%);
  padding: 2.25rem 1.5rem 1.75rem;
}

/* Hero brand title letter-spacing scales down on small screens */
.knet-auth-hero .knet-brand-title,
.knet-auth-hero .fw-black {
  letter-spacing: clamp(1px, 2vw, 4px);
}

/* White form area */
.knet-auth-form-area {
  padding: 1.75rem 1.5rem 1.5rem;
}

/* OR divider */
.knet-auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #9ca3af;
  font-size: 0.8rem;
  margin: 0.5rem 0;
}
.knet-auth-divider::before,
.knet-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

/* ============================================================
   Brand mark
   ============================================================ */
.knet-brand-mark {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.35);
  color: #fff;
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.knet-brand-title {
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--knet-primary-dark);
  margin-bottom: 0.25rem;
  font-size: clamp(1.25rem, 5vw, 1.75rem);   /* scales smoothly between devices */
}

/* ============================================================
   Inputs
   ============================================================ */
.knet-input {
  border-radius: 14px;
  border: 1.5px solid #dde6f7;
  background: #f8faff;
  padding: 0.82rem 1rem 0.82rem 3rem;
  font-size: 0.95rem;
  color: #1e293b;
  box-shadow: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.knet-input:focus {
  background: #fff;
  border-color: var(--knet-primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  outline: none;
}
.knet-input-group { position: relative; }

/* Input icon — works for both <i> (original) and <svg> (injected by knet-icons.js) */
.knet-input-group i.input-icon,
.knet-input-group svg.input-icon {
  position: absolute;
  top: 50%; left: 0.9rem;
  transform: translateY(-50%);
  color: var(--knet-primary);
  stroke: var(--knet-primary);
  width: 1.15rem;
  height: 1.15rem;
  font-size: 1.15rem;
  z-index: 2;
  pointer-events: none;
}

/* Select dropdowns need same left padding as inputs */
select.knet-input {
  padding-left: 3rem;
}
/* Textarea variant */
textarea.knet-input {
  padding-top: 0.75rem;
  padding-left: 3rem;
  resize: vertical;
  min-height: 80px;
}

/* Form field labels */
.knet-field-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  margin-bottom: 0.35rem;
  display: block;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-knet-primary {
  background: linear-gradient(135deg, var(--knet-primary-dark), var(--knet-primary-light));
  color: #fff !important;
  font-weight: 700;
  letter-spacing: 1.5px;
  border: none;
  border-radius: 14px;
  padding: 0.82rem 1.5rem;
  box-shadow: 0 6px 20px rgba(28, 63, 170, 0.35);
  transition: filter .15s, box-shadow .15s;
  font-size: 0.9rem;
}
.btn-knet-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 8px 24px rgba(28, 63, 170, 0.45);
  color: #fff !important;
}

.btn-knet-outline {
  border: 1.5px solid var(--knet-primary);
  color: var(--knet-primary);
  background: #fff;
  border-radius: 14px;
  padding: 0.75rem 1.3rem;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background .15s, color .15s;
}
.btn-knet-outline:hover {
  background: var(--knet-primary);
  color: #fff;
}

/* ============================================================
   Passcode boxes — responsive
   ============================================================ */
.knet-passcode-row { display: flex; justify-content: center; gap: .75rem; }
.knet-passcode-box {
  width: clamp(48px, 14vw, 64px);
  height: clamp(48px, 14vw, 64px);
  border-radius: 14px;
  border: 2px solid var(--knet-primary-light);
  background: #fff;
  text-align: center;
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  box-shadow: var(--knet-soft-shadow);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

/* ============================================================
   Dashboard top bar
   ============================================================ */
.knet-topbar {
  background: linear-gradient(135deg, var(--knet-primary-dark) 0%, #1c3faa 60%, #2d5be3 100%);
  color: #fff;
  border-radius: 0 0 32px 32px;
  padding: 0.9rem 1.25rem 2.25rem;  /* enough for search bar to float over the bottom */
  box-shadow: 0 8px 24px rgba(28, 63, 170, 0.30);
}

.knet-search-bar {
  background: #fff;
  border-radius: 16px;
  padding: 0.45rem 0.45rem 0.45rem 1rem;
  margin-top: -26px;              /* floats over the rounded bottom of topbar */
  box-shadow: 0 4px 20px rgba(28, 63, 170, 0.18);
  display: flex;
  align-items: center;
  border: 1px solid #e8eef8;
}
.knet-search-bar input { border: none; outline: none; flex: 1; min-width: 0; font-size: 0.9rem; color: #374151; }
.knet-search-bar input::placeholder { color: #9ca3af; }
.knet-search-bar button {
  background: linear-gradient(135deg, var(--knet-primary-dark), var(--knet-primary-light));
  border: none; color: #fff;
  width: 40px; height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   AI banner
   ============================================================ */
.knet-ai-banner {
  background: linear-gradient(120deg, #2148c8, #4373ff);
  color: #fff;
  border-radius: var(--knet-radius);
  padding: 1.15rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--knet-shadow);
}
.knet-ai-banner h5 { margin-bottom: .25rem; font-weight: 700; }

/* ============================================================
   Tiles
   ============================================================ */
.knet-tile {
  background: #fff;
  border-radius: var(--knet-radius);
  padding: 1rem .6rem .8rem;
  text-align: center;
  border: 1px solid #dde6f7;
  box-shadow: 0 3px 14px rgba(28, 63, 170, 0.11), 0 1px 4px rgba(0,0,0,0.06);
  transition: transform .15s, box-shadow .15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  touch-action: manipulation;
}
.knet-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(28, 63, 170, 0.18), 0 2px 6px rgba(0,0,0,0.08);
  color: inherit;
}
.knet-tile .tile-icon {
  width: clamp(52px, 14vw, 64px);
  height: clamp(52px, 14vw, 64px);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: clamp(1.3rem, 4vw, 1.6rem);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
/* Inline SVG icons inside tile circles */
.knet-tile .tile-icon > svg {
  width: 1.75em;
  height: 1.75em;
  stroke: currentColor;
  fill: none;
  display: block;
  flex-shrink: 0;
}
/* Sidebar inline SVG icons */
.offcanvas-body a > span > svg {
  width: 1.1em;
  height: 1.1em;
  stroke: currentColor;
  fill: none;
  display: block;
}
.knet-tile .tile-title {
  font-weight: 700;
  font-size: clamp(0.7rem, 2.2vw, 0.85rem);
  color: #1e293b;
  margin-top: .4rem;
  line-height: 1.2;
}
.knet-tile .tile-sub { color: #6b7280; font-size: 0.72rem; margin-top: .15rem; }

/* ============================================================
   Dashboard layout
   ============================================================ */
.knet-dashboard { background: #eef1fb; }

/* Page wrap: leaves room at the bottom for the fixed nav bar */
.knet-page-wrap {
  min-height: 100dvh;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.knet-main-content { padding-top: 1.25rem; padding-bottom: 1.5rem; }

/* ============================================================
   Bottom nav — fixed to viewport bottom
   ============================================================ */
.knet-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #e3ebf6;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: .5rem 0 calc(.5rem + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(28,63,170,0.07);
  z-index: 1000;
}
.knet-bottom-nav a {
  flex: 1;
  text-align: center;
  color: #6b7280;
  text-decoration: none;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 0;
  touch-action: manipulation;
}
.knet-bottom-nav a i,
.knet-bottom-nav a svg { font-size: 1.25rem; width: 1.25rem; height: 1.25rem; }
.knet-bottom-nav a span { line-height: 1; }
.knet-bottom-nav a.active { color: var(--knet-primary); font-weight: 700; }

/* Center FAB (AI) button */
.knet-nav-fab { position: relative; }
.knet-nav-fab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  min-height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--knet-primary-dark), var(--knet-primary-light));
  color: #fff;
  font-size: 1.3rem;
  margin-top: -20px;
  box-shadow: var(--knet-shadow);
}

/* ============================================================
   Mobile chip (passcode login — shows verified number)
   ============================================================ */
.knet-mobile-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(28, 63, 170, .08);
  color: var(--knet-primary-dark);
  border: 1px solid rgba(28, 63, 170, .18);
  border-radius: 50px;
  padding: .4rem 1rem;
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: .5px;
}

/* ============================================================
   Verified banner (set_passcode / reset stage 3)
   ============================================================ */
.knet-verified-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--knet-radius);
  padding: .75rem 1rem;
}

/* ============================================================
   OTP-sent chip (reset stage 2)
   ============================================================ */
.knet-otp-sent-chip {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: rgba(28, 63, 170, .06);
  border: 1px solid rgba(28, 63, 170, .15);
  border-radius: var(--knet-radius);
  padding: .65rem 1rem;
  font-size: .875rem;
  color: #1e293b;
}

/* ============================================================
   Step progress indicator (reset_passcode)
   ============================================================ */
.knet-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.knet-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
}
.knet-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #fff;
  color: #94a3b8;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.knet-step.active .knet-step-dot {
  border-color: var(--knet-primary);
  background: var(--knet-primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(28, 63, 170, .15);
}
.knet-step.done .knet-step-dot {
  border-color: #22c55e;
  background: #22c55e;
  color: #fff;
}
.knet-step-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #94a3b8;
  white-space: nowrap;
}
.knet-step.active .knet-step-label { color: var(--knet-primary); }
.knet-step.done  .knet-step-label  { color: #22c55e; }

.knet-step-line {
  flex: 1;
  height: 2px;
  background: #e2e8f0;
  min-width: 28px;
  max-width: 56px;
  margin-bottom: 1.25rem;
  transition: background .2s;
}
.knet-step-line.done { background: #22c55e; }

/* ============================================================
   Responsive breakpoints
   ============================================================ */

/* Extra-small phones (< 400px) */
@media (max-width: 399px) {
  .knet-brand-mark {
    width: 64px;
    height: 64px;
    font-size: 26px;
  }
  .knet-auth-wrapper { padding: 1.25rem 0.75rem; }
  .knet-passcode-box { border-radius: 10px; }
  .btn-knet-primary { padding: 0.75rem 1.25rem; font-size: 0.95rem; }
  .knet-passcode-row { gap: .5rem; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
  .knet-auth-wrapper { align-items: flex-start; padding-top: 1rem; }
  .knet-brand-mark { width: 52px; height: 52px; font-size: 22px; }
  .knet-auth-card { max-width: 480px; }
  .knet-bottom-nav { padding: .25rem 0 calc(.25rem + env(safe-area-inset-bottom)); }
  .knet-nav-fab-btn { width: 38px; height: 38px; min-height: 38px; margin-top: -14px; font-size: 1.1rem; }
}

/* Large screens — wider card for comfortable reading */
@media (min-width: 768px) {
  .knet-auth-card { max-width: 480px; }
}

/* ============================================================
   Module tile gradient backgrounds (matches seed_rbac colors)
   ============================================================ */
.knet-grad-purple-pink  { background: linear-gradient(135deg, #7c3aed, #ec4899); }
.knet-grad-blue         { background: linear-gradient(135deg, #1c3faa, #3b82f6); }
.knet-grad-red-orange   { background: linear-gradient(135deg, #dc2626, #f97316); }
.knet-grad-green        { background: linear-gradient(135deg, #059669, #34d399); }
.knet-grad-orange       { background: linear-gradient(135deg, #d97706, #fbbf24); }
.knet-grad-magenta      { background: linear-gradient(135deg, #9d174d, #ec4899); }
.knet-grad-indigo-blue  { background: linear-gradient(135deg, #3730a3, #6366f1); }
.knet-grad-green-teal   { background: linear-gradient(135deg, #047857, #0d9488); }
.knet-grad-red-pink     { background: linear-gradient(135deg, #be123c, #f43f5e); }
.knet-grad-indigo       { background: linear-gradient(135deg, #4338ca, #818cf8); }
.knet-grad-teal         { background: linear-gradient(135deg, #0f766e, #2dd4bf); }
.knet-grad-blue-purple  { background: linear-gradient(135deg, #1d4ed8, #7c3aed); }
.knet-grad-amber        { background: linear-gradient(135deg, #b45309, #fcd34d); }
.knet-grad-slate        { background: linear-gradient(135deg, #334155, #64748b); }
.knet-grad-dark         { background: linear-gradient(135deg, #0f172a, #1e293b); }

/* ============================================================
   Topbar button icon alignment (SVG injected by knet-icons.js)
   ============================================================ */
.knet-topbar .btn svg,
.knet-topbar button svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke: #fff;
  display: block;
  margin: auto;
}

/* ============================================================
   Dashboard topbar — avatar online dot
   ============================================================ */
.knet-avatar-wrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.knet-avatar-wrap .online-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border: 2px solid var(--knet-primary-dark);
  border-radius: 50%;
}

/* ============================================================
   Section heading inside dashboard
   ============================================================ */
.knet-section-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #64748b;
  margin-bottom: 0.75rem;
}

/* ============================================================
   Quick actions strip
   ============================================================ */
.knet-quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
  touch-action: manipulation;
}
.knet-quick-action-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
}
.knet-quick-action-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60px;
}

/* ============================================================
   Dashboard cards — make them clearly visible on the bg
   ============================================================ */
.knet-dashboard .card {
  border: 1px solid #dde6f7 !important;
  box-shadow: 0 3px 14px rgba(28, 63, 170, 0.10), 0 1px 4px rgba(0,0,0,0.05) !important;
  border-radius: var(--knet-radius) !important;
}

/* ============================================================
   Promo banner
   ============================================================ */
.knet-promo-banner {
  background: linear-gradient(135deg, #1c3faa 0%, #3b82f6 60%, #7c3aed 100%);
  color: #fff;
  border-radius: var(--knet-radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--knet-shadow);
  overflow: hidden;
  position: relative;
}
.knet-promo-banner::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -30px;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

/* ============================================================
   Responsive tile grid tweak — 3-per-row on small phones
   ============================================================ */
@media (max-width: 360px) {
  .knet-tile { padding: .8rem .5rem; }
  .knet-tile .tile-cta { display: none; }
  .knet-topbar { padding: 0.75rem 1rem 2rem; }
  .knet-search-bar { margin-top: -22px; }
}
