/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Safe area insets for iOS standalone mode (hides URL bar) */
.pt-safe {
  padding-top: env(safe-area-inset-top);
}

.pb-safe {
  padding-bottom: env(safe-area-inset-bottom);
}

.pl-safe {
  padding-left: env(safe-area-inset-left);
}

.pr-safe {
  padding-right: env(safe-area-inset-right);
}

/* iOS-style Action Sheet */
.action-sheet {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  touch-action: manipulation;
}

.action-sheet.action-sheet-open {
  display: flex;
}

.action-sheet-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0);
  transition: background-color 0.2s ease-out;
  touch-action: none;
}

.action-sheet-visible .action-sheet-backdrop {
  background-color: rgba(0, 0, 0, 0.4);
}

.action-sheet-content {
  position: relative;
  padding: 8px 16px;
  padding-bottom: max(env(safe-area-inset-bottom), 8px);
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
  max-height: 85vh;
  max-height: 85dvh;
}

.action-sheet-visible .action-sheet-content {
  transform: translateY(0);
}

/* Scrollable action sheet for forms with many inputs */
.action-sheet-content--scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.action-sheet-content--scrollable .action-sheet-group {
  max-height: none;
}

.action-sheet-group {
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 8px;
}

.action-sheet-header {
  padding: 14px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.action-sheet-header-title {
  font-size: 13px;
  font-weight: 600;
  color: #8e8e93;
}

.action-sheet-action {
  display: block;
  width: 100%;
  padding: 18px 16px;
  text-align: center;
  font-size: 20px;
  color: #007aff;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.action-sheet-action:last-child {
  border-bottom: none;
}

.action-sheet-action:active {
  background-color: rgba(0, 0, 0, 0.1);
}

.action-sheet-action--destructive {
  color: #ff3b30;
}

.action-sheet-action--primary {
  color: #34c759;
  font-weight: 600;
}

.action-sheet-cancel {
  background-color: white;
  border-radius: 14px;
  overflow: hidden;
}

.action-sheet-cancel button {
  display: block;
  width: 100%;
  padding: 18px 16px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: #007aff;
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.action-sheet-cancel button:active {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Action sheet form inputs */
.action-sheet-group textarea,
.action-sheet-group input[type="text"],
.action-sheet-group input[type="number"] {
  font-size: 16px; /* Prevents iOS zoom on focus */
  touch-action: manipulation;
}

.action-sheet-group textarea:focus,
.action-sheet-group input:focus {
  outline: none;
}

/* Prevent iOS from scrolling body when keyboard appears */
.action-sheet-open {
  touch-action: none;
}

/* Fix iOS keyboard viewport push */
html:has(.action-sheet-open) {
  overflow: hidden;
  height: 100%;
  height: 100dvh;
}

html:has(.action-sheet-open) body {
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  position: fixed;
  width: 100%;
}

.action-sheet-content--scrollable {
  max-height: 70vh;
  max-height: 70dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Reduced motion support - respect user's accessibility preferences */
@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;
  }

  .action-sheet-content,
  .action-sheet-backdrop {
    transition: none !important;
  }
}
