/* حلول كاريو — Login Modal */

:root {
  --ink-950: #070b14;
  --ink-900: #0c1220;
  --ink-800: #141c2e;
  --ink-700: #1c2740;
  --paper: #eef1f4;
  --paper-elevated: #ffffff;
  --copper: #d4895a;
  --copper-deep: #b86d3f;
  --text: #121826;
  --text-muted: #5b657a;
  --text-faint: #8b93a7;
  --border: #e2e6ef;
  --border-focus: #d4895a;
  --danger: #c45c5c;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-modal: 28px;
  --shadow-modal: 0 22px 60px rgba(18, 24, 38, 0.12), 0 6px 18px rgba(18, 24, 38, 0.06);
  --font-ar: "Cairo", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --visual-bg: #8fd0ef;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ar);
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body::-webkit-scrollbar {
  display: none;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

/* ========== Centered modal on solid backdrop ========== */
.auth-stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2rem);
  background: var(--paper);
}

.auth-stack {
  --side: min(500px, calc((100vw - 2.5rem) / 2));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.15rem;
  width: calc(var(--side) * 2);
}

.auth-modal {
  --modal-h: min(640px, calc(100vh - 7.5rem), calc(100dvh - 7.5rem));
  direction: ltr;
  width: 100%;
  height: var(--modal-h);
  display: grid;
  grid-template-columns: var(--side) var(--side);
  align-items: stretch;
  background: var(--paper-elevated);
  border-radius: var(--radius-modal);
  overflow: hidden;
  box-shadow: var(--shadow-modal);
  border: 1px solid rgba(255, 255, 255, 0.9);
  animation: modal-in 0.55s var(--ease) both;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Left: image fills full modal height */
.auth-modal__visual {
  position: relative;
  width: var(--side);
  height: 100%;
  background: var(--visual-bg);
  overflow: hidden;
}

.auth-modal__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

/* Right: Wiso-style form */
.auth-modal__form {
  direction: rtl;
  display: flex;
  flex-direction: column;
  width: var(--side);
  height: 100%;
  padding: clamp(1.1rem, 2.2vw, 1.65rem) clamp(1.25rem, 2.8vw, 2rem);
  background: #fff;
  min-height: 0;
  overflow: hidden;
}

.form-top {
  flex-shrink: 0;
}

.form-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-left: 0.1rem;
  margin-top: 0.1rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.form-body::-webkit-scrollbar {
  display: none;
}

.form-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.4rem;
}

.form-logo img {
  width: min(140px, 48%);
  height: auto;
  display: block;
  object-fit: contain;
  background: transparent;
}

.form-title {
  margin: 0 0 0.85rem;
  text-align: center;
  font-size: clamp(1.15rem, 1.8vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink-900);
}

.btn-google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 0.88rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}

.btn-google__icon {
  font-size: 1.35rem;
  line-height: 1;
  color: #4285f4;
}

.btn-google:hover {
  border-color: #c9d0df;
  background: #fafbfd;
  transform: translateY(-1px);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0.85rem 0;
  color: var(--text-faint);
  font-size: 0.8rem;
  font-weight: 600;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Tabs */
.mode-toggle {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.28rem;
  margin-bottom: 0.9rem;
  background: #eef1f6;
  border-radius: 999px;
}

.mode-toggle__btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  padding: 0.62rem 0.5rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.25s var(--ease);
}

.mode-toggle__btn.is-active {
  color: var(--ink-900);
}

.mode-toggle__pill {
  position: absolute;
  top: 0.28rem;
  bottom: 0.28rem;
  width: calc(50% - 0.28rem);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(18, 24, 38, 0.08);
  transition: transform 0.35s var(--ease);
  right: 0.28rem;
  left: auto;
  transform: translateX(0);
}

.mode-toggle[data-active="signup"] .mode-toggle__pill {
  transform: translateX(-100%);
}

/* Forms */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 0.95rem;
}

.auth-form.is-active {
  display: flex;
  animation: form-fade 0.3s var(--ease);
}

@keyframes form-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-800);
}

.field input,
.field select {
  width: 100%;
  padding: 0.88rem 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
}

.field input::placeholder {
  color: #a3abc0;
}

.field input:hover,
.field select:hover {
  border-color: #cdd3e1;
}

.field input:focus,
.field select:focus {
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(212, 137, 90, 0.15);
}

.field.has-error input,
.field.has-error select {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(196, 92, 92, 0.12);
}

.field-error {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--danger);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-left: 2.7rem;
}

.toggle-password {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--text-faint);
  padding: 0.35rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.toggle-password:hover {
  color: var(--ink-700);
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  left: 1rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.field select {
  appearance: none;
  cursor: pointer;
  padding-left: 2.4rem;
}

.field select:invalid {
  color: #a3abc0;
}

.field select option {
  color: var(--text);
}

.site-rights {
  margin: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text-muted);
  direction: rtl;
}

.site-rights span:last-child {
  direction: ltr;
  font-family: var(--font-ar);
  font-weight: 500;
  color: var(--text-faint);
}

.btn-primary {
  margin-top: 0.15rem;
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  padding: 0.95rem 1rem;
  background: linear-gradient(135deg, var(--ink-800) 0%, var(--ink-950) 55%, #152038 100%);
  color: #fff;
  font-weight: 800;
  font-size: 0.96rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(12, 18, 32, 0.22);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s;
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(240, 164, 106, 0.22) 50%, transparent 70%);
  transform: translateX(120%);
  transition: transform 0.55s var(--ease);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(12, 18, 32, 0.3);
  filter: brightness(1.05);
}

.btn-primary:hover::after {
  transform: translateX(-120%);
}

.forgot-link {
  display: block;
  text-align: center;
  margin-top: 0.1rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--copper-deep);
  text-decoration: none;
  transition: color 0.2s;
}

.forgot-link:hover {
  color: var(--copper);
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink-900);
  color: #fff;
  padding: 0.85rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 16px 40px rgba(7, 11, 20, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  z-index: 50;
  max-width: calc(100% - 2rem);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 900px) {
  .auth-stack {
    --side: min(520px, calc(100vw - 1.5rem));
    width: var(--side);
  }

  .auth-modal {
    --modal-h: auto;
    width: 100%;
    height: auto;
    grid-template-columns: 1fr;
  }

  .auth-modal__visual {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
    max-height: 240px;
  }

  .auth-modal__form {
    width: 100%;
    height: auto;
    max-height: none;
    min-height: auto;
    overflow: visible;
  }

  .form-body {
    overflow: visible;
  }

  .form-logo img {
    width: min(150px, 58%);
  }
}

@media (max-width: 480px) {
  .auth-stage {
    padding: 0.75rem;
  }

  .auth-modal {
    border-radius: 20px;
  }

  .auth-modal__visual {
    max-height: 200px;
  }

  .auth-modal__form {
    padding: 1rem 1.05rem 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
