/* KachingSignals auth modal styles. All selectors prefixed .km- to
   avoid colliding with styles.css. */

.km-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 9000;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 2rem;
  overflow-y: auto;
  animation: km-fade-in 160ms ease-out;
}

.km-modal-backdrop.km-modal-open {
  display: flex;
}

.km-modal {
  background: #ffffff;
  border-radius: 10px;
  width: 100%;
  max-width: 460px;
  padding: 1.75rem 1.75rem 1.5rem;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: #1a1a1a;
  animation: km-slide-in 180ms ease-out;
}

.km-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: 0;
  font-size: 26px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.km-modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.km-modal h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: #0052cc;
}

.km-modal-sub {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.km-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.km-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}

.km-field input,
.km-field select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a1a;
  background: #ffffff;
  box-sizing: border-box;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.km-field input:focus,
.km-field select:focus {
  outline: none;
  border-color: #0052cc;
  box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.18);
}

.km-field-help {
  display: block;
  margin-top: 0.3rem;
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
}

.km-field-error input,
.km-field-error select {
  border-color: #ef4444;
}

.km-error {
  display: none;
  background: #fef2f2;
  color: #b91c1c;
  border-left: 3px solid #ef4444;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.km-error.km-show {
  display: block;
}

.km-success {
  display: none;
  background: #f0fdf4;
  color: #047857;
  border-left: 3px solid #10b981;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.km-success.km-show {
  display: block;
}

.km-submit {
  margin-top: 0.4rem;
  background: #0052cc;
  color: #ffffff;
  border: 0;
  border-radius: 5px;
  padding: 0.75rem 1rem;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 120ms ease, opacity 120ms ease;
}

.km-submit:hover {
  background: #003d99;
}

.km-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.km-modal-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: 13px;
  color: #475569;
}

.km-link {
  background: none;
  border: 0;
  color: #0052cc;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
}

.km-link:hover {
  color: #003d99;
}

.km-user-pill {
  font-size: 13px;
  color: #1a1a1a;
  background: #eef2ff;
  padding: 6px 10px;
  border-radius: 16px;
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.km-logout-btn {
  background: #ffffff;
  color: #0052cc;
  border: 1px solid #0052cc;
  padding: 6px 14px;
  border-radius: 5px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.km-logout-btn:hover {
  background: #0052cc;
  color: #ffffff;
}

@media (max-width: 520px) {
  .km-modal-backdrop {
    padding: 1.5rem 0.75rem;
  }
  .km-modal {
    max-width: 100%;
    padding: 1.5rem 1.25rem 1.25rem;
  }
  .km-modal h2 {
    font-size: 20px;
  }
}

@keyframes km-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes km-slide-in {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .km-modal-backdrop,
  .km-modal {
    animation: none;
  }
}
