/*
 * components.css — 뷰에 속하지 않는 전역 공유 UI 컴포넌트
 *
 * Sections:
 *   1. Note Card (채팅/인박스 공유)
 *   2. Bottom Nav (모바일 하단 탭)
 *   3. Summary Toast
 *   4. Connection Status Banner
 *   5. PWA Install Banner
 *   6. Swipe Hint
 *   7. All Appear Overlay (전체 등장)
 */

/* ===== 1. Note Card ===== */
.note-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.note-card {
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  max-width: 400px;
  box-shadow: var(--shadow-sm);
  transition: all 200ms ease;
}

.note-card:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.note-card-processing {
  opacity: 0.6;
  pointer-events: none;
}

.note-card-header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.note-card-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.note-card-info {
  min-width: 0;
  flex: 1;
}

.note-card-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-card-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.note-card-preview {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card .action-buttons { margin-top: 10px; }

/* 분류 버튼 색상 구분 */
.action-btn.action-idea {
  border-color: #F59E0B;
  color: #B45309;
}
.action-btn.action-idea:hover {
  background: #FFFBEB;
  border-color: #F59E0B;
  color: #B45309;
}

.action-btn.action-plan {
  border-color: var(--accent);
  color: var(--accent);
}
.action-btn.action-plan:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.action-btn.action-ref {
  border-color: #22C55E;
  color: #16A34A;
}
.action-btn.action-ref:hover {
  background: #F0FDF4;
  border-color: #22C55E;
  color: #16A34A;
}

.action-btn.action-delete {
  border-color: #EF4444;
  color: #DC2626;
}
.action-btn.action-delete:hover {
  background: #FEF2F2;
  border-color: #EF4444;
  color: #DC2626;
}

/* Note card mobile */
@media (max-width: 767px) {
  .note-card {
    max-width: 100%;
    position: relative;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
  }

  /* 스와이프 안내 */
  .note-card::after {
    content: "\2190 \uAE30\B85D  |  \C0DD\AC01 \2192";
    display: block;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    opacity: 0.6;
  }
}

/* ===== Bottom Nav (mobile) ===== */
.bottom-nav {
  display: none;
  height: 56px;
  background: var(--surface-app-canvas);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  transition: color 150ms ease;
}

.tab-item.active { color: var(--accent-pink); }

/* 하단 탭 뱃지 */
.tab-icon-wrapper {
  position: relative;
  display: inline-flex;
}

.tab-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--accent-pink);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
  }
}

/* ===== Bottom Nav More Sheet ===== */
.bottom-more-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0);
  transition: background 250ms ease;
}

.bottom-more-sheet-backdrop.visible {
  background: rgba(0, 0, 0, 0.4);
}

.bottom-more-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-app-canvas);
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%);
  transition: transform 250ms ease;
  max-height: 60vh;
  overflow-y: auto;
}

.bottom-more-sheet-backdrop.visible .bottom-more-sheet {
  transform: translateY(0);
}

.bottom-more-sheet-title {
  padding: 16px 20px 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.bottom-more-sheet-list {
  display: flex;
  flex-direction: column;
  padding: 4px 8px 12px;
}

.bottom-more-sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: none;
  background: none;
  font-size: 15px;
  font-family: var(--font-family);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 150ms ease;
  min-height: 44px;
}

.bottom-more-sheet-item:hover,
.bottom-more-sheet-item:active {
  background: var(--surface-control-track);
}

.bottom-more-sheet-item svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ===== Summary Toast ===== */
.summary-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 300ms ease;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

.summary-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Connection Status Banner ===== */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  pointer-events: none;
  background: #ff9800;
  color: white;
}
.connection-banner.visible {
  transform: translateY(0);
}
.connection-banner.reconnected {
  background: var(--primary);
}
.connection-banner.offline {
  background: #ff9800;
}
.connection-banner.reconnecting {
  background: #607d8b;
}
.connection-banner.replaced {
  background: #ef4444;
  pointer-events: auto;
}
.connection-banner.restarting {
  background: #607d8b;
  animation: restart-pulse 2s ease-in-out infinite;
}
@keyframes restart-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.connection-banner.reconnect-failed {
  background: #ef4444;
  pointer-events: auto;
}

/* ===== PWA Install Banner ===== */
.install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent));
  color: white;
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  animation: slideDown 300ms ease;
}

/* cursor/transition/font-family from .ui-btn base */
.install-btn {
  padding: 4px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid white;
  background: transparent;
  color: white;
  font-size: 12px;
  font-weight: 600;
}

.install-btn:hover {
  background: white;
  color: var(--accent-pink);
}

.install-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.install-dismiss:hover {
  color: white;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@media (max-width: 767px) {
  .install-banner {
    font-size: 12px;
    padding: 8px 12px;
    gap: 8px;
  }
}

/* ===== Swipe Hint ===== */
.swipe-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 700;
  pointer-events: none;
  transition: opacity 100ms ease;
  white-space: nowrap;
  z-index: 5;
}

/* ===== All Appear Overlay ===== */
.all-appear-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--surface-app-canvas);
  flex-direction: column;
  animation: allAppearFadeIn 400ms ease-out;
}

.all-appear-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  background: var(--border);
}

.all-appear-cell {
  position: relative;
  overflow: hidden;
}

.all-appear-cell .cell-bg {
  position: absolute;
  inset: 0;
}

.all-appear-cell[data-agent="hana"] .cell-bg {
  background: linear-gradient(180deg, #F8FAFF 0%, #E8EDFF 100%);
}
.all-appear-cell[data-agent="sori"] .cell-bg {
  background: var(--agent-sori-bg);
}
.all-appear-cell[data-agent="seoyeon"] .cell-bg {
  background: var(--agent-seoyeon-bg);
}
.all-appear-cell[data-agent="jihyun"] .cell-bg {
  background: var(--agent-jihyun-bg);
}

.all-appear-cell video {
  display: none;
}

.all-appear-cell canvas {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 1;
}

.all-appear-cell .cell-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 14px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.35));
  z-index: 2;
}

.all-appear-cell .cell-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-on-card);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.all-appear-cell .cell-role {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  margin-top: 2px;
}

.all-appear-cell.cell-exited canvas {
  opacity: 0;
  transition: opacity 400ms ease;
}

.all-appear-hint {
  text-align: center;
  padding: 14px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-app-canvas);
  animation: hintPulse 2s ease-in-out infinite;
}

@keyframes allAppearFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@media (max-width: 767px) {
  .all-appear-cell .cell-name {
    font-size: 15px;
  }
  .all-appear-cell .cell-overlay {
    padding: 16px 10px 10px;
  }
  .all-appear-hint {
    font-size: 12px;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}
