/* ---------------------------------------------------------------------------
   KreditSol shared UI layer.

   Progressive enhancement only: every page works without this file, and nothing
   here changes page content. Loaded by all public pages plus the staff
   dashboard. Selectors are namespaced with `ks-` so they can't collide with the
   per-page styles, which are hand-written and vary a lot from page to page.
   --------------------------------------------------------------------------- */

:root {
  --ks-navy: #1F3A52;
  --ks-navy-deep: #16293A;
  --ks-gold: #C8A03C;
  --ks-line: rgba(255, 255, 255, .14);
  --ks-shadow: 0 8px 28px rgba(16, 32, 47, .18);
}

/* --- Skip to content ----------------------------------------------------- */
.ks-skip {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -120%);
  z-index: 10050;
  background: var(--ks-navy);
  color: #fff;
  padding: 10px 20px;
  border-radius: 0 0 8px 8px;
  font: 600 .9rem/1 system-ui, -apple-system, sans-serif;
  text-decoration: none;
  transition: transform .18s ease;
}
.ks-skip:focus {
  transform: translate(-50%, 0);
  outline: 3px solid var(--ks-gold);
  outline-offset: 2px;
}

/* --- Scroll progress ----------------------------------------------------- */
.ks-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--ks-gold), #E4C56B);
  z-index: 10040;
  transition: width .08s linear;
  pointer-events: none;
}

/* --- Sticky header ------------------------------------------------------- */
.ks-sticky {
  position: sticky;
  top: 0;
  z-index: 10020;
  transition: box-shadow .2s ease;
}
.ks-sticky.ks-stuck { box-shadow: 0 4px 18px rgba(16, 32, 47, .22); }

/* --- Injected site nav --------------------------------------------------- */
.ks-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.ks-nav a {
  color: var(--ks-fg, inherit);
  opacity: .82;
  text-decoration: none;
  font: 600 .82rem/1 system-ui, -apple-system, sans-serif;
  padding: 7px 11px;
  border-radius: 7px;
  transition: background .15s ease, opacity .15s ease;
}
.ks-nav a:hover,
.ks-nav a:focus-visible { opacity: 1; background: rgba(255, 255, 255, .12); }
.ks-nav a[aria-current="page"] { opacity: 1; box-shadow: inset 0 -2px 0 var(--ks-gold); }

.ks-burger {
  display: none;
  background: transparent;
  border: 1px solid var(--ks-line);
  color: var(--ks-fg, inherit);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.ks-burger:hover { background: rgba(255, 255, 255, .12); }

@media (max-width: 760px) {
  .ks-burger { display: inline-flex; margin-top: 10px; }
  .ks-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    width: 100%;
    border-top: 1px solid var(--ks-line);
    padding-top: 10px;
  }
  .ks-nav.ks-open { display: flex; }
  .ks-nav a { padding: 11px 6px; font-size: .92rem; }
}

/* --- Floating buttons ---------------------------------------------------- */
.ks-fab {
  position: fixed;
  right: 18px;
  z-index: 10030;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--ks-shadow);
  font: 600 .9rem/1 system-ui, -apple-system, sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .15s ease, opacity .2s ease, background .15s ease;
}
.ks-fab:hover { transform: translateY(-2px); }
.ks-fab:focus-visible { outline: 3px solid var(--ks-gold); outline-offset: 3px; }

.ks-top {
  bottom: 18px;
  width: 44px;
  height: 44px;
  justify-content: center;
  background: var(--ks-navy);
  color: #fff;
  font-size: 1.1rem;
  opacity: 0;
  visibility: hidden;
}
.ks-top.ks-show { opacity: 1; visibility: visible; }

.ks-contact {
  bottom: 74px;
  padding: 12px 18px;
  background: var(--ks-gold);
  color: var(--ks-navy-deep);
  text-decoration: none;
}

@media print { .ks-fab, .ks-progress, .ks-skip, .ks-cookie, .ks-search-btn { display: none !important; } }

/* --- Search -------------------------------------------------------------- */
.ks-search-btn {
  background: transparent;
  border: 1px solid var(--ks-line);
  color: var(--ks-fg, inherit);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  font: 600 .82rem/1 system-ui, -apple-system, sans-serif;
  transition: background .15s ease;
}
.ks-search-btn:hover { background: rgba(255, 255, 255, .12); }

.ks-modal {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
  background: rgba(12, 22, 33, .55);
  backdrop-filter: blur(3px);
}
.ks-modal.ks-open { display: flex; }
.ks-modal-card {
  background: #fff;
  color: #17222C;
  width: min(560px, 100%);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(9, 18, 27, .35);
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
  animation: ks-rise .16s ease-out;
}
@keyframes ks-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .ks-modal-card { animation: none; }
  .ks-fab, .ks-progress, .ks-skip { transition: none; }
}

.ks-search-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #E3E8ED;
  padding: 17px 18px;
  font-size: 1rem;
  outline: none;
  font-family: inherit;
}
.ks-results { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
.ks-results li a {
  display: block;
  padding: 11px 13px;
  border-radius: 8px;
  color: #17222C;
  text-decoration: none;
}
.ks-results li a:hover,
.ks-results li a:focus-visible,
.ks-results li.ks-cur a { background: #F1F5F8; outline: none; }
.ks-results .ks-r-title { display: block; font-weight: 700; font-size: .93rem; }
.ks-results .ks-r-desc { display: block; font-size: .82rem; color: #5B6B79; margin-top: 2px; }
.ks-empty { padding: 20px 18px; color: #5B6B79; font-size: .9rem; }

/* --- Confirm modal ------------------------------------------------------- */
.ks-confirm-body { padding: 22px 24px 6px; }
.ks-confirm-title { font-weight: 700; font-size: 1.05rem; margin: 0 0 8px; }
.ks-confirm-text { margin: 0; color: #4A5A68; font-size: .93rem; line-height: 1.55; }
.ks-confirm-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 18px 24px 22px; }
.ks-btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font: 600 .9rem/1 system-ui, -apple-system, sans-serif;
  cursor: pointer;
  transition: filter .15s ease, background .15s ease;
}
.ks-btn:hover { filter: brightness(1.07); }
.ks-btn:focus-visible { outline: 3px solid var(--ks-gold); outline-offset: 2px; }
.ks-btn-primary { background: var(--ks-navy); color: #fff; }
.ks-btn-danger { background: #B3261E; color: #fff; }
.ks-btn-ghost { background: #EDF1F4; color: #33424F; }

/* --- Cookie banner ------------------------------------------------------- */
.ks-cookie {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 10035;
  background: var(--ks-navy-deep);
  color: #E7EDF2;
  border: 1px solid var(--ks-line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--ks-shadow);
  font: 400 .86rem/1.5 system-ui, -apple-system, sans-serif;
  max-width: 720px;
  margin: 0 auto;
}
.ks-cookie p { margin: 0; flex: 1 1 280px; }

/* --- Password visibility -------------------------------------------------- */
.ks-pw-wrap { position: relative; display: block; }
.ks-pw-wrap .ks-pw-toggle {
  /* Two classes so page rules like `.auth-box button` lose. Every box property
     is stated because those rules set width, background and padding. */
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 6px;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 6px;
  color: inherit;
  font-size: .95rem;
  line-height: 1;
  letter-spacing: normal;
  opacity: .65;
  cursor: pointer;
}
.ks-pw-wrap .ks-pw-toggle:hover { opacity: 1; background: rgba(127, 127, 127, .14); }
.ks-pw-wrap .ks-pw-toggle:focus-visible { outline: 2px solid var(--ks-gold); opacity: 1; }

/* --- Copy to clipboard ---------------------------------------------------- */
.ks-copy {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  opacity: .7;
  border-radius: 6px;
  padding: 3px 8px;
  margin-left: 8px;
  font: 600 .72rem/1.35 system-ui, -apple-system, sans-serif;
  cursor: pointer;
  vertical-align: middle;
  transition: opacity .15s ease, background .15s ease;
}
.ks-copy:hover { opacity: 1; background: rgba(127, 127, 127, .14); }
.ks-copy.ks-copied { opacity: 1; border-color: #1D7A4C; color: #1D7A4C; }

/* --- FAQ accordion -------------------------------------------------------- */
.ks-faq { border-bottom: 1px solid rgba(127, 127, 127, .22); }
.ks-faq-q {
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 2px;
  cursor: pointer;
  font: 700 .97rem/1.45 inherit;
  color: inherit;
}
.ks-faq-q:hover { opacity: .78; }
.ks-faq-q:focus-visible { outline: 2px solid var(--ks-gold); outline-offset: 2px; }
.ks-faq-mark { flex: none; transition: transform .2s ease; opacity: .6; }
.ks-faq-q[aria-expanded="true"] .ks-faq-mark { transform: rotate(45deg); }
.ks-faq-a { padding: 0 2px 18px; line-height: 1.6; opacity: .88; }
.ks-faq-a[hidden] { display: none; }

/* --- Loading -------------------------------------------------------------- */
.ks-spin {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ks-spin .7s linear infinite;
  vertical-align: -.12em;
}
@keyframes ks-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ks-spin { animation-duration: 2s; } }

.ks-busy { position: relative; pointer-events: none; opacity: .72; }

/* Every button and link-button gets a visible hover and focus state. Kept to
   opacity/shadow so it layers over each page's own button colours instead of
   overriding them. */
button:not(.ks-faq-q):not(.ks-copy):not(.ks-pw-toggle),
input[type="submit"],
input[type="button"],
a[class*="btn"],
a[class*="cta"] {
  transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
}
button:not(:disabled):not(.ks-faq-q):not(.ks-copy):not(.ks-pw-toggle):hover,
input[type="submit"]:not(:disabled):hover,
input[type="button"]:not(:disabled):hover,
a[class*="btn"]:hover,
a[class*="cta"]:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
button:disabled { cursor: not-allowed; filter: grayscale(.4); opacity: .65; }
:focus-visible { outline: 3px solid var(--ks-gold); outline-offset: 2px; }

/* --- Print ---------------------------------------------------------------- */
@media print {
  @page { margin: 16mm; }
  body { background: #fff !important; color: #000 !important; }
  header, .hero { background: #fff !important; color: #000 !important; }
  nav, .ks-nav, .ks-burger, video, iframe { display: none !important; }
  a[href^="http"]::after,
  a[href^="/"]::after {
    content: " (" attr(href) ")";
    font-size: .8em;
    color: #444;
    word-break: break-all;
  }
  a[href^="#"]::after { content: ""; }
  .ks-faq-a[hidden] { display: block !important; }
  h1, h2, h3 { break-after: avoid-page; }
  img, table, figure, .card { break-inside: avoid; }
}

@media (max-width: 760px) {
  body { padding-bottom: 104px; }
  .ks-contact { padding: 10px 14px; font-size: .82rem; }
  .ks-top { width: 40px; height: 40px; }
}

/* --- Theme toggle --------------------------------------------------------- */
.ks-theme-btn {
  background: transparent;
  border: 1px solid var(--ks-line);
  color: var(--ks-fg, inherit);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  margin-left: 6px;
  transition: background .15s ease;
}
.ks-theme-btn:hover { background: rgba(127, 127, 127, .18); }
.ks-theme-float {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 10031;
  background: var(--ks-navy);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--ks-shadow);
}
@media print { .ks-theme-btn { display: none !important; } }
