/**
 * Tamkeen System - Unified Authentication Stylesheet
 * Standardized across Admin, Customer Service (CS), and Marketer Portals
 */

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

:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --focus-ring: rgba(59, 130, 246, 0.15);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --radius-card: 18px;
  --radius-input: 11px;
}

/* ── Theme: Admin Portal (Blue) ── */
body.theme-admin {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --border-focus: #3b82f6;
  --focus-ring: rgba(59, 130, 246, 0.15);
  background: radial-gradient(circle at 50% 0%, #edf2f7 0%, #f8fafc 100%);
}

body.theme-admin .brand-icon {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
}

body.theme-admin .btn-submit {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

body.theme-admin .btn-submit:hover:not(:disabled) {
  background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.32);
}

/* ── Theme: Customer Service Portal (Teal) ── */
body.theme-cs {
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-soft: #f0fdfa;
  --primary-border: #99f6e4;
  --border-focus: #0d9488;
  --focus-ring: rgba(13, 148, 136, 0.18);
  background: radial-gradient(circle at 50% 0%, #ecfeff 0%, #f0fdfa 40%, #f8fafc 100%);
}

body.theme-cs .brand-icon {
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.22);
}

body.theme-cs .btn-submit {
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.25);
}

body.theme-cs .btn-submit:hover:not(:disabled) {
  background: linear-gradient(135deg, #115e59 0%, #0f766e 100%);
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.32);
}

/* ── Theme: Marketer Portal (Indigo) ── */
body.theme-marketer {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-border: #c7d2fe;
  --border-focus: #4f46e5;
  --focus-ring: rgba(79, 70, 229, 0.16);
  background: radial-gradient(circle at 50% 0%, #eef2ff 0%, #f8fafc 100%);
}

body.theme-marketer .brand-icon {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.22);
}

body.theme-marketer .btn-submit {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

body.theme-marketer .btn-submit:hover:not(:disabled) {
  background: linear-gradient(135deg, #3730a3 0%, #4338ca 100%);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.32);
}

/* ── Global Layout ── */
html {
  height: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  -webkit-font-smoothing: antialiased;
}

.page-wrapper {
  width: 100%;
  max-width: 410px;
  margin: auto 0;
  padding: 10px 0;
}

/* ── Brand Header ── */
.brand-section {
  text-align: center;
  margin-bottom: 22px;
}

.brand-icon-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 12px;
}

.brand-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 10px;
  border-radius: 15px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition: transform 0.2s ease;
}

.brand-icon svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 8px;
}

.brand-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
}

.brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.brand-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Login Card ── */
.login-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 28px 24px;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
}

.card-header {
  margin-bottom: 20px;
  text-align: right;
}

.card-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Alerts ── */
.alert-box {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-input);
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 18px;
  line-height: 1.45;
  animation: alertFadeIn 0.2s ease-out;
}

@keyframes alertFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-box.show {
  display: flex;
}

.alert-box.error {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.alert-box.success {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.alert-box svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  fill: currentColor;
}

/* ── Form Controls ── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 7px;
}

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

.form-input {
  width: 100%;
  padding: 12px 42px 12px 42px;
  background-color: #fafbfc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: 16px; /* Prevents auto-zoom on iOS Safari */
  color: var(--text-main);
  font-weight: 600;
  outline: none;
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

.form-input::placeholder {
  color: var(--text-subtle);
  font-size: 0.85rem;
  font-weight: 500;
}

.form-input:focus {
  background-color: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3.5px var(--focus-ring);
}

.input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s;
}

.input-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.input-wrap:focus-within .input-icon {
  color: var(--primary);
}

.btn-toggle-password {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-subtle);
  padding: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  transition: color 0.15s, background-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-toggle-password:hover {
  color: var(--text-main);
  background-color: #f1f5f9;
}

.btn-toggle-password svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── Submit Button & Loader ── */
.btn-submit {
  width: 100%;
  margin-top: 8px;
  padding: 13px 20px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-input);
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-submit:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}

.btn-submit svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

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

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

/* ── Footers & Security Badges ── */
.security-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-subtle);
}

.security-badge svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.page-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-subtle);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 14px;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--primary);
}

/* ── Mobile Optimization ── */
@media (max-width: 480px) {
  body {
    padding: 14px 12px;
  }

  .login-card {
    padding: 22px 18px;
  }

  .brand-name {
    font-size: 1.25rem;
  }
}
