/* ============================================
   MOBILE OPTIMIZATION & PERFORMANCE CSS
   Add this to the END of your registerAndLogin.CSS
   ============================================ */

/* 1. VIEWPORT & BASE OPTIMIZATIONS */
html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;
  /* Smooth scrolling but only where needed */
  scroll-behavior: smooth;
  /* GPU acceleration for smoother animations */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 2. MOBILE-FIRST RESPONSIVE BREAKPOINTS */

/* Large phones and small tablets (up to 640px) */
@media (max-width: 640px) {
  body {
    padding: 0;
    min-height: 100dvh; /* Use dynamic viewport height for mobile browsers */
    display: block;
    background: linear-gradient(135deg, #071a02 0%, #240d4e 100%);
  }

  .frame {
    width: 100%;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    border: none;
    display: flex;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
    display: flex;
    flex-direction: column;
  }

  /* Hide illustration panel on small phones to focus on form */
  .art {
    display: none; /* Remove on very small screens for UX */
  }

  /* Alternative: Show compact header instead of full art */
  .art::before {
    content: "سيلفا";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    background: linear-gradient(135deg, #4c1d95, #6d28d9);
    color: white;
    font-size: 24px;
    font-weight: 800;
    font-family: 'Cairo', sans-serif;
    width: 100%;
    position: static;
  }

  .panel {
    padding: 24px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 40px;
  }

  .form {
    max-width: 100%;
    width: 100%;
  }

  h1 {
    font-size: 26px;
    margin-bottom: 24px;
    text-align: center;
  }

  .input {
    height: 52px; /* Larger touch target */
    font-size: 16px; /* Prevent zoom on iOS */
    margin-bottom: 16px;
    border-radius: 12px;
  }

  /* Fix for iOS input zoom */
  @supports (-webkit-touch-callout: none) {
    .input {
      font-size: 16px !important;
    }
  }

  .label {
    font-size: 14px;
    margin-bottom: 6px;
    color: #1f2937;
  }

  .row {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    margin: 0 0 20px 0;
  }

  .check {
    font-size: 14px;
    order: 2; /* Move checkbox below forgot password on mobile */
  }

  .link {
    font-size: 14px;
    align-self: flex-end;
    order: 1;
  }

  .btn {
    height: 52px; /* Larger touch target */
    font-size: 16px;
    border-radius: 12px;
    /* Hardware acceleration */
    transform: translateZ(0);
    will-change: transform;
  }

  .btn-ghost {
    height: 52px;
    font-size: 15px;
  }

  .divider {
    margin: 20px 0;
  }

  .bottom {
    font-size: 14px;
    margin-top: auto; /* Push to bottom */
    padding-bottom: 20px;
  }

  /* Reposition worker button for mobile */
  .worker-login-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100; /* لضمان ظهوره فوق الرسمة والمحتوى */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

  .worker-login-btn:hover {
    transform: translateX(-50%) translateY(-2px);
  }

  /* Password visibility button larger for touch */
  .eye-btn {
    width: 44px;
    height: 44px;
    left: 4px;
    opacity: 0.7;
  }

  .eye-icon {
    width: 22px;
    height: 22px;
  }

  .pass-wrap .input {
    padding-left: 50px;
  }
}

/* 3. TABLET OPTIMIZATION (641px - 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
  body {
    padding: 20px;
    background: linear-gradient(135deg, #071a02 0%, #240d4e 100%);
  }

  .frame {
    width: 100%;
    max-width: 900px;
    border-radius: 24px;
    min-height: auto;
  }

  .layout {
    grid-template-columns: 1fr 1fr;
    min-height: 600px;
  }

  .art {
    padding: 30px;
    position: relative;
  }

  /* Simplify 3D grid on tablet for performance */
  .art #isometric-grid {
    transform: scale(0.8);
  }

  .panel {
    padding: 40px 30px;
  }

  h1 {
    font-size: 28px;
  }

  .input {
    height: 48px;
  }

  .btn {
    height: 48px;
  }
}

/* 4. PERFORMANCE OPTIMIZATIONS - GPU ACCELERATION */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .cube-wrapper {
    transition: none !important;
  }
}

/* Optimize animations for mobile */
@media (max-width: 1024px) {
  /* Disable complex 3D animations on mobile for battery/performance */
  .grid-container {
    display: none !important; /* Hide heavy 3D grid on mobile */
  }

  /* Simpler background animation replacement */
  .art {
    background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 50%, #240d4e 100%);
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
  }

  @keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }

  /* Optimize button interactions */
  .btn, .btn-ghost, .worker-login-btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
  }

  .btn:active, .btn-ghost:active {
    transform: scale(0.98);
  }

  /* Remove heavy shadows on mobile for performance */
  .btn {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }

  .btn:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  }
}

/* 5. LANDSCAPE MODE OPTIMIZATIONS */
@media (max-height: 500px) and (orientation: landscape) {
  .art {
    display: none;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 20px;
    max-width: 400px;
    margin: 0 auto;
  }

  h1 {
    font-size: 22px;
    margin-bottom: 16px;
  }

  .input {
    height: 44px;
    margin-bottom: 12px;
  }

  .worker-login-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    left: auto;
    bottom: auto;
    transform: none;
    padding: 8px 14px;
    font-size: 12px;
  }
}

/* 6. SAFARI & iOS SPECIFIC FIXES */
@supports (-webkit-touch-callout: none) {
  /* Fix for iOS 100vh issue */
  .frame {
    min-height: -webkit-fill-available;
  }

  /* Fix for iOS input zoom */
  input, textarea, select {
    font-size: 16px;
  }

  /* Smooth scrolling on iOS */
  body {
    -webkit-overflow-scrolling: touch;
  }
}

/* 7. ACCESSIBILITY IMPROVEMENTS */
.input:focus-visible {
  outline: 2px solid #6d28d9;
  outline-offset: 2px;
}

.btn:focus-visible {
  outline: 2px solid #6d28d9;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .input {
    border-width: 2px;
  }
  
  .btn {
    border: 2px solid currentColor;
  }
}

/* 8. LOADING STATES & SKELETON */
.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spinner 0.8s linear infinite;
}

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

/* 9. DARK MODE SUPPORT (if needed) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --text: #f8fafc;
    --muted: #94a3b8;
    --line: #334155;
  }
  
  @media (max-width: 640px) {
    body {
      background: linear-gradient(135deg, #020617 0%, #1e1b4b 100%);
    }
  }
}

/* 10. PRINT STYLES */
@media print {
  .art, .worker-login-btn {
    display: none !important;
  }
  
  .panel {
    width: 100%;
    max-width: 100%;
  }
}





.art-card{
background:linear-gradient(135deg,#4c1d95,#6d28d9);
border-radius:16px;
padding:20px;
color:white;
text-align:center;
}

.art-title{
font-size:24px;
font-weight:bold;
margin-bottom:10px;
}

.art-subtitle{
opacity:.85;
margin-bottom:20px;
}


/* 🚨 تصميم زر الموظفين الجديد 🚨 */
.worker-login-btn {
  position: absolute;
  top: 24px;
  left: 24px; /* وضعناه في أعلى اليسار ليكون في المساحة الفارغة للرسمة */
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px); /* تأثير زجاجي خفيف */
  color: #010102;
  padding: 8px 16px;
  border-radius: 99px; /* شكل كبسولة */
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border: 1px solid #E5E7EB;
  transition: all 0.3s ease;
  z-index: 10;
}

.worker-login-btn:hover {
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(109, 40, 217, 0.15); /* ظل بنفسجي خفيف */
  color: #6d28d9; /* لون سيلفا */
  border-color: #d8b4fe;
}
@media (max-width: 640px) {
    .worker-login-btn {
        top: 15px;
        left: 15px;
        font-size: 12px; /* تصغير الخط قليلاً ليتناسب مع الهاتف */
        padding: 6px 12px;
        background: white; /* تعتيم الخلفية قليلاً ليبرز على خلفية الموبايل */
    }
}
