/* Mobile-specific optimizations for login page */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Prevent horizontal scrolling on mobile */
html {
  overflow-x: hidden;
  width: 100%;
  position: relative;
}

/* Beautiful gradient background */
body {
  background: linear-gradient(135deg,
    #ffffff 0%,
    #fff5f0 15%,
    #ffe8dc 30%,
    #ffd5c8 45%,
    #ffe8dc 60%,
    #fff5f0 75%,
    #ffffff 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  position: relative;
  /* Allow vertical scrolling on mobile */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dark body,
html[data-theme="dark"] body {
  background: linear-gradient(135deg,
    #0a0a0a 0%,
    #1a0f0a 15%,
    #251812 30%,
    #2d1d15 45%,
    #251812 60%,
    #1a0f0a 75%,
    #0a0a0a 100%);
  background-attachment: fixed;
}

/* Better touch targets for mobile */
button, a, input, select, textarea {
  touch-action: manipulation;
}

/* Minimum touch target size (44x44px recommended by Apple/Google) */
button, a.button-like, input[type="submit"], input[type="button"] {
  min-height: 44px;
  min-width: 44px;
}

/* Improve text rendering on mobile */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Prevent iOS zoom on input focus */
@media (max-width: 640px) {
  input[type="email"],
  input[type="password"],
  input[type="text"],
  input[type="tel"],
  input[type="number"] {
    font-size: 16px !important; /* Prevents iOS zoom on input focus */
  }
  
  /* Better spacing for mobile forms */
  form {
    gap: 0.75rem;
    width: 100%;
  }
  
  /* Improve toggle switch touch target */
  .toggle-track {
    min-width: 36px;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Ensure inputs don't overflow */
  input {
    width: 100%;
    box-sizing: border-box;
  }
  
  /* Better button sizing on mobile */
  button {
    width: 100%;
    box-sizing: border-box;
  }
  
  /* Compact spacing on mobile */
  h2 {
    margin-bottom: 0.75rem !important;
  }
  
  .mb-3 {
    margin-bottom: 0.75rem;
  }
  
  .mt-4 {
    margin-top: 1rem;
  }
}

/* Improve scrolling performance on mobile */
@media (max-width: 768px) {
  * {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better form layout on mobile */
  main {
    display: grid;
    grid-template-rows: 1fr;
  }
  
  /* Ensure form section fits on screen */
  section {
    height: 100vh;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Ensure form content fits on mobile */
  section > div {
    width: 100%;
    max-width: 100%;
  }
  
  /* Theme toggle button positioning */
  #theme-toggle {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    max-width: 44px;
    max-height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Landscape mobile adjustments */
@media (max-width: 896px) and (orientation: landscape) {
  section {
    height: 100vh;
    padding: 0.5rem 0 !important;
  }
  
  h2 {
    font-size: 1.5rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  form {
    gap: 0.75rem !important;
  }
  
  /* Reduce spacing in landscape */
  section > div {
    padding: 0;
  }
}

/* Improve focus states for accessibility on mobile */
input:focus,
button:focus,
a:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Better checkbox/toggle interaction on mobile */
label {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Prevent text selection on interactive elements during touch */
button, a {
  -webkit-user-select: none;
  user-select: none;
}

/* Ensure inputs are readable on mobile */
input, textarea {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0.5rem;
}

/* Better spacing for mobile form elements */
@media (max-width: 640px) {
  .separator {
    margin: 1.5rem 0;
  }
}

/* Code input styling for verification */
.code-input {
  caret-color: transparent;
}

.code-input:focus {
  animation: pulse-ring 1.5s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1);
  }
}

.dark .code-input:focus {
  animation: pulse-ring-dark 1.5s ease-in-out infinite;
}

@keyframes pulse-ring-dark {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.1);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
  }
}
