/* ==========================================================
   Cloud Calling CRM — Login Module
   Brief: white bg, primary blue #2563EB, 10px radius, soft shadow
   Mode:  PWA-first — native-app feel on mobile, browser feel on desktop
   ========================================================== */

:root {
  --color-bg: #ffffff;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4fd1;
  --color-primary-soft: #eaf1ff;
  --color-ink: #101828;
  --color-muted: #667085;
  --color-line: #e4e7ec;
  --color-danger: #d92d20;
  --color-danger-soft: #fef3f2;
  --color-success: #067647;

  --radius-card: 10px;
  --radius-input: 10px;
  --radius-btn: 10px;

  --shadow-soft: 0 2px 8px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.08);

  --font-display: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-ink);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input {
  font-family: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ----------------------------------------------------------
   Background stage (desktop/browser mode signature element)
   A quiet "signal" motif — concentric call-wave rings behind
   the card — nods to the product without shouting about it.
   Hidden entirely in standalone/app mode & on small screens.
---------------------------------------------------------- */
.stage {
  min-height: 100dvh;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.stage__waves {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.stage__waves svg { width: 100%; height: 100%; }

/* ----------------------------------------------------------
   Card
---------------------------------------------------------- */
.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--color-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: 36px 32px 28px;
}

.card__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 22px;
}

.card__logo-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
}

.card__logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 14px;
  position: relative;
  z-index: 1;
}

.card__logo-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  border: 1.5px solid var(--color-primary);
  opacity: 0;
  animation: pulse-ring 2.6s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { transform: scale(0.92); opacity: 0.55; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

.card__title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--color-ink);
}

.card__subtitle {
  font-size: 13px;
  color: var(--color-muted);
  margin: 0;
  line-height: 1.5;
}

/* ----------------------------------------------------------
   Form
---------------------------------------------------------- */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ink);
  margin-bottom: 6px;
}

.field__control {
  position: relative;
}

.field__control input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-input);
  outline: none;
  background: #fff;
  color: var(--color-ink);
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
}

.field__control input::placeholder { color: #98a2b3; }

.field__control input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3.5px var(--color-primary-soft);
}

.field__control input[aria-invalid="true"] {
  border-color: var(--color-danger);
}
.field__control input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3.5px var(--color-danger-soft);
}

.field--password .field__control input {
  padding-right: 42px;
}

.eye-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  border-radius: 8px;
}
.eye-toggle:hover { background: #f2f4f7; color: var(--color-ink); }
.eye-toggle svg { width: 19px; height: 19px; }

.field-error {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--color-danger);
  margin-top: 6px;
}
.field-error.is-visible { display: flex; }

.field-error svg { width: 14px; height: 14px; flex: none; }

/* ----------------------------------------------------------
   Row: remember me + forgot password
---------------------------------------------------------- */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--color-ink);
  user-select: none;
  cursor: pointer;
}

.remember input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.forgot-link {
  font-size: 13.5px;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.forgot-link:hover { text-decoration: underline; }

/* ----------------------------------------------------------
   Alert banner (invalid login etc.)
---------------------------------------------------------- */
.alert {
  display: none;
  align-items: flex-start;
  gap: 8px;
  background: var(--color-danger-soft);
  border: 1px solid #fda29b;
  color: #912018;
  border-radius: var(--radius-input);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.45;
}
.alert.is-visible { display: flex; }
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ----------------------------------------------------------
   Submit button
---------------------------------------------------------- */
.btn-submit {
  width: 100%;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s ease, transform .05s ease;
}
.btn-submit:hover { background: var(--color-primary-dark); }
.btn-submit:active { transform: scale(0.98); }
.btn-submit:disabled { opacity: 0.75; cursor: progress; }

.spinner {
  width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  animation: spin 0.7s linear infinite;
}
.btn-submit.is-loading .spinner { display: inline-block; }
.btn-submit.is-loading .btn-submit__label { opacity: 0.85; }

@keyframes spin { to { transform: rotate(360deg); } }

.card__footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: #98a2b3;
}

/* ============================================================
   MOBILE / APP MODE
   Full-height, edge-to-edge, no visible card chrome —
   feels like a native app screen, not a webpage.
   ============================================================ */
@media (max-width: 640px) {
  .stage {
    padding: 0;
    align-items: stretch;
  }
  .stage__waves { display: none; }

  .card {
    max-width: none;
    width: 100%;
    min-height: 100dvh;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: calc(28px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  }

  .card__brand { margin-bottom: 28px; }
  .card__logo-wrap { width: 72px; height: 72px; }
  .card__title { font-size: 23px; }

  .form-row { margin-bottom: 24px; }

  .btn-submit { padding: 15px 16px; font-size: 16px; }
}

/* When launched from home screen (standalone/PWA) give a touch
   more top breathing room since there's no browser UI at all. */
@media all and (display-mode: standalone), (display-mode: fullscreen) {
  .card { padding-top: calc(36px + var(--safe-top)); }
}

/* ============================================================
   DESKTOP / BROWSER MODE
   Centered card, visible shadow — reads like a normal website.
   ============================================================ */
@media (min-width: 641px) {
  .stage {
    background: linear-gradient(180deg, #fbfcff 0%, #ffffff 55%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card__logo-pulse { animation: none; }
  .spinner { animation: spin 1.4s linear infinite; }
}

@media (max-width: 360px) {
  .card { padding-left: 18px; padding-right: 18px; }
}
