/* ==========================================================================
   LOGIN PAGE STYLES - REFINED & ANIMATED
   Premium Card-Based & Split-View Design
   ========================================================================== */

/* Base Reset for Login Page */
.login-page {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--color-bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden; /* Important for full screen canvas */
}

/* Background Animation Canvas - FIXED FULL SCREEN */
.interactive-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none; /* Let clicks pass through, JS handles interaction via mousemove */
  z-index: 0;
  opacity: 0.8;
}

/* Main Wrapper */
.login-wrapper {
  position: relative;
  z-index: 10;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: var(--spacing-6);
}

/* Theme Toggle */
.theme-toggle {
  position: absolute;
  top: var(--spacing-6);
  right: var(--spacing-6);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-primary);
  background: var(--color-bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
  color: var(--color-text-secondary);
  z-index: 50; /* Ensure on top */
  backdrop-filter: blur(8px);
}

.theme-toggle:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-border-secondary);
  color: var(--color-text-primary);
  transform: rotate(15deg);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-moon {
  display: none;
}
.theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}
[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

/* ==========================================================================
   VIEW 1: ROLE SELECTION SCREEN
   ========================================================================== */
.role-selection-container {
  width: 100%;
  max-width: 720px;
  text-align: center;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  transform: scale(1);
}

.role-selection-container.hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  display: none;
}

.welcome-header {
  margin-bottom: var(--spacing-10);
  animation: slideDown 0.6s ease-out;
}

.brand-logo {
  width: 72px;
  height: 72px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--spacing-6);
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

.brand-logo img {
  width: 55px;
  height: 55px;
  object-fit: contain;
}

.welcome-title {
  font-family: var(--font-primary);
  font-size: 3rem; /* 4xl */
  font-weight: 800; /* Extra Bold */
  color: var(--color-text-primary);
  margin: 0 0 var(--spacing-2);
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-size: 1.25rem; /* xl */
  color: var(--color-text-secondary);
  font-weight: 400;
}

/* Role Cards Grid */
.role-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-6);
  margin-bottom: var(--spacing-10);
  perspective: 1000px;
}

.role-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-2xl);
  padding: var(--spacing-8) var(--spacing-6);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-4);
  /* Glassmorphism Effect */
  background: rgba(
    var(--bg-secondary-rgb),
    0.7
  ); /* Needs RGB var or fallback */
  background: var(--color-bg-secondary); /* Fallback */
  backdrop-filter: blur(12px);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Stagger animations for cards */
.role-card:nth-child(1) {
  animation: fadeInUp 0.5s ease-out 0.1s backwards;
}
.role-card:nth-child(2) {
  animation: fadeInUp 0.5s ease-out 0.2s backwards;
}
.role-card:nth-child(3) {
  animation: fadeInUp 0.5s ease-out 0.3s backwards;
}

.role-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--card-color, var(--color-primary));
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.role-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at center,
    var(--card-bg-hover),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.role-card:hover::after {
  opacity: 1;
}

.role-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-tertiary);
  color: var(--card-color, var(--color-text-secondary));
  transition: all 0.3s ease;
  margin-bottom: var(--spacing-2);
  position: relative;
  z-index: 2;
}

.role-card:hover .role-icon {
  background: var(--card-color);
  color: white;
  transform: scale(1.1) rotate(3deg);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.role-icon svg {
  width: 40px;
  height: 40px;
}

.role-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
  position: relative;
  z-index: 2;
}

.role-desc {
  font-size: 0.875rem;
  color: var(--color-text-tertiary);
  margin: 0;
  line-height: var(--line-height-relaxed);
  position: relative;
  z-index: 2;
}

/* Card Specifics */
.role-card.manager {
  --card-color: #3b82f6;
  --card-bg-hover: rgba(59, 130, 246, 0.15);
}
.role-card.staff {
  --card-color: #f59e0b;
  --card-bg-hover: rgba(245, 158, 11, 0.15);
}
.role-card.customer {
  --card-color: #10b981;
  --card-bg-hover: rgba(16, 185, 129, 0.15);
}

/* System Login Link */
.system-login-link {
  margin-top: var(--spacing-8);
  padding-top: var(--spacing-6);
  border: none;
  animation: fadeIn 0.8s ease-out 0.4s backwards;
}

.btn-system {
  background: transparent;
  border: 1px solid var(--color-border-primary);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--spacing-2) var(--spacing-5);
  border-radius: var(--radius-full);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-2);
  backdrop-filter: blur(4px);
}

.btn-system:hover {
  color: var(--color-primary); /* Use primary color theme */
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   VIEW 2: SPLIT LOGIN CONTAINER
   ========================================================================== */
.login-split-container {
  display: flex;
  width: 100%;
  max-width: 800px; /* Wider for split view */
  height: 480px; /* Fixed height for consistency */
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-2xl);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-primary);

  /* Initial hidden state */
  display: none;
  opacity: 0;
  transform: scale(0.98) translateY(20px);
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-split-container.active {
  display: flex;
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Left Panel - Info/Art */
.split-info-side {
  flex: 0 0 320px;
  background: var(
    --side-gradient,
    linear-gradient(135deg, #0f172a 0%, #334155 100%)
  );
  position: relative;
  padding: var(--spacing-10);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  overflow: hidden;
}

/* Dynamic Gradients for Left Panel based on Role */
.split-info-side[data-role="manager"] {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}
.split-info-side[data-role="staff"] {
  background: linear-gradient(135deg, #7c2d12 0%, #d97706 100%);
}
.split-info-side[data-role="customer"] {
  background: linear-gradient(135deg, #064e3b 0%, #10b981 100%);
}
.split-info-side[data-role="kurtuba"] {
  background: linear-gradient(135deg, #312e81 0%, #6366f1 100%);
}

.split-info-content {
  position: relative;
  z-index: 2;
}

.info-icon-large {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--spacing-6);
  backdrop-filter: blur(8px);
}

.info-icon-large svg {
  width: 32px;
  height: 32px;
  color: white;
}

.info-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--spacing-4);
  line-height: 1.1;
}

.info-desc {
  font-size: 1rem;
  opacity: 0.9;
  line-height: 1.6;
}

/* Decorative Circles/Blobs in Left Panel */
.split-info-side::before,
.split-info-side::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  z-index: 1;
}

.split-info-side::before {
  width: 300px;
  height: 300px;
  top: -100px;
  right: -100px;
}

.split-info-side::after {
  width: 200px;
  height: 200px;
  bottom: -50px;
  left: -50px;
}

/* Back Button in Left Panel */
.btn-back-split {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: var(--spacing-2) var(--spacing-4);
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  width: fit-content;
  font-size: 0.875rem;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
  position: relative;
  z-index: 10;
}

.btn-back-split:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateX(-2px);
}

/* Right Panel - Form */
.split-form-side {
  flex: 1;
  padding: var(--spacing-10) var(--spacing-12);
  display: flex;
  align-items: center; /* Vertically center the form */
  justify-content: center;
  position: relative;
}

.login-form-wrapper {
  width: 100%;
  max-width: 360px;
}

/* Active Form Handling */
.login-form {
  display: none;
  animation: fadeInRight 0.5s ease-out;
}

.login-form.active {
  display: block;
}

/* Form Styles */
.form-header-minimal {
  margin-bottom: var(--spacing-8);
}

.form-header-minimal h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-1);
}

.form-header-minimal p {
  color: var(--color-text-tertiary);
  font-size: 0.9rem;
}

/* Enhanced Inputs */
.input-group-premium {
  margin-bottom: var(--spacing-5);
}

.input-group-premium label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-2);
}

/* Input Box - Position Relative for absolute toggle */
.input-box {
  position: relative;
  transition: all 0.2s ease;
}

.input-box input {
  width: 100%;
  padding: 12px 42px 12px 42px; /* Left padding for icon, Right for toggle */
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-lg);
  background: var(--color-bg-primary);
  font-size: 0.95rem;
  font-family: var(--font-primary);
  color: var(--color-text-primary);
  transition: all 0.2s ease;
  height: 50px;
}

/* Hide browser-native password reveal toggle (Edge, Chrome) */
.input-box input::-ms-reveal,
.input-box input::-ms-clear,
.input-box input::-webkit-credentials-auto-fill-button {
  display: none;
}

.input-box .field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  transition: color 0.2s ease;
  pointer-events: none;
}

.input-box input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
  background: var(--color-bg-secondary);
}

.input-box input:focus + .field-icon {
  color: var(--color-primary);
}

/* FIXED Password Toggle */
.toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px; /* Touch area */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.toggle-password:hover {
  color: var(--color-text-primary);
}

/* Remember Me Checkbox */
.form-options {
  margin-bottom: var(--spacing-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.remember-me {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-4);
  user-select: none;
}

.remember-me input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border: 1px solid var(--color-border-primary);
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* Submit Button Premium */
.btn-submit-premium {
  width: 100%;
  height: 52px;
  margin-top: var(--spacing-2);
  border: none;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 1rem;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  position: relative;
  overflow: hidden;
}

/* Button Colors per Role */
.btn-submit-premium.manager {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-submit-premium.staff {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.btn-submit-premium.customer {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-submit-premium.kurtuba {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-submit-premium:hover {
  transform: translateY(-2px);
  filter: brightness(110%);
}

.btn-submit-premium:active {
  transform: translateY(0);
}

/* Keyframes */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .login-split-container {
    flex-direction: column;
    max-width: 500px;
    height: auto;
  }

  .split-info-side {
    flex: 0 0 160px;
    padding: var(--spacing-6);
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-4);
  }

  .info-icon-large {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
  }

  .info-icon-large svg {
    width: 24px;
    height: 24px;
  }

  .split-info-content {
    flex: 1;
  }

  .info-title {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-1);
  }

  .info-desc {
    display: none; /* Hide desc on mobile split view to save space */
  }

  .btn-back-split {
    position: absolute;
    top: var(--spacing-4);
    right: var(--spacing-4);
  }

  .split-form-side {
    padding: var(--spacing-8) var(--spacing-6);
  }
}

@media (max-width: 640px) {
  .role-cards {
    grid-template-columns: 1fr;
  }

  .welcome-title {
    font-size: 2rem;
  }
}
