@import url('/css/fonts.css');

:root {
  --ink: #14213d;
  --ink-light: #1f3060;
  --parchment: #f7f4ec;
  --gold: #c9974b;
  --gold-bright: #e0ac5c;
  --slate: #6b7280;
  --line: rgba(20, 33, 61, 0.12);
  --error: #b3492f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--ui-font, 'Cairo', sans-serif);
  background: var(--parchment);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
}

/* === لوحة تسجيل الدخول === */
.identity-panel {
  flex: 1.1;
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-light) 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px;
  color: var(--parchment);
}

.identity-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.08;
}

.grid-accent {
  position: absolute;
  bottom: -80px;
  inset-inline-end: -80px;
  width: 340px;
  height: 340px;
  border: 1px solid rgba(224, 172, 92, 0.25);
  border-radius: var(--radius-round);
}
.grid-accent::after {
  content: '';
  position: absolute;
  inset: 40px;
  border: 1px solid rgba(224, 172, 92, 0.2);
  border-radius: var(--radius-round);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 1;
}

.brand-mark .glyph {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--gold-bright);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ui-font-heading, 'Zain', sans-serif);
  font-weight: 800;
  font-size: var(--font-size-3xl);
  color: var(--gold-bright);
}

.brand-mark .glyph-icon {
  border: 0;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.brand-mark span.name {
  font-family: var(--ui-font-heading, 'Zain', sans-serif);
  font-weight: 700;
  font-size: var(--font-size-3xl);
  letter-spacing: 0.5px;
}

.identity-copy {
  z-index: 1;
  max-width: 420px;
}

.identity-copy .eyebrow {
  color: var(--gold-bright);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 18px;
  display: block;
}

.identity-copy h1 {
  font-family: var(--ui-font-heading, 'Zain', sans-serif);
  font-weight: 800;
  font-size: var(--font-size-8xl);
  line-height: 1.35;
  margin-bottom: 18px;
}

.identity-copy p {
  color: rgba(247, 244, 236, 0.7);
  font-size: var(--font-size-lg);
  line-height: 1.8;
}

.role-strip {
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.role-chip {
  border: 1px solid rgba(247, 244, 236, 0.18);
  color: rgba(247, 244, 236, 0.85);
  font-size: var(--font-size-sm);
  padding: 7px 14px;
  border-radius: var(--radius-pill);
}

/* === لوحة تسجيل الدخول === */
.form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.form-card {
  width: 100%;
  max-width: 380px;
}

/* إشعار التشغيل التجريبي أعلى نموذج الدخول */
.beta-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 22px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--ink);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.7;
}
.beta-note-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 0.6em;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 25%, transparent);
}
.beta-note a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.beta-note a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.form-card h2 {
  font-family: var(--ui-font-heading, 'Zain', sans-serif);
  font-weight: 700;
  font-size: var(--font-size-6xl);
  margin-bottom: 6px;
}

.form-card .sub {
  color: var(--slate);
  font-size: var(--font-size-md);
  margin-bottom: 36px;
}

.field {
  margin-bottom: 20px;
}

/* نفس قاعدة app.css - عنوان الحقل فقط (label بلا صنف)، حتى لا ينهار أي مكوّن
   مكتوب كـ label داخل .field مثل صف "تذكّرني". */
.field label:not([class]) {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--ink-light);
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  font-family: var(--ui-font, 'Cairo', sans-serif);
  font-size: var(--font-size-lg);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--gold);
}

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

.field select {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  font-family: var(--ui-font, 'Cairo', sans-serif);
  font-size: var(--font-size-lg);
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")
    no-repeat left 14px center;
  padding-inline-end: 40px;
  color: var(--ink);
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

html[dir='ltr'] .field select {
  background-position: right 14px center;
}

.field select:focus {
  outline: none;
  border-color: var(--gold);
}

.field-hint {
  margin-top: 8px;
  color: var(--slate);
  font-size: var(--font-size-xs);
  line-height: 1.65;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  font-size: var(--font-size-sm);
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--slate);
}

.forgot {
  color: var(--ink-light);
  text-decoration: none;
  font-weight: 600;
}
.forgot:hover {
  color: var(--gold);
}

.btn-login {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--ink-light), var(--ink));
  color: var(--parchment);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--ui-font, 'Cairo', sans-serif);
  font-weight: 700;
  font-size: var(--font-size-lg);
  cursor: pointer;
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.error-msg {
  background: rgba(179, 73, 47, 0.08);
  border: 1px solid rgba(179, 73, 47, 0.25);
  color: var(--error);
  font-size: var(--font-size-md);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: none;
}

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

.footnote {
  text-align: center;
  margin-top: 28px;
  font-size: var(--font-size-sm);
  color: #a1a6b2;
}

@media (max-width: 860px) {
  .identity-panel {
    display: none;
  }
}

/* ==== مودال نسيت كلمة المرور ==== */
.forgot-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 33, 61, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.forgot-overlay.show {
  display: flex;
}

.forgot-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
}
.forgot-box h3 {
  font-family: var(--ui-font-heading, 'Zain', sans-serif);
  font-weight: 700;
  font-size: var(--font-size-3xl);
  margin-bottom: 8px;
  color: var(--ink);
}
.forgot-hint {
  font-size: var(--font-size-sm);
  color: var(--slate);
  margin-bottom: 16px;
  line-height: 1.6;
}
.forgot-box input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  font-family: var(--ui-font, 'Cairo', sans-serif);
  font-size: var(--font-size-md);
  margin-bottom: 14px;
}
.forgot-box input:focus {
  outline: none;
  border-color: var(--gold);
}

#forgotResult {
  font-size: var(--font-size-sm);
  line-height: 1.7;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: none;
}
#forgotResult.show {
  display: block;
  background: rgba(20, 33, 61, 0.04);
}
#forgotResult a {
  color: var(--ink);
  font-weight: 700;
  word-break: break-all;
}

.forgot-actions {
  display: flex;
  gap: 10px;
}
.forgot-cancel {
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: var(--ui-font, 'Cairo', sans-serif);
  font-weight: 700;
  font-size: var(--font-size-md);
  cursor: pointer;
  color: var(--ink);
  flex: 1;
}

/* Semantic tokens for this module; original layout and print rules retained. */
@media screen {
  html[data-appearance-shape] .field input {
    background: var(--panel);
  }
  html[data-appearance-shape] .field input::placeholder {
    color: var(--slate);
  }
  html[data-appearance-shape] .footnote {
    color: var(--slate);
  }
  html[data-appearance-shape] .forgot-box {
    background: var(--panel);
  }
}

/* Selectable local artwork with a stable, readable text scrim. */
html[data-login-background][data-appearance-shape] .identity-panel {
  background-image: linear-gradient(
      180deg,
      rgba(8, 18, 38, 0.18) 0%,
      rgba(8, 18, 38, 0.2) 25%,
      rgba(8, 18, 38, 0.62) 48%,
      rgba(8, 18, 38, 0.85) 100%
    ),
    var(--login-art);
  background-size: cover;
  background-position: center;
  color: #fff;
  isolation: isolate;
}
html[data-login-background] .identity-copy h1,
html[data-login-background] .brand-mark {
  color: #fff;
}
html[data-login-background] .identity-copy p {
  color: #f0f3fa;
}
html[data-login-background] .identity-copy .eyebrow {
  color: #ffe2a4;
}
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: var(--font-size-sm);
  margin-bottom: 16px;
}
.invite-steps {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 12px 0 20px;
  font-size: var(--font-size-xs);
  color: var(--slate);
}
.invite-steps li {
  border-bottom: 3px solid var(--line);
  padding: 8px 2px;
  flex: 1;
}
.invite-steps li[aria-current='step'] {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}
.invite-secondary {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  font: inherit;
  cursor: pointer;
}
.invite-success {
  padding: 22px;
  background: var(--success-soft);
  border: 1px solid var(--success);
  border-radius: var(--radius-card);
  line-height: 1.9;
}
.auth-page [hidden] {
  display: none !important;
}
/* Password rules shown while typing on the invitation page. */
.pw-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.pw-rules li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border, #d9e1e9);
  color: var(--slate);
  font-size: 0.8rem;
}
.pw-rules li::before {
  content: '○';
  font-size: 0.75em;
}
.pw-rules li.met {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--text, #17324d);
}
.pw-rules li.met::before {
  content: '✓';
  color: var(--success);
  font-weight: 800;
}
.invite-login-name {
  margin: 4px 0 0;
  font-weight: 700;
}
@media (min-width: 861px) and (max-height: 850px) {
  .auth-page .form-panel {
    padding: 22px 32px;
  }
  .auth-page .form-card .sub {
    margin-bottom: 16px;
  }
  .auth-page .field {
    margin-bottom: 12px;
  }
  .auth-page .field input {
    padding: 10px 13px;
  }
  .auth-page .footnote {
    margin-top: 14px;
  }
  .auth-page .invite-steps {
    margin: 4px 0 12px;
  }
}
@media (max-width: 480px) {
  .auth-page .form-panel {
    padding: 20px;
  }
  .appearance-pack-grid {
    grid-template-columns: 1fr;
  }
}

html[data-login-background]:not([data-login-background='plain']) .identity-panel::before,
html[data-login-background]:not([data-login-background='plain']) .grid-accent {
  display: none;
}

/* Fit ordinary short screens while keeping inputs, hints and actions readable. */
@media screen and (max-height: 850px) {
  html[data-appearance-shape] body.auth-page .form-panel {
    padding-block: 12px;
  }
  html[data-appearance-shape] body.auth-page .form-card {
    padding: 16px 22px;
  }
  html[data-appearance-shape] body.auth-page .form-card .sub {
    margin-bottom: 10px;
  }
  html[data-appearance-shape] body.auth-page .field {
    margin-bottom: 8px;
  }
  html[data-appearance-shape] body.auth-page .field label:not([class]) {
    margin-bottom: 4px;
  }
  html[data-appearance-shape] body.auth-page .field input,
  html[data-appearance-shape] body.auth-page .field select {
    padding: 8px 13px;
    min-height: 44px;
  }
  html[data-appearance-shape] body.auth-page .field select {
    padding-inline-end: 40px;
  }
  html[data-appearance-shape] body.auth-page .field-hint {
    margin-top: 4px;
    line-height: 1.5;
  }
  html[data-appearance-shape] body.auth-page .row-between {
    margin-bottom: 10px;
    min-height: 32px;
  }
  html[data-appearance-shape] body.auth-page .btn-login {
    padding-block: 8px;
    min-height: 44px;
  }
  html[data-appearance-shape] body.auth-page .footnote {
    margin-top: 8px;
  }
  html[data-appearance-shape] body.auth-page .form-card > .ajyal-locale-control {
    padding-block: 0;
    margin-bottom: 8px;
  }
  html[data-appearance-shape] body.auth-page .ajyal-locale-control select {
    width: auto;
    flex: 0 1 auto;
  }
  html[data-appearance-shape] body.auth-page .ajyal-locale-control small:empty {
    display: none;
  }
  html[data-appearance-shape] body.auth-page .platform-auth-controls {
    margin-top: 8px;
    padding-block: 4px;
  }
}
@media screen and (min-width: 861px) and (max-height: 700px) {
  html[data-appearance-shape] body.auth-page .form-panel {
    padding-block: 8px;
  }
  html[data-appearance-shape] body.auth-page .form-card {
    max-width: 480px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
  }
  html[data-appearance-shape] body.auth-page .auth-card-heading {
    grid-column: 1;
    min-width: 0;
    margin-bottom: 8px;
  }
  html[data-appearance-shape] body.auth-page .form-card > .ajyal-locale-control {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 8px;
    padding-inline: 0;
  }
  html[data-appearance-shape] body.auth-page .ajyal-locale-control label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  html[data-appearance-shape] body.auth-page .ajyal-locale-control select {
    width: 112px;
  }
  html[data-appearance-shape] body.auth-page .ajyal-locale-control:has(small:not(:empty)) {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  html[data-appearance-shape] body.auth-page .form-card > :not(.auth-card-heading):not(.ajyal-locale-control) {
    grid-column: 1 / -1;
  }
}

/* On short desktop screens tighten vertical rhythm (not touch targets: inputs and the sign-in
   button keep 44px) so the whole sign-in card fits a 1280×600 window without scrolling. */
@media screen and (min-width: 861px) and (max-height: 700px) {
  html[data-appearance-shape] body.auth-page .form-card {
    padding-block: 12px;
  }
  html[data-appearance-shape] body.auth-page .form-card .sub {
    margin-bottom: 6px;
  }
  html[data-appearance-shape] body.auth-page .field {
    margin-bottom: 6px;
  }
  html[data-appearance-shape] body.auth-page .field label:not([class]) {
    margin-bottom: 2px;
  }
  html[data-appearance-shape] body.auth-page .field-hint {
    margin-top: 2px;
  }
  html[data-appearance-shape] body.auth-page .row-between {
    margin-bottom: 6px;
  }
  html[data-appearance-shape] body.auth-page .footnote {
    margin-top: 4px;
  }
  html[data-appearance-shape] body.auth-page .platform-auth-controls {
    margin-top: 6px;
    padding-block: 0;
  }
  html[data-appearance-shape] body.auth-page .platform-auth-controls .platform-launcher {
    min-height: 40px;
    padding-block: 6px;
  }
  html[data-appearance-shape] body.auth-page .form-card > .entry-page-help:not([open]) {
    margin-block: 6px 0;
    padding: 6px 12px;
  }
}

@media screen and (max-height: 760px) {
  .beta-note {
    margin-bottom: 12px;
    padding: 7px 12px;
  }
}
