/* ============================================================
   klukvaCloud — Components
   Buttons, nav/header, footer, cards, badges, forms, toasts
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-snug);
  padding: 0.7rem 1.25rem;
  border-radius: var(--r-full); /* Pill buttons */
  border: 1px solid transparent;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-700); box-shadow: var(--shadow-md); }

.btn-ghost { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
.btn-ghost:hover { border-color: var(--text); background: var(--surface-2); }

.btn-quiet { color: var(--text-muted); }
.btn-quiet:hover { color: var(--text); background: var(--surface-2); }

.btn-inverse { background: var(--bg-inverse); color: var(--text-inverse); }
.btn-inverse:hover { opacity: 0.88; }

.btn-lg { padding: 0.95rem 1.75rem; font-size: var(--fs-base); }
.btn-sm { padding: 0.45rem 0.9rem; font-size: var(--fs-xs); }
.btn-block { width: 100%; }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: saturate(200%) blur(24px);
  backdrop-filter: saturate(200%) blur(24px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-base) var(--ease-out),
              background-color var(--dur-base) var(--ease-out);
}
.site-header.is-scrolled { border-bottom-color: var(--border); }

.nav {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.1rem; flex-wrap: nowrap; white-space: nowrap;
  letter-spacing: -0.05em;
}

.brand .mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--text-brand);
}
.brand .mark svg { width: 28px; height: 28px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  margin-inline: auto;
}
.nav-links a {
  padding: 0.5rem 0.85rem;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  transition: color var(--dur-fast), background-color var(--dur-fast);
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a.active { color: var(--text); }

.nav-actions { display: flex; align-items: center; gap: var(--sp-3); }

/* icon button (theme, lang, hamburger) */
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  color: var(--text-muted);
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* Language dropdown */
.lang {
  position: relative;
}
.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0.45rem 0.7rem;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
}
.lang-trigger:hover { background: var(--surface-2); color: var(--text); }
.lang-trigger svg { width: 18px; height: 18px; }
.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-2);
  z-index: var(--z-dropdown);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  max-height: 70vh;
  overflow-y: auto;
}
.lang.open .lang-menu { opacity: 1; transform: none; pointer-events: auto; }
.lang-menu button {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--text);
  transition: background-color var(--dur-fast);
}
.lang-menu button:hover { background: var(--surface-2); }
.lang-menu button[aria-current="true"] { color: var(--text-brand); font-weight: var(--fw-semibold); }
.lang-menu .flag { font-size: 1.1rem; line-height: 1; }
.lang-menu .native { color: var(--text-muted); margin-left: auto; font-size: var(--fs-xs); }

/* Hamburger */
.nav-toggle { display: none; }

@media (max-width: 900px) {
  .nav-links {
    position: fixed;
    inset: 64px 0 0 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-6);
    background: color-mix(in srgb, var(--bg) 95%, transparent);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: var(--sp-8) var(--gutter);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px) scale(0.98);
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    margin: 0;
    z-index: 99;
  }
  .nav-links.open { 
    opacity: 1; 
    pointer-events: auto; 
    transform: none; 
  }
  .nav-links a { 
    font-size: var(--fs-2xl); 
    font-family: "Outfit", "SF Pro Display", sans-serif; 
    font-weight: var(--fw-bold);
    color: var(--text);
  }
  .nav-links a:hover { color: var(--brand-500); }
  .nav-toggle { display: grid; z-index: 100; }
  .desktop-only { display: none !important; }
}
@media (min-width: 901px) {
  .mobile-only { display: none !important; }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding-block: var(--sp-8) var(--sp-6);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(4, 1fr);
  gap: var(--sp-6);
}
.footer-col h4 {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-subtle);
  margin-bottom: var(--sp-4);
}
.footer-col a {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding-block: var(--sp-2);
  transition: color var(--dur-fast);
}
.footer-col a:hover { color: var(--text); }
.footer-brand p { margin-top: var(--sp-3); max-width: 320px; font-size: var(--fs-sm); }
.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-top: var(--sp-7);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-subtle);
  flex-wrap: wrap;
}
.social { display: flex; gap: 0; }
.social a { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-full); color: var(--text-muted); }
.social a:hover { background: var(--surface-2); color: var(--text); }
.social svg { width: 18px; height: 18px; }

@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xs);
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
:root[data-theme="dark"] .card {
  background: var(--surface);
}
.card.hover:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-md), 0 10px 40px -10px color-mix(in srgb, var(--brand-500) 10%, transparent);
  border-color: var(--border-strong);
}
.card .card-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--brand-50);
  color: var(--brand-600);
  margin-bottom: var(--sp-4);
}
:root[data-theme="dark"] .card .card-icon { background: color-mix(in srgb, var(--brand-500) 18%, transparent); color: var(--brand-400); }
.card .card-icon svg { width: 22px; height: 22px; }
.card h3 { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.card p { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.brand { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.badge.success { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); border-color: transparent; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
:root[data-theme="dark"] .badge.brand { background: var(--brand-600); color: #fff; border-color: transparent; font-weight: var(--fw-semibold); }

/* ---------- Forms ---------- */
.field { display: block; }
.field + .field { margin-top: var(--sp-4); }
.field label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  margin-bottom: var(--sp-2);
  color: var(--text);
}
.control {
  width: 100%;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.control::placeholder { color: var(--text-subtle); }
.control:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 22%, transparent);
}
.control[aria-invalid="true"] { border-color: var(--danger); }
.field-hint { font-size: var(--fs-xs); color: var(--text-subtle); margin-top: var(--sp-2); }
.field-error {
  font-size: var(--fs-xs);
  color: var(--danger);
  margin-top: var(--sp-2);
  min-height: 1em;
}
.input-wrap { position: relative; }
.input-wrap .toggle-pw {
  position: absolute;
  right: 0.5rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  padding: 0.3rem;
  border-radius: var(--r-sm);
}
.input-wrap .toggle-pw:hover { color: var(--text); }
.input-wrap .control { padding-right: 2.75rem; }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--brand-600);
  flex-shrink: 0;
  cursor: pointer;
}

/* Password strength meter */
.pw-meter { display: flex; gap: 4px; margin-top: var(--sp-2); }
.pw-meter span {
  height: 4px; flex: 1;
  background: var(--border);
  border-radius: var(--r-full);
  transition: background-color var(--dur-fast);
}
.pw-meter[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] span:nth-child(-n+2) { background: var(--warning); }
.pw-meter[data-score="3"] span:nth-child(-n+3) { background: var(--info); }
.pw-meter[data-score="4"] span { background: var(--success); }

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: min(360px, calc(100vw - 2rem));
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--bg-inverse);
  color: var(--text-inverse);
  padding: 0.85rem 1.1rem;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  animation: toast-in var(--dur-base) var(--ease-out);
}
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Segmented control (billing toggle, view switch) ---------- */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 3px;
}
.seg button {
  padding: 0.5rem 1rem;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: background-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.seg svg { width: 18px; height: 18px; display: block; }

/* ---------- Cookie banner ---------- */
.cookie-banner {
  position: fixed;
  bottom: var(--sp-5);
  left: var(--sp-5);
  z-index: var(--z-overlay);
  max-width: min(420px, calc(100vw - 2rem));
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-5);
  transform: translateY(calc(100% + 2rem));
  transition: transform var(--dur-slow) var(--ease-out);
}
.cookie-banner.show { transform: none; }
.cookie-banner p { font-size: var(--fs-sm); color: var(--text-muted); }
.cookie-banner .cookie-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-4); }

@media (max-width: 560px) {
  .cookie-banner { left: var(--sp-4); right: var(--sp-4); max-width: none; }
  .toast-region { left: var(--sp-4); right: var(--sp-4); max-width: none; }
}

/* Helpers */
.ml-auto { margin-inline-start: auto; }
/* .btn svg margin removed for perfect flex centering */
