/* =====================================================================
   UniMate Component — Sheet Modal v1.0
   Drag-to-close bottom sheets for mobile
   Replaces centered modals on small screens
   ===================================================================== */

/* ── Overlay ─────────────────────────────────────────────────────────── */
.um-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--um-duration-slow) var(--um-ease-smooth),
    visibility var(--um-duration-slow);
}

.um-sheet-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ── Sheet Panel ─────────────────────────────────────────────────────── */
.um-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1301;
  background: var(--um-surface);
  border-radius: var(--um-radius-2xl) var(--um-radius-2xl) 0 0;
  box-shadow: var(--um-shadow-2xl);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--um-duration-slower) var(--um-ease-smooth);
  overflow: hidden;
  touch-action: none;
}

.um-sheet-overlay.is-active .um-sheet {
  transform: translateY(0);
}

/* ── Drag Handle ─────────────────────────────────────────────────────── */
.um-sheet__handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--um-space-3) 0 var(--um-space-1);
  cursor: grab;
  flex-shrink: 0;
}

.um-sheet__handle::before {
  content: '';
  width: 36px;
  height: 4px;
  border-radius: var(--um-radius-full);
  background: var(--um-border-strong);
  transition: background var(--um-duration-fast) var(--um-ease-default);
}

.um-sheet__handle:active {
  cursor: grabbing;
}

.um-sheet__handle:active::before {
  background: var(--um-text-muted);
}

/* ── Header ──────────────────────────────────────────────────────────── */
.um-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--um-space-2) var(--um-space-5) var(--um-space-3);
  flex-shrink: 0;
}

.um-sheet__title {
  font-family: var(--um-font-display);
  font-size: var(--um-text-lg);
  font-weight: var(--um-weight-bold);
  color: var(--um-text);
  letter-spacing: var(--um-tracking-tight);
  margin: 0;
}

.um-sheet__close {
  width: 32px;
  height: 32px;
  border-radius: var(--um-radius-md);
  border: 1px solid var(--um-border);
  background: transparent;
  color: var(--um-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition:
    background var(--um-duration-fast) var(--um-ease-default),
    color var(--um-duration-fast) var(--um-ease-default);
}

.um-sheet__close:hover {
  background: var(--um-danger-light);
  color: var(--um-danger);
}

/* ── Body ─────────────────────────────────────────────────────────────── */
.um-sheet__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 var(--um-space-5) var(--um-space-5);
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.um-sheet__footer {
  padding: var(--um-space-4) var(--um-space-5);
  padding-bottom: calc(var(--um-space-4) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--um-divider);
  display: flex;
  align-items: center;
  gap: var(--um-space-2);
  flex-shrink: 0;
}

/* ── Size Variants ───────────────────────────────────────────────────── */
.um-sheet--sm  { max-height: 40vh; }
.um-sheet--md  { max-height: 60vh; }
.um-sheet--lg  { max-height: 85vh; }
.um-sheet--full { max-height: calc(100vh - 40px); }

/* ── Action List (menu-style sheet) ──────────────────────────────────── */
.um-sheet__action-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.um-sheet__action {
  display: flex;
  align-items: center;
  gap: var(--um-space-3);
  padding: var(--um-space-3-5) var(--um-space-5);
  color: var(--um-text);
  font-size: var(--um-text-md);
  font-weight: var(--um-weight-medium);
  cursor: pointer;
  transition: background var(--um-duration-fast) var(--um-ease-default);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  min-height: 48px;
}

.um-sheet__action:active {
  background: var(--um-surface-sunken);
}

.um-sheet__action i {
  width: 24px;
  text-align: center;
  color: var(--um-text-secondary);
  font-size: 16px;
}

.um-sheet__action--danger {
  color: var(--um-danger);
}

.um-sheet__action--danger i {
  color: var(--um-danger);
}

.um-sheet__action-divider {
  height: 1px;
  background: var(--um-divider);
  margin: var(--um-space-1) 0;
}

/* ── Dark Theme ──────────────────────────────────────────────────────── */
.theme-dark .um-sheet-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.theme-dark .um-sheet {
  background: var(--um-surface-elevated);
  border-top: 1px solid var(--um-border);
}

.theme-dark .um-sheet__handle::before {
  background: var(--um-border);
}

.theme-dark .um-sheet__close {
  border-color: var(--um-border);
}

/* ── Desktop: revert to centered modal ───────────────────────────────── */
@media (min-width: 641px) {
  .um-sheet-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .um-sheet {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    max-width: 480px;
    width: 100%;
    border-radius: var(--um-radius-2xl);
    max-height: 85vh;
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    transition:
      transform var(--um-duration-slower) var(--um-ease-spring),
      opacity var(--um-duration-slow) var(--um-ease-smooth);
  }

  .um-sheet-overlay.is-active .um-sheet {
    transform: scale(1) translateY(0);
    opacity: 1;
  }

  .um-sheet__handle {
    display: none;
  }
}
