/* ==========================================================================
   StitChat — Modal / Drawer system
   Desktop (>=768px): centered dialog, fade + scale in.
   Mobile (<768px):   bottom sheet, slides up from the edge, drag handle,
                       swipe-down-to-dismiss.
   ========================================================================== */

.sc-modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.55);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.sc-modal-backdrop.open { opacity: 1; pointer-events: auto; }

.sc-modal-panel {
  position: fixed; z-index: 201;
  background: #FFFFFF;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.35);
  max-height: 85vh;
}

.sc-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #E2E8F0; flex-shrink: 0;
}
.sc-modal-title { font-size: 15px; font-weight: 700; color: #0F172A; }
.sc-modal-close {
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: #64748B; transition: background-color .15s ease;
}
.sc-modal-close:hover { background: #F1F5F9; }

.sc-modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.sc-modal-footer {
  padding: 12px 18px; border-top: 1px solid #E2E8F0; display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0;
}

.sc-drag-handle {
  display: none;
  width: 36px; height: 4px; border-radius: 99px; background: #CBD5E1;
  margin: 8px auto 0;
}

/* Buttons used inside modals */
.sc-btn {
  font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 9px;
  transition: background-color .15s ease, opacity .15s ease;
}
.sc-btn-primary { background: #2563EB; color: #fff; }
.sc-btn-primary:hover { background: #1D4ED8; }
.sc-btn-secondary { background: #F1F5F9; color: #334155; }
.sc-btn-secondary:hover { background: #E2E8F0; }
.sc-btn-danger { background: #FEE2E2; color: #B91C1C; }
.sc-btn-danger:hover { background: #FECACA; }
.sc-btn:disabled { opacity: .5; pointer-events: none; }

.sc-option-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 10px; border: 1px solid #E2E8F0;
  margin-bottom: 8px; cursor: pointer; transition: border-color .15s ease, background-color .15s ease;
}
.sc-option-row:hover { border-color: #2563EB; background: #EFF6FF; }
.sc-option-row.active { border-color: #2563EB; background: #EFF6FF; }
.sc-option-label { font-size: 13.5px; font-weight: 600; color: #0F172A; }
.sc-option-sub { font-size: 11.5px; color: #94A3B8; margin-top: 1px; }

.sc-emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
}
.sc-emoji-btn {
  font-size: 20px; padding: 6px; border-radius: 8px; transition: background-color .12s ease;
}
.sc-emoji-btn:hover { background: #F1F5F9; }

.sc-tag-input-row { display: flex; gap: 8px; margin-top: 10px; }
.sc-tag-input-row input {
  flex: 1; border: 1px solid #E2E8F0; border-radius: 9px; padding: 8px 10px; font-size: 13px; outline: none;
}
.sc-tag-input-row input:focus { border-color: #2563EB; box-shadow: 0 0 0 3px #EFF6FF; }

.sc-existing-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.sc-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #0F172A; color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 10px 16px; border-radius: 10px; z-index: 250;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.sc-toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 767.98px) {
  .sc-modal-panel {
    left: 0; right: 0; bottom: 0; width: 100%;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    transition: transform .25s cubic-bezier(.32,.72,0,1);
  }
  .sc-modal-panel.open { transform: translateY(0); }
  .sc-drag-handle { display: block; }
}

/* ---------- Desktop: centered dialog ---------- */
@media (min-width: 768px) {
  .sc-modal-panel {
    top: 50%; left: 50%; width: 420px; max-width: 90vw;
    border-radius: 16px;
    transform: translate(-50%, -48%) scale(.96);
    opacity: 0;
    transition: transform .18s ease, opacity .18s ease;
  }
  .sc-modal-panel.open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sc-modal-panel, .sc-modal-backdrop { transition: none !important; }
}

/* ==========================================================================
   Mobile viewport-height fix
   Mobile browsers measure 100vh as the full screen including the area
   behind the address bar / toolbar, which isn't always visible. That was
   pushing the composer (pinned to the bottom of a 100vh-tall layout) off
   the actually-visible screen on real phones. 100dvh tracks the real
   visible area instead. Kept as a progressive enhancement — falls back
   to the existing 100vh-based layout on older browsers that don't support it.
   ========================================================================== */
@supports (height: 100dvh) {
  .h-screen { height: 100dvh; }
}

@media (max-width: 767.98px) {
  @supports (height: 100dvh) {
    .list-pane, .chat-pane {
      height: calc(100dvh - 56px);
    }
    .rail, .details-pane {
      height: 100dvh;
    }
  }
}
