/**
 * Login Mobile Optimizations
 * Stili specifici per migliorare l'esperienza su dispositivi mobili
 */

html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

* {
  -webkit-tap-highlight-color: rgba(11, 179, 181, 0.1);
  -webkit-touch-callout: none;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

input[type="checkbox"],
.auth-consent-row__checkbox {
  -webkit-appearance: checkbox !important;
  appearance: checkbox !important;
  min-height: 20px !important;
  width: 20px !important;
  height: 20px !important;
  max-width: 20px !important;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  html {
    height: -webkit-fill-available;
  }

  body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding-top: max(90px, calc(90px + env(safe-area-inset-top)));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .app-container {
    padding-bottom: max(28px, calc(28px + env(safe-area-inset-bottom))) !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  .card {
    margin-bottom: 16px;
    max-height: none !important;
    overflow: visible !important;
  }
}

@supports (-webkit-touch-callout: none) {
  body {
    padding-top: max(90px, calc(90px + env(safe-area-inset-top)));
  }

  html {
    height: -webkit-fill-available;
  }

  body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
  }
}

@media (max-width: 480px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="date"],
  select {
    font-size: 16px !important;
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
  }

  input[type="checkbox"],
  .auth-consent-row__checkbox {
    min-height: 20px !important;
    font-size: initial !important;
  }

  button,
  .oauth-btn {
    min-height: 48px;
  }

  .toggle-password,
  .modal-close-btn,
  .back-btn {
    min-height: auto !important;
  }

  .card {
    margin-bottom: 16px;
  }

  .auth-modal {
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
  }

  form input:not([type="checkbox"]),
  form select,
  form textarea {
    margin-bottom: 14px;
  }

  .oauth-btn + .oauth-btn {
    margin-top: 12px;
  }

  .modal-close-btn {
    width: 40px !important;
    height: 40px !important;
    font-size: 1.8rem !important;
    background: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    z-index: 10;
  }

  .auth-consent-row {
    align-items: flex-start !important;
    flex-wrap: nowrap !important;
  }
}

@media (max-width: 374px) {
  .card {
    padding: 16px 12px;
    margin-bottom: 12px;
  }

  .card h2 {
    font-size: 1.2rem;
  }

  .oauth-btn {
    padding: 10px 12px !important;
    font-size: 0.85rem !important;
    min-height: 44px;
  }

  .auth-modal__panel {
    padding: 18px 12px max(12px, env(safe-area-inset-bottom)) !important;
  }

  .modal-close-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.5rem !important;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body {
    padding-top: 60px;
  }

  .app-header {
    padding: 10px 16px;
  }

  .card {
    padding: 16px;
  }

  .auth-modal__panel {
    max-height: 85vh !important;
    padding: 16px !important;
  }
}

@media (prefers-reduced-motion: no-preference) and (max-width: 768px) {
  button,
  .oauth-btn,
  input,
  .card {
    transition: all 0.2s ease-out;
  }

  button:active,
  .oauth-btn:active {
    transform: scale(0.98);
  }

  .auth-modal.is-open .auth-modal__panel {
    animation: slideUpMobile 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  }

  @keyframes slideUpMobile {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}

@supports (padding: max(0px)) {
  body {
    padding-top: max(90px, calc(90px + env(safe-area-inset-top)));
    padding-bottom: max(20px, calc(20px + env(safe-area-inset-bottom)));
  }

  .app-header {
    padding-top: max(16px, calc(16px + env(safe-area-inset-top)));
    min-height: 70px;
  }

  .app-container {
    padding-bottom: max(28px, calc(28px + env(safe-area-inset-bottom))) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid #0bb3b5;
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(11, 179, 181, 0.3);
  border-radius: 2px;
}

/* Auth login pages — no page scroll (login.html + business-login.html) */
html.auth-login-shell {
  height: 100%;
  overflow: hidden;
  scroll-behavior: auto;
}

html.auth-login-shell body {
  min-height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
  padding-top: calc(56px + env(safe-area-inset-top, 0px)) !important;
}

html.auth-login-shell .app-container {
  min-height: 0 !important;
  overflow: hidden !important;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
}

@media (max-width: 768px) {
  html.auth-login-shell body {
    padding-top: calc(56px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  }

  html.auth-login-shell .app-container {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
    overflow: hidden !important;
  }

  html.auth-login-shell .card {
    max-height: 100% !important;
    overflow-y: auto !important;
  }
}

@supports (-webkit-touch-callout: none) {
  html.auth-login-shell body {
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    padding-top: calc(56px + env(safe-area-inset-top, 0px)) !important;
  }
}
