/*
 * Alee Share Links — Frontend v1.1
 *
 *  ┌──────────────────────────────────────────────────────────┐
 *  │  Modes:                                                  │
 *  │    .asl-mode-fab   → single FAB + bottom sheet (default) │
 *  │    .asl-mode-bar   → sticky bar (mobile) + sidebar (PC)  │
 *  │  Positions (FAB only):                                   │
 *  │    .asl-fab-right / .asl-fab-left                         │
 *  └──────────────────────────────────────────────────────────┘
 */

.asl-root {
  --asl-primary:     #2563eb;
  --asl-primary-ink: #1d4ed8;
  --asl-text:        #0f172a;
  --asl-text-muted:  #64748b;
  --asl-surface:     #ffffff;
  --asl-surface-alt: #f1f5f9;
  --asl-border:      rgba(15, 23, 42, 0.08);
  --asl-radius:      10px;
  --asl-radius-lg:   16px;
  --asl-shadow-fab:  0 6px 16px rgba(37, 99, 235, 0.32), 0 2px 6px rgba(37, 99, 235, 0.2);
  --asl-shadow-sheet:0 -16px 40px rgba(15, 23, 42, 0.15), 0 -2px 8px rgba(15, 23, 42, 0.06);
  --asl-safe-offset: 0px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", "IBM Plex Sans Thai", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.asl-root * { box-sizing: border-box; }

/* Mono accent */
.asl-root.asl-accent-mono .asl-btn-icon,
.asl-root.asl-accent-mono .asl-sheet-item-icon { --asl-brand: #475569 !important; }

/* ============================================================
 *  FAB (Floating Action Button) — v1.1 default
 * ============================================================ */
.asl-fab {
  position: fixed;
  z-index: 997;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 20px 0 16px;
  height: 56px;
  border: none;
  border-radius: 999px;
  background: var(--asl-primary);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--asl-shadow-fab);
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .2s cubic-bezier(.4, 0, .2, 1),
              box-shadow .2s ease,
              opacity .2s ease;
  /* iOS safe area */
  bottom: calc(20px + env(safe-area-inset-bottom) + var(--asl-safe-offset));
}
.asl-root.asl-fab-right .asl-fab { right: 20px; }
.asl-root.asl-fab-left  .asl-fab { left:  20px; }

.asl-fab:hover  { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(37, 99, 235, 0.38), 0 3px 8px rgba(37, 99, 235, 0.25); }
.asl-fab:active { transform: translateY(0) scale(0.96); }
.asl-fab:focus-visible { outline: 3px solid #bfdbfe; outline-offset: 3px; }

.asl-fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.asl-fab-icon svg { width: 22px; height: 22px; }
.asl-fab-label { letter-spacing: .01em; }

/* Visibility */
.asl-root.asl-mode-fab.asl-on-mobile .asl-fab  { display: inline-flex; }
@media (min-width: 900px) {
  .asl-root.asl-mode-fab.asl-on-desktop .asl-fab { display: inline-flex; }
  .asl-root.asl-mode-fab.asl-off-desktop .asl-fab { display: none; }
}
@media (max-width: 899px) {
  .asl-root.asl-mode-fab.asl-off-mobile .asl-fab { display: none; }
}

/* Auto-hide behavior */
.asl-root.asl-hidden .asl-fab {
  opacity: 0;
  transform: translateY(8px) scale(0.94);
  pointer-events: none;
}
.asl-root.asl-sheet-open .asl-fab {
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

/* Compact (icon only) on small screens */
@media (max-width: 420px) {
  .asl-fab {
    width: 56px;
    padding: 0;
    justify-content: center;
  }
  .asl-fab-label { display: none; }
}

/* ============================================================
 *  Bottom Sheet
 * ============================================================ */
.asl-sheet-root {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
}
.asl-sheet-root[data-visible="1"] { pointer-events: auto; }

.asl-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity .25s ease;
}
.asl-sheet-root[data-visible="1"] .asl-sheet-backdrop { opacity: 1; }

.asl-sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 480px;
  background: var(--asl-surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--asl-shadow-sheet);
  padding: 8px 0 calc(12px + env(safe-area-inset-bottom) + var(--asl-safe-offset));
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.asl-sheet-root[data-visible="1"] .asl-sheet {
  transform: translateX(-50%) translateY(0);
}

/* Desktop: centered modal instead of bottom sheet (looks better on wide viewports) */
@media (min-width: 900px) {
  .asl-sheet {
    top: 50%;
    bottom: auto;
    left: 50%;
    transform: translate(-50%, -48%) scale(0.96);
    opacity: 0;
    width: calc(100% - 40px);
    max-width: 420px;
    border-radius: 20px;
    padding-top: 14px;
    padding-bottom: 14px;
    max-height: 75vh;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28), 0 4px 12px rgba(15, 23, 42, 0.1);
    transition: transform .28s cubic-bezier(.32, .72, 0, 1),
                opacity .22s ease;
  }
  .asl-sheet-root[data-visible="1"] .asl-sheet {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  /* Drag handle not useful on desktop — hide */
  .asl-sheet-handle { display: none; }
}

.asl-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--asl-surface-alt);
  border-radius: 999px;
  margin: 4px auto 10px;
  flex: none;
}

.asl-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--asl-border);
  flex: none;
}
.asl-sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--asl-text);
  line-height: 1.2;
}
.asl-sheet-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: var(--asl-surface-alt);
  border-radius: 50%;
  color: var(--asl-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.asl-sheet-close:hover { background: #e2e8f0; color: var(--asl-text); }
.asl-sheet-close:focus-visible { outline: 2px solid var(--asl-primary); outline-offset: 2px; }

.asl-sheet-body {
  padding: 6px 10px;
  overflow-y: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

.asl-sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--asl-text);
  transition: background .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.asl-sheet-item:hover { background: var(--asl-surface-alt); }
.asl-sheet-item:active { transform: scale(0.98); }
.asl-sheet-item:focus-visible { background: var(--asl-surface-alt); box-shadow: inset 0 0 0 2px var(--asl-primary); }

.asl-sheet-item-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--asl-brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: transform .15s ease;
}
.asl-sheet-item-icon svg { width: 22px; height: 22px; }
.asl-sheet-item:active .asl-sheet-item-icon { transform: scale(0.94); }

.asl-sheet-item-label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--asl-text);
}

.asl-sheet-item-chevron {
  color: #cbd5e1;
  display: inline-flex;
  transition: transform .15s ease, color .15s ease;
}
.asl-sheet-item:hover .asl-sheet-item-chevron { color: var(--asl-text-muted); transform: translateX(2px); }

/* ============================================================
 *  LEGACY MODE (v1.0 look) — .asl-mode-bar
 *  Preserves old bar on mobile + sidebar on desktop
 * ============================================================ */

/* Sticky bar (mobile) */
.asl-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 998;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--asl-border);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
  display: none;
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--asl-safe-offset));
}
.asl-root.asl-mode-bar.asl-on-mobile .asl-bar  { display: block; }
.asl-root.asl-mode-bar.asl-off-mobile .asl-bar { display: none !important; }
.asl-root.asl-mode-bar.asl-hidden .asl-bar     { transform: translateY(110%); }

.asl-bar-inner {
  display: flex;
  align-items: stretch;
  max-width: 640px;
  margin: 0 auto;
}

/* Floating sidebar (desktop) */
.asl-sidebar {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 998;
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border: 1px solid var(--asl-border);
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.asl-sidebar.asl-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%);
}
.asl-sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--asl-text-muted);
  padding: 2px 8px;
}
.asl-sidebar-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }

.asl-root.asl-mode-bar.asl-on-desktop  .asl-sidebar { display: flex; }
.asl-root.asl-mode-bar.asl-off-desktop .asl-sidebar { display: none !important; }
@media (max-width: 899px) {
  .asl-root.asl-mode-bar .asl-sidebar { display: none !important; }
}
@media (min-width: 900px) {
  .asl-root.asl-mode-bar .asl-bar { display: none !important; }
}

/* Legacy buttons */
.asl-btn {
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  color: var(--asl-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  line-height: 1.2;
  transition: transform .15s ease;
}
.asl-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  color: #fff;
  background: var(--asl-brand);
  width: 36px; height: 36px;
  border-radius: 10px;
  transition: transform .15s ease, filter .15s ease;
}
.asl-btn-icon svg { width: 22px; height: 22px; }
.asl-btn:hover  .asl-btn-icon { filter: brightness(0.95); }
.asl-btn:active .asl-btn-icon { transform: scale(0.92); }
.asl-btn-label { font-size: 13px; font-weight: 600; color: var(--asl-text); }

.asl-btn-bar {
  flex: 1 1 0;
  flex-direction: column;
  gap: 3px;
  padding: 8px 4px 10px;
  min-height: 58px;
}
.asl-btn-bar .asl-btn-icon { width: 34px; height: 34px; border-radius: 10px; }
.asl-btn-bar .asl-btn-icon svg { width: 18px; height: 18px; }
.asl-root.asl-nolbl-m .asl-btn-bar .asl-btn-label { display: none; }
.asl-root.asl-lbl-m  .asl-btn-bar .asl-btn-label { font-size: 10.5px; color: var(--asl-text-muted); }

.asl-btn-sidebar {
  flex: none;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0);
  width: 100%;
}
.asl-btn-sidebar:hover { background: rgba(15, 23, 42, 0.04); }
.asl-btn-sidebar .asl-btn-icon { width: 40px; height: 40px; border-radius: 50%; }
.asl-btn-sidebar .asl-btn-icon svg { width: 20px; height: 20px; }
.asl-root.asl-nolbl-d .asl-btn-sidebar { padding: 6px; }
.asl-root.asl-nolbl-d .asl-btn-sidebar .asl-btn-label { display: none; }
.asl-root.asl-lbl-d  .asl-btn-sidebar .asl-btn-label { font-size: 12.5px; }

/* Pulse for feedback */
@keyframes aslPulse {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.asl-btn.asl-pulse .asl-btn-icon,
.asl-sheet-item.asl-pulse .asl-sheet-item-icon,
.asl-fab.asl-pulse { animation: aslPulse .35s ease; }

/* ============================================================
 *  Toast (copy feedback)
 * ============================================================ */
.asl-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom) + var(--asl-safe-offset));
  transform: translateX(-50%) translateY(8px);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
}
.asl-toast[data-visible="1"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Lift the toast above the FAB in fab mode */
.asl-root.asl-mode-fab .asl-toast {
  bottom: calc(92px + env(safe-area-inset-bottom) + var(--asl-safe-offset));
}
.asl-root.asl-mode-bar .asl-toast {
  bottom: calc(80px + env(safe-area-inset-bottom) + var(--asl-safe-offset));
}
@media (min-width: 900px) {
  .asl-root.asl-mode-bar .asl-toast { bottom: 24px; }
}
.asl-toast-icon { display: inline-flex; color: #86efac; }
.asl-toast-icon svg { width: 16px; height: 16px; }

/* ============================================================
 *  Reduced motion
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .asl-fab, .asl-bar, .asl-sidebar, .asl-toast,
  .asl-btn-icon, .asl-sheet, .asl-sheet-backdrop,
  .asl-sheet-item, .asl-sheet-item-icon, .asl-sheet-item-chevron {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================================
 *  Prefers dark (neutral tweaks so FAB/sheet don't look jarring)
 * ============================================================ */
@media (prefers-color-scheme: dark) {
  .asl-root {
    --asl-surface:     #1e293b;
    --asl-surface-alt: #334155;
    --asl-text:        #e2e8f0;
    --asl-text-muted:  #94a3b8;
    --asl-border:      rgba(255, 255, 255, 0.08);
  }
  .asl-bar     { background: rgba(15, 23, 42, 0.88); }
  .asl-sidebar { background: rgba(15, 23, 42, 0.85); }
  .asl-sheet-close { background: #334155; }
  .asl-sheet-close:hover { background: #475569; }
}

/* Body scroll lock helper (applied by JS) */
html.asl-no-scroll, body.asl-no-scroll {
  overflow: hidden !important;
  touch-action: none;
}
