/*
 * 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.
 */

/* Custom select styling for consistent cross-browser appearance */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.25rem 1.25rem;
  padding-right: 2.5rem;
}

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

.pt-safe {
  padding-top: env(safe-area-inset-top);
}

/* Hide details marker for messenger dropdowns */
details > summary {
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

/* Dropdown component */
details[data-controller="dropdown"] {
  position: relative;
}

/* Keep content visible during close animation */
details[data-controller="dropdown"]::details-content {
  transition: content-visibility 200ms allow-discrete;
}

/* Panel — closed state (default) */
details[data-controller="dropdown"] [data-dropdown-target="panel"] {
  position: absolute;
  z-index: 50;
  margin-top: 0.25rem;
  opacity: 0;
  transform: scale(0.97);
  transform-origin: top left;
  transition: opacity 200ms cubic-bezier(0.2, 0.6, 0.35, 1),
              transform 200ms cubic-bezier(0.2, 0.6, 0.35, 1);
}

/* Panel — open state */
details[data-controller="dropdown"][open] [data-dropdown-target="panel"] {
  opacity: 1;
  transform: scale(1);
  transition: opacity 250ms cubic-bezier(0.32, 0.72, 0, 1),
              transform 250ms cubic-bezier(0.32, 0.72, 0, 1);

  @starting-style {
    opacity: 0;
    transform: scale(0.97);
  }
}

/* Alignment variants for transform-origin */
details[data-controller="dropdown"][data-align="end"] [data-dropdown-target="panel"] {
  transform-origin: top right;
}

details[data-controller="dropdown"][data-align="center"] [data-dropdown-target="panel"] {
  transform-origin: top center;
}

/* PWA Offline indicator */
body.offline::before {
  content: "Offline - Internet connection required for changes";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: #ef4444;
  color: white;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Offline form state */
.offline-disabled {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.offline-disabled::after {
  content: "Internet connection required";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(239, 68, 68, 0.95);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

/* Offline toast notification */
.offline-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #ef4444;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 10000;
  transition: transform 0.3s ease;
}

.offline-toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Show elements only when offline */
body.offline .offline\:block {
  display: block !important;
}

body:not(.offline) .offline\:block {
  display: none !important;
}

/* Hide elements when offline */
body.offline .online\:block {
  display: none !important;
}

body:not(.offline) .online\:block {
  display: block !important;
}

@media (prefers-color-scheme: dark) {
  .offline-disabled::after,
  .offline-toast {
    background: rgba(239, 68, 68, 0.95);
  }
}

/* PWA installed state - hide install instructions when running as standalone app */
@media (display-mode: standalone) {
  .pwa__instructions {
    display: none;
  }
}

/* PWA installer button - only show when install is available */
.pwa__installer {
  display: none;
}

.pwa--can-install .pwa__installer {
  display: block;
}
