:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #b91c1c;
  --shadow-card: 0 20px 45px -15px rgba(15, 23, 42, 0.12), 0 4px 12px -4px rgba(15, 23, 42, 0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  font-family: "Cairo", "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  overscroll-behavior: none;
}

.login-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(circle at 15% 15%, rgba(37, 99, 235, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(22, 163, 74, 0.08) 0%, transparent 45%),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow-card);
}

.brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
}

.brand-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--accent-soft);
  border: 1px solid #dbeafe;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.brand-icon svg {
  width: 30px;
  height: 30px;
}

.brand-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.brand-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form.shake {
  animation: shakeForm 0.36s ease;
}

@keyframes shakeForm {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  right: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.field-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 42px 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input.has-toggle {
  padding-left: 48px;
}

.field-input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.btn-eye {
  position: absolute;
  left: 4px;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
}

.btn-eye:active {
  background: #e2e8f0;
}

.btn-eye svg {
  width: 20px;
  height: 20px;
}

.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.remember-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.remember-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.error-box {
  display: none;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.error-box.visible {
  display: block;
}

.btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  border: none;
  border-radius: 14px;
  background: var(--accent-blue);
  color: #ffffff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.btn-submit:hover {
  background: var(--accent-blue-hover);
}

.btn-submit:active {
  transform: scale(0.985);
}

.btn-submit:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: none;
}

.spinner.visible {
  display: inline-block;
}

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

.login-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
