/* Reset & base */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
  color: var(--text-primary);
  background: linear-gradient(135deg, #0d9488 0%, #14b8a6 50%, #06b6d4 100%);
  overflow-x: hidden;
  overflow-y: auto;
  /* avoid accidental horizontal scroll on small screens */
}

:root {
  --brand: #14b8a6;
  --brand-600: #0d9488;
  --brand-700: #0f766e;
  --brand-800: #115e59;
  --teal-light: #5eead4;
  --teal: #14b8a6;
  --teal-dark: #0d9488;
  --accent: #06b6d4;
  --muted: #64748b;
  --card: #ffffff;
  --border: #e2e8f0;
  --surface: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #475569;
}

.auth-wrapper {
  position: relative;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Define areas so we can swap columns on signup */
  grid-template-areas: 'visual form';
}

/* Visual Panel */
.panel.visual {
  position: relative;
  /* Use only the image, no overlays or colors */
  /* Use a relative path so it works when the app runs under /finmate/public */
  background-image: url('../images/finmate-auth.svg');
  /* Show the full image without cropping */
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  /* No fallback color to avoid colored sides */
  background-color: transparent;
  /* place in left column by default */
  grid-area: visual;
  color: #fff;
  display: grid;
  place-items: center;
  padding: 3rem;
}

.visual-inner {
  max-width: 520px;
  text-align: center;
}

.visual-inner h1 {
  font-size: 2rem;
  letter-spacing: 0.2px;
  margin: 0 0 0.5rem;
}

.visual-inner p {
  margin: 0 0 1.5rem;
  color: #e2e8f0;
}

/* Form Panel */
.panel.form-pane {
  display: grid;
  place-items: center;
  padding: 2rem;
  /* place in right column by default */
  grid-area: form;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
}

/* Smooth transition for swaps */
.panel {
  transition: transform .45s cubic-bezier(.22, .61, .36, 1), opacity .45s ease;
}

/* Two-phase animation: out (move away) then in (move in) */
/* Going to signup: image moves right, form moves left on OUT; after swap, they come back IN from those sides */
.auth-wrapper.animating.out.to-signup .panel.visual {
  transform: translateX(60%);
  opacity: 0;
}

.auth-wrapper.animating.out.to-signup .panel.form-pane {
  transform: translateX(-60%);
  opacity: 0;
}

.auth-wrapper.animating.in.to-signup .panel.visual {
  transform: translateX(60%);
  opacity: 0;
}

.auth-wrapper.animating.in.to-signup .panel.form-pane {
  transform: translateX(-60%);
  opacity: 0;
}

/* Going back to signin: reverse directions */
.auth-wrapper.animating.out.to-signin .panel.visual {
  transform: translateX(-60%);
  opacity: 0;
}

.auth-wrapper.animating.out.to-signin .panel.form-pane {
  transform: translateX(60%);
  opacity: 0;
}

.auth-wrapper.animating.in.to-signin .panel.visual {
  transform: translateX(-60%);
  opacity: 0;
}

.auth-wrapper.animating.in.to-signin .panel.form-pane {
  transform: translateX(60%);
  opacity: 0;
}

.form-card {
  width: min(500px, 92%);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.form-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--teal-dark) 0%, var(--brand) 50%, var(--accent) 100%);
}

.form-title {
  margin: .25rem 0 1.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--teal-dark) 0%, var(--brand) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  padding: 0.4rem;
  border-radius: 14px;
  position: relative;
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: .65rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  flex: 1;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}

.tab.active {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
  transform: translateY(-2px);
}

.field {
  display: grid;
  gap: .45rem;
  margin-bottom: 1rem;
}

.field.two-col {
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-primary);
}

input {
  outline: none;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: .75rem .9rem;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 500;
}

input::placeholder {
  color: #94a3b8;
}

/* Input with icon and actions */
.input-wrap {
  position: relative;
}

.input-wrap input {
  width: 100%;
  padding-left: 2.75rem;
  padding-right: 3.5rem;
  /* space for action button like show/hide */
}

.input-icon {
  position: absolute;
  left: .875rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  pointer-events: none;
  transition: all 0.3s ease;
}

.input-wrap:focus-within .input-icon svg {
  stroke: var(--brand);
}

.input-action {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: var(--surface);
  color: var(--brand);
  font-weight: 700;
  padding: .4rem .75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.input-action:hover {
  background: var(--brand);
  color: white;
  transform: translateY(-50%) scale(1.05);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  font-size: .95rem;
  color: var(--text-secondary);
  cursor: pointer;
}

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

.helper {
  font-size: .8rem;
  color: #64748b;
  margin: .1rem 0 0;
}

.error-msg {
  font-size: .85rem;
  color: #b91c1c;
  margin: .15rem 0 0;
}

input:focus {
  border-color: var(--brand);
  background: white;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.1),
    0 4px 12px rgba(20, 184, 166, 0.15);
  transform: translateY(-1px);
}

input:hover:not(:focus) {
  border-color: #cbd5e1;
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  margin-top: .5rem;
}

.actions.compact {
  margin-top: .3rem;
}

.alt {
  margin-top: .75rem;
  font-size: .9rem;
  color: var(--text-secondary);
  text-align: center;
}

.btn {
  cursor: pointer;
  border: 0;
  padding: .75rem 1.25rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.4);
}

.btn.primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.btn.primary:hover::before {
  left: 100%;
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(20, 184, 166, 0.5);
}

.btn.primary:active {
  transform: translateY(0);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .6);
  color: #fff;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, .12);
}

.btn.linklike {
  background: transparent;
  color: var(--brand);
  padding: 0;
  border-radius: 6px;
  font-weight: 600;
}

.btn.linklike:hover {
  color: var(--teal-dark);
  text-decoration: underline;
}

.link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  position: relative;
  transition: color 0.2s ease;
}

.link:hover {
  color: var(--teal-dark);
}

.link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 0.3s ease;
}

.link:hover::after {
  width: 100%;
}

/* Forms switching */
.form {
  display: none;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity .35s ease, transform .35s ease;
}

.form.active {
  display: block;
  opacity: 1;
  transform: translateX(0);
}

/* Slide animation between sides */
/* We’ll slide the visual panel horizontally by toggling a class on the wrapper */
.auth-wrapper {
  transition: all .6s cubic-bezier(.22, .61, .36, 1);
}

.auth-wrapper.signup-active {
  /* Keep equal halves on signup so the image appears centered in the right half */
  grid-template-columns: 1fr 1fr;
  /* Swap columns so the form is on the left, image on the right */
  grid-template-areas: 'form visual';
}

/* No transforms needed to swap; grid areas handle the position */

/* Responsive */
@media (max-width: 920px) {
  .auth-wrapper {
    grid-template-columns: 1fr;
    grid-template-areas: 'visual' 'form';
    height: auto;
    /* allow content to grow */
    min-height: 100dvh;
    /* modern viewport unit for mobile toolbars */
    overflow: visible;
    /* allow form to scroll if taller than viewport */
  }

  /* Ensure signup uses same order on mobile (image first, then form) */
  .auth-wrapper.signup-active {
    grid-template-columns: 1fr;
    grid-template-areas: 'visual' 'form';
  }

  .panel.visual {
    height: 35vh;
    /* slightly shorter to prioritize form space */
    padding: 1.25rem;
    /* lighter padding on small screens */
    background-size: contain;
  }

  .panel.form-pane {
    padding: 1rem;
    /* tighter padding on small screens */
  }

  .form-card {
    width: min(560px, 94%);
  }

  .field.two-col {
    grid-template-columns: 1fr;
    /* stack name fields vertically */
    gap: .75rem;
  }

  /* Stack primary action buttons; keep compact rows inline */
  .actions:not(.compact) {
    flex-direction: column;
    align-items: stretch;
    gap: .6rem;
  }

  .actions:not(.compact) .btn {
    width: 100%;
  }
}

/* Always keep the full image visible (no fixed sizes per breakpoint) */

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.35);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #0f172a;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

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

.modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  flex: 1;
}

.modal-body h3 {
  font-size: 1.1rem;
  color: #1e293b;
  margin: 1.5rem 0 0.75rem;
}

.modal-body h3:first-child {
  margin-top: 0.5rem;
}

.modal-body p {
  color: #475569;
  line-height: 1.6;
  margin: 0.5rem 0;
}

.modal-body ul {
  color: #475569;
  line-height: 1.6;
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.modal-body li {
  margin: 0.35rem 0;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  background: #f8fafc;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.modal-footer .btn {
  min-width: 160px;
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

@media (max-width: 640px) {
  .modal-content {
    max-height: 90vh;
    margin: 0.5rem;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1.25rem;
  }

  .modal-header h2 {
    font-size: 1.25rem;
  }
}