/* style.css - NexusERP World-Class Login — Windows 11 Inspired + Premium Glass */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700&family=Outfit:wght@300;400;500;600&display=swap');

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --blue-dark: #1d4ed8;
  --purple: #7c3aed;
  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-card: rgba(255, 255, 255, 0.92);
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --error: #ef4444;
  --success: #10b981;
  --input-border: #e2e8f0;
  --input-focus: #3b82f6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.25);
  --shadow-card: 0 32px 80px rgba(15,23,42,0.2), 0 0 0 1px rgba(255,255,255,0.5) inset;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --transition: cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  font-family: 'Tajawal', 'Outfit', system-ui, sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  direction: rtl;
  overflow: hidden;
}

/* ─── ANIMATED BACKGROUND ─── */
.erp-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, #0a0f1e 0%, #0d1b3e 30%, #1a0b3e 65%, #0f1a2e 100%);
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: orbFloat 12s ease-in-out infinite;
}

.orb-1 {
  width: 600px;
  height: 600px;
  top: -200px;
  left: -150px;
  background: radial-gradient(circle, rgba(59,130,246,0.35) 0%, transparent 70%);
  animation-delay: 0s;
}

.orb-2 {
  width: 500px;
  height: 500px;
  bottom: -150px;
  right: -100px;
  background: radial-gradient(circle, rgba(124,58,237,0.3) 0%, transparent 70%);
  animation-delay: -4s;
}

.orb-3 {
  width: 400px;
  height: 400px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(16,185,129,0.15) 0%, transparent 70%);
  animation-delay: -8s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

.bg-noise {
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ─── CONTAINER ─── */
.login-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 420px;
  animation: cardEntrance 0.7s var(--transition) both;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(32px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ─── CARD ─── */
.login-card {
  background: var(--glass-card);
  border-radius: var(--radius);
  padding: 36px 36px 24px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  border: 1px solid rgba(255,255,255,0.6);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.4s var(--transition), transform 0.4s var(--transition);
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
}

.login-card:hover {
  box-shadow: 0 40px 100px rgba(15,23,42,0.28), 0 0 0 1px rgba(255,255,255,0.55) inset;
  transform: translateY(-2px);
}

/* Shake animation */
.shake {
  animation: cardShake 0.4s var(--transition);
}

@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

/* ─── BRAND HEADER ─── */
.brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  animation: fadeUp 0.5s var(--transition) 0.1s both;
}

.brand-logo {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(59,130,246,0.5));
  animation: eyePulse 4s ease-in-out infinite;
}

.eye-logo-svg {
  width: 100%;
  height: 100%;
}

@keyframes eyePulse {
  0%, 100% { filter: drop-shadow(0 4px 12px rgba(59,130,246,0.5)); }
  50% { filter: drop-shadow(0 4px 20px rgba(124,58,237,0.7)) drop-shadow(0 0 8px rgba(59,130,246,0.4)); }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-tagline {
  font-family: 'Outfit', sans-serif;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

.card-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--input-border), transparent);
  margin-bottom: 24px;
  animation: fadeUp 0.5s var(--transition) 0.15s both;
}

/* ─── AVATAR ─── */
.avatar-section {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  animation: fadeUp 0.5s var(--transition) 0.2s both;
}

.avatar-ring {
  position: relative;
  width: 88px;
  height: 88px;
}

.avatar-ring-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #3b82f6, #7c3aed, #10b981, #3b82f6);
  animation: ringRotate 3s linear infinite;
  opacity: 0.7;
}

@keyframes ringRotate {
  to { transform: rotate(360deg); }
}

.avatar-ring::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--glass-card);
  z-index: 1;
}

.user-avatar {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  overflow: hidden;
  z-index: 2;
  background: #f1f5f9;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--transition);
}

.user-avatar:hover img {
  transform: scale(1.05);
}

/* ─── USER INFO ─── */
.selected-user-info {
  text-align: center;
  margin-bottom: 8px;
  animation: fadeUp 0.3s var(--transition) both;
}

.selected-username {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.change-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.2);
  color: var(--blue);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 20px;
  transition: all 0.2s var(--transition);
}

.change-user-btn:hover {
  background: rgba(59,130,246,0.15);
  border-color: rgba(59,130,246,0.4);
  transform: scale(1.02);
}

/* ─── LOGIN HEADER ─── */
.login-header {
  text-align: center;
  margin-bottom: 28px;
  animation: fadeUp 0.5s var(--transition) 0.25s both;
}

.login-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.login-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ─── FORM ─── */
.login-form {
  animation: fadeUp 0.5s var(--transition) 0.3s both;
}

.form-group {
  margin-bottom: 20px;
  position: relative;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  z-index: 4;
  transition: color 0.2s var(--transition);
  display: flex;
  align-items: center;
}

.input-wrapper input {
  width: 100%;
  background: #f8fafc;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 14px 46px 14px 48px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--text-primary);
  outline: none;
  transition: all 0.25s var(--transition);
  position: relative;
  z-index: 3;
}

.input-wrapper input::placeholder {
  color: transparent;
}

.input-wrapper input:focus {
  background: #fff;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12), 0 2px 8px rgba(59,130,246,0.08);
}

.input-wrapper input:focus + label,
.input-wrapper input:not(:placeholder-shown) + label {
  transform: translateY(-22px) scale(0.78);
  color: var(--input-focus);
  font-weight: 600;
  right: 14px;
}

.input-wrapper label {
  position: absolute;
  right: 46px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9375rem;
  font-weight: 400;
  pointer-events: none;
  transition: all 0.2s var(--transition);
  transform-origin: right center;
  z-index: 4;
  background: transparent;
  padding: 0 4px;
}

.input-wrapper input:focus ~ .input-focus-line,
.input-wrapper input:not(:placeholder-shown) ~ .input-focus-line {
  width: calc(100% - 24px);
  opacity: 1;
}

.input-focus-line {
  position: absolute;
  bottom: 10px;
  right: 12px;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  border-radius: 2px;
  opacity: 0;
  transition: all 0.3s var(--transition);
  pointer-events: none;
  z-index: 5;
}

.input-wrapper input:focus ~ .input-icon,
.input-wrapper:focus-within .input-icon {
  color: var(--blue);
}

/* Next button */
.next-btn {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  border: none;
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--transition);
  z-index: 10;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
}

.next-btn:hover {
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(59,130,246,0.5);
}

/* Password wrapper */
.password-wrapper input {
  padding-right: 16px;
  padding-left: 48px;
}

.password-wrapper label {
  right: 16px !important;
}

.password-wrapper input:focus + label,
.password-wrapper input:not(:placeholder-shown) + label {
  right: 16px !important;
}

.password-toggle {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--transition);
  z-index: 10;
  color: var(--text-muted);
}

.password-toggle:hover {
  background: rgba(59,130,246,0.08);
  color: var(--blue);
}

.toggle-icon {
  display: block;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='1.5'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'/%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z'/%3e%3c/svg%3e");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: background-image 0.2s ease;
}

.password-toggle:hover .toggle-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%233b82f6' stroke-width='1.5'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'/%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z'/%3e%3c/svg%3e");
}

.toggle-icon.show-password {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='1.5'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 11-4.243-4.243m4.242 4.242L9.88 9.88'/%3e%3c/svg%3e");
}

/* ─── ERROR MESSAGES ─── */
.error-message {
  display: block;
  color: var(--error);
  font-size: 0.775rem;
  font-weight: 500;
  margin-top: 6px;
  padding-right: 4px;
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.2s var(--transition);
  min-height: 0;
}

.error-message.show {
  opacity: 1;
  transform: translateY(0);
}

.form-group.error .input-wrapper input {
  border-color: var(--error);
  background: #fff5f5;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.general-error {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-xs);
  color: #b91c1c;
  font-size: 0.8375rem;
  font-weight: 500;
  text-align: center;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: none;
  animation: errorSlide 0.3s var(--transition) both;
}

.general-error.show {
  display: block;
}

@keyframes errorSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── LOGIN BUTTON ─── */
.login-btn {
  position: relative;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0;
  height: 52px;
  cursor: pointer;
  overflow: hidden;
  margin-bottom: 20px;
  transition: transform 0.2s var(--transition), box-shadow 0.2s var(--transition);
  box-shadow: 0 4px 16px rgba(59,130,246,0.35);
}

.btn-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 50%, #4f46e5 100%);
  transition: opacity 0.2s;
}

.btn-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.5s var(--transition);
  pointer-events: none;
}

.login-btn:hover .btn-shine {
  left: 120%;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(59,130,246,0.45);
}

.login-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.btn-text {
  position: relative;
  z-index: 2;
  color: white;
  font-family: 'Tajawal', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: opacity 0.2s;
}

.btn-arrow {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  opacity: 0;
  transition: all 0.2s var(--transition);
}

.login-btn:hover .btn-arrow {
  opacity: 0.7;
  left: 14px;
}

.btn-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.loader-circle {
  width: 24px;
  height: 24px;
  animation: rotate 1.4s linear infinite;
}

.loader-path {
  animation: loaderDash 1.4s ease-in-out infinite;
}

@keyframes rotate {
  100% { transform: rotate(360deg); }
}

@keyframes loaderDash {
  0% { stroke-dasharray: 1, 88; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 60, 88; stroke-dashoffset: -20; }
  100% { stroke-dasharray: 60, 88; stroke-dashoffset: -88; }
}

.login-btn.loading .btn-text,
.login-btn.loading .btn-arrow {
  opacity: 0;
}

.login-btn.loading .btn-loader {
  opacity: 1;
}

/* ─── SUCCESS ─── */
.success-message {
  display: none;
  text-align: center;
  padding: 8px 0 12px;
  animation: fadeUp 0.4s var(--transition) both;
}

.success-message.show {
  display: block;
}

.success-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.success-ring {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: 16px;
}

.success-ring::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #10b981, #34d399, #10b981);
  animation: ringRotate 2s linear infinite;
  opacity: 0.5;
}

.success-ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--glass-card);
  z-index: 1;
}

.success-icon {
  position: absolute;
  inset: 6px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 4px 16px rgba(16,185,129,0.4);
  animation: successPop 0.4s var(--transition) 0.1s both;
}

@keyframes successPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.success-message h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.success-message p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.success-progress {
  width: 100%;
  max-width: 200px;
  height: 3px;
  background: var(--input-border);
  border-radius: 3px;
  overflow: hidden;
}

.success-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #3b82f6);
  border-radius: 3px;
  animation: progressFill 2s var(--transition) both;
}

@keyframes progressFill {
  from { width: 0; }
  to { width: 100%; }
}

/* ─── FOOTER ─── */
.card-footer {
  display: flex;
  justify-content: center;
  animation: fadeUp 0.5s var(--transition) 0.35s both;
}

.footer-secure {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.footer-secure svg {
  color: var(--success);
  flex-shrink: 0;
}

/* ─── UTILITIES ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 480px) {
  body { padding: 16px; }
  .login-card { padding: 28px 24px 20px; }
  .login-header h2 { font-size: 1.3rem; }
  .avatar-ring { width: 76px; height: 76px; }
}

@media (max-height: 700px) {
  .login-card { padding: 24px 28px 18px; }
  .avatar-section { margin-bottom: 10px; }
  .login-header { margin-bottom: 18px; }
  .form-group { margin-bottom: 14px; }
}

@supports (-webkit-touch-callout: none) {
  input, button { font-size: 16px !important; }
}

@media (hover: none) and (pointer: coarse) {
  .next-btn:hover,
  .change-user-btn:hover,
  .password-toggle:hover,
  .login-btn:hover {
    transform: none;
    box-shadow: 0 4px 16px rgba(59,130,246,0.35);
  }
}