/* ═══════════════════════════════════════════════════════
   AutoMixSJ88 — Mobile UX Round 2 (10 ฟีเจอร์)
   #11-#20
   ═══════════════════════════════════════════════════════ */

/* ────────────────────────────────────────────────────────
   #11  LONG-PRESS CONTEXT MENU
   ──────────────────────────────────────────────────────── */
.context-menu {
  position: fixed;
  z-index: 700;
  background: rgba(14, 14, 36, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 1px rgba(255,255,255,0.1);
  animation: ctxIn 0.2s ease;
  display: none;
}
.context-menu.open { display: block; }
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.84rem;
  color: var(--text-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.context-menu-item:active {
  background: rgba(139, 92, 246, 0.12);
}
.context-menu-item .ctx-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}
.context-menu-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 4px 8px;
}
.context-menu-item.danger { color: #ef4444; }
@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
.context-menu-overlay {
  position: fixed; inset: 0;
  z-index: 699;
  display: none;
}
.context-menu-overlay.open { display: block; }

/* ────────────────────────────────────────────────────────
   #12  SKELETON LOADING
   ──────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.skeleton-avatar {
  width: 44px; height: 44px;
  border-radius: 10px;
}
.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.skeleton-line {
  height: 12px;
  border-radius: 6px;
}
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w40 { width: 40%; }

.skeleton-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.04);
}
.skeleton-title {
  height: 16px;
  width: 50%;
  margin-bottom: 16px;
  border-radius: 8px;
}
.skeleton-input {
  height: 44px;
  width: 100%;
  margin-bottom: 12px;
  border-radius: 10px;
}

/* ────────────────────────────────────────────────────────
   #13  VOICE INPUT (MIC BUTTON)
   ──────────────────────────────────────────────────────── */
.input-with-mic {
  position: relative;
}
.input-with-mic .form-input,
.input-with-mic .form-textarea {
  padding-right: 52px;
}
.mic-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-1);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.mic-btn:active { transform: translateY(-50%) scale(0.88); }
.mic-btn.recording {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  animation: micPulse 1s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* textarea mic — position top-right */
.input-with-mic .form-textarea ~ .mic-btn {
  top: 12px;
  transform: none;
}

/* ────────────────────────────────────────────────────────
   #14  PWA INSTALL BANNER
   ──────────────────────────────────────────────────────── */
.pwa-banner {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  left: 8px; right: 8px;
  z-index: 550;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(139,92,246,0.2);
  border-radius: 16px;
  padding: 14px 16px;
  display: none;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  animation: slideUp 0.4s ease;
}
.pwa-banner.visible { display: flex; }
.pwa-banner-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.pwa-banner-text {
  flex: 1;
  min-width: 0;
}
.pwa-banner-title {
  font-size: 0.84rem;
  font-weight: 700;
}
.pwa-banner-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.pwa-banner-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.pwa-banner .btn-install {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: var(--accent-gradient);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.pwa-banner .btn-dismiss {
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

/* ────────────────────────────────────────────────────────
   #15  OFFLINE STATUS BAR
   ──────────────────────────────────────────────────────── */
.offline-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 800;
  background: linear-gradient(90deg, #dc2626, #b91c1c);
  color: white;
  text-align: center;
  padding: 6px 16px;
  padding-top: calc(6px + env(safe-area-inset-top, 0px));
  font-size: 0.72rem;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  animation: slideDown 0.3s ease;
}
.offline-bar.visible { display: flex; }
.offline-bar.online {
  background: linear-gradient(90deg, #059669, #047857);
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

/* ────────────────────────────────────────────────────────
   #17  SCROLL-TO-TOP BUTTON
   ──────────────────────────────────────────────────────── */
.scroll-top-btn {
  position: fixed;
  bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  z-index: 470;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(14, 14, 36, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.scroll-top-btn.visible {
  display: flex;
  animation: fadeScaleIn 0.25s ease;
}
.scroll-top-btn:active { transform: scale(0.88); }
@keyframes fadeScaleIn {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

/* ────────────────────────────────────────────────────────
   #19  DRAG HANDLE (visual only for file list)
   ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .file-item { position: relative; }
  .file-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: grab;
    opacity: 0.4;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
  }
  .file-drag-handle:active { opacity: 0.8; cursor: grabbing; }
  .file-item.dragging {
    opacity: 0.5;
    background: rgba(139,92,246,0.06);
    border-radius: 12px;
  }
}

/* ────────────────────────────────────────────────────────
   #20  PROGRESS BADGE ON BOTTOM NAV
   ──────────────────────────────────────────────────────── */
.bottom-nav-item { position: relative; }
.nav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #ef4444;
  color: white;
  font-size: 0.55rem;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 8px rgba(239,68,68,0.5);
  animation: badgePop 0.3s ease;
}
.nav-badge.visible { display: flex; }
.nav-badge.pulse { animation: badgePop 0.3s ease, badgeBlink 1.5s ease-in-out infinite; }
@keyframes badgePop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
@keyframes badgeBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Mobile-only visibility for some features */
@media (min-width: 769px) {
  .context-menu,
  .context-menu-overlay,
  .pwa-banner,
  .scroll-top-btn,
  .mic-btn,
  .offline-bar { display: none !important; }
}
