/* ReplyGenius — Enhanced Styles v4.0 */

/* ── CSS 변수 (라이트/다크 모드) ─────────────────────── */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --sidebar-bg: #ffffff;
  --sidebar-border: #f1f5f9;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.05);
  --accent: #7c3aed;
  --accent-light: #ede9fe;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --border-hover: #475569;
  --sidebar-bg: #1e293b;
  --sidebar-border: #334155;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.3);
}

/* ── 기본 설정 ───────────────────────────────────────── */
html { scroll-behavior: smooth; }
body { 
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

/* 모바일 safe area */
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }

/* 스크롤바 */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── 다크모드 오버라이드 ─────────────────────────────── */
.dark .bg-white { background: var(--bg-secondary) !important; }
.dark .bg-gray-50, .dark .bg-slate-50 { background: var(--bg-primary) !important; }
.dark .bg-gray-100 { background: var(--bg-tertiary) !important; }
.dark .border-gray-100, .dark .border-gray-200 { border-color: var(--border-color) !important; }
.dark .text-slate-900, .dark .text-gray-900 { color: var(--text-primary) !important; }
.dark .text-slate-800, .dark .text-gray-800 { color: var(--text-primary) !important; }
.dark .text-slate-700, .dark .text-gray-700 { color: var(--text-secondary) !important; }
.dark .text-gray-600, .dark .text-gray-500 { color: var(--text-secondary) !important; }
.dark .text-gray-400, .dark .text-gray-300 { color: var(--text-muted) !important; }
.dark aside, .dark #sidebar { background: var(--sidebar-bg) !important; border-color: var(--sidebar-border) !important; }
.dark main { background: var(--bg-primary) !important; }

/* ── 라인 클램프 ─────────────────────────────────────── */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── 토스트 알림 ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 22rem;
}
@media (min-width: 768px) {
  #toast-container { bottom: 1.5rem; }
}
#toast-container > div {
  animation: toast-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ── 로딩 오버레이 ───────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.dark .loading-overlay {
  background: rgba(15, 23, 42, 0.88);
}

/* ── 페이지 트랜지션 ─────────────────────────────────── */
#page-content { 
  animation: page-fade 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes page-fade { 
  from { opacity: 0; transform: translateY(6px); } 
  to { opacity: 1; transform: translateY(0); } 
}

/* ── 카드 효과 ───────────────────────────────────────── */
.card-hover {
  transition: var(--transition);
  box-shadow: var(--card-shadow);
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

/* ── 사이드바 ────────────────────────────────────────── */
.nav-item { 
  transition: all 0.15s ease; 
  position: relative;
  overflow: hidden;
}
.nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #7c3aed, #0ea5e9);
  transform: scaleY(0);
  transition: transform 0.2s ease;
  border-radius: 0 3px 3px 0;
}
.nav-item.active::before { transform: scaleY(1); }

/* ── 모달 ────────────────────────────────────────────── */
[id$="-modal"] { backdrop-filter: blur(6px); }
.animate-modal-in {
  animation: modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── 모바일 사이드바 ─────────────────────────────────── */
#mobile-sidebar-overlay > div {
  animation: slide-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slide-in { 
  from { transform: translateX(-100%); } 
  to { transform: translateX(0); } 
}

/* ── 버튼 포커스 ─────────────────────────────────────── */
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ── 그라데이션 텍스트 ───────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, #a78bfa, #38bdf8, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── 차트 캔버스 ─────────────────────────────────────── */
canvas { max-width: 100%; }

/* ── 스켈레톤 로딩 ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 8px;
}
.dark .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
}
@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ── 펄스 애니메이션 ─────────────────────────────────── */
.animate-pulse-once {
  animation: pulse-once 0.6s ease;
}
@keyframes pulse-once {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.01); }
}

/* ── 플로팅 라벨 ─────────────────────────────────────── */
.float-label {
  position: relative;
}
.float-label label {
  position: absolute;
  left: 1rem; top: 50%;
  transform: translateY(-50%);
  transition: all 0.2s ease;
  pointer-events: none;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.float-label input:focus ~ label,
.float-label input:not(:placeholder-shown) ~ label {
  top: 0.5rem;
  font-size: 0.7rem;
  color: var(--accent);
}

/* ── 통계 카드 카운터 애니메이션 ─────────────────────── */
.count-up {
  animation: count-fade 0.5s ease;
}
@keyframes count-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 차트 wrapper ────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
}

/* ── 다크모드 토글 버튼 ──────────────────────────────── */
.dark-toggle {
  position: relative;
  width: 2.5rem;
  height: 1.375rem;
  background: #e2e8f0;
  border-radius: 99px;
  transition: background 0.3s ease;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
}
.dark .dark-toggle { background: #7c3aed; }
.dark-toggle::after {
  content: '';
  position: absolute;
  top: 0.125rem; left: 0.125rem;
  width: 1.125rem; height: 1.125rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.dark .dark-toggle::after { transform: translateX(1.125rem); }

/* ── 리뷰 카드 선택 효과 ─────────────────────────────── */
.review-card-selected {
  border-color: #7c3aed !important;
  background: #faf5ff !important;
}
.dark .review-card-selected {
  background: rgba(124, 58, 237, 0.1) !important;
}

/* ── 진행바 애니메이션 ───────────────────────────────── */
.progress-bar-animated {
  animation: progress-fill 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes progress-fill {
  from { width: 0 !important; }
}

/* ── 태그 애니메이션 ─────────────────────────────────── */
.badge-pop {
  animation: badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes badge-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ── 반응형 그리드 ───────────────────────────────────── */
@media (max-width: 640px) {
  .grid-responsive-2 { grid-template-columns: 1fr 1fr; }
  .grid-responsive-1 { grid-template-columns: 1fr; }
}

/* ── 인풋 효과 ───────────────────────────────────────── */
input, select, textarea {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* ── 버튼 리플 효과 ──────────────────────────────────── */
.btn-ripple {
  position: relative;
  overflow: hidden;
}
.btn-ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  transform: scale(0);
  transition: transform 0.4s ease, opacity 0.4s ease;
  opacity: 0;
}
.btn-ripple:active::after {
  transform: scale(2);
  opacity: 1;
  transition: none;
}

/* ── 사이드바 아이콘 호버 ────────────────────────────── */
.nav-item:hover .fas {
  transform: scale(1.15);
  transition: transform 0.15s ease;
}

/* ── 빈 상태 ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* ── 별점 ────────────────────────────────────────────── */
.star-filled { color: #f59e0b; }
.star-empty { color: #d1d5db; }

/* ── 반응형 텍스트 ───────────────────────────────────── */
@media (max-width: 480px) {
  h1 { font-size: 1.375rem !important; }
  .text-3xl { font-size: 1.5rem !important; }
}

/* ── 스크롤 부드럽게 ─────────────────────────────────── */
.smooth-scroll { scroll-behavior: smooth; }

/* ── Chart.js 다크모드 ───────────────────────────────── */
.dark canvas { filter: brightness(0.9); }

/* ── 통계 페이지 차트 컨테이너 ──────────────────────── */
.analytics-chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.5rem;
  transition: var(--transition);
}
.analytics-chart-card:hover {
  box-shadow: var(--card-shadow-hover);
}

/* ── 월별 트렌드 바 차트 ─────────────────────────────── */
.trend-bar-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.375rem;
  height: 100px;
}
.trend-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  position: relative;
  min-height: 4px;
}
.trend-bar:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 105%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
}

/* ── 지표 카드 ───────────────────────────────────────── */
.kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.25rem;
  transition: var(--transition);
  cursor: default;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

/* ── 결제 카드 호버 ──────────────────────────────────── */
.pricing-card {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
}
.pricing-card:hover {
  transform: translateY(-4px);
}
.pricing-card.highlight {
  background: linear-gradient(135deg, #7c3aed08, #0ea5e908);
}

/* ── 다크모드 포괄적 오버라이드 v2 ────────────────────── */

/* 카드/패널 배경 */
.dark .bg-white { background: var(--bg-secondary) !important; }
.dark .bg-gray-50 { background: var(--bg-primary) !important; }
.dark .bg-gray-100 { background: var(--bg-tertiary) !important; }
.dark .bg-gray-200 { background: #475569 !important; }
.dark .bg-slate-50 { background: var(--bg-primary) !important; }
.dark .bg-slate-100 { background: var(--bg-tertiary) !important; }

/* 텍스트 */
.dark .text-slate-900,
.dark .text-slate-800,
.dark .text-gray-900,
.dark .text-gray-800 { color: var(--text-primary) !important; }
.dark .text-slate-700,
.dark .text-slate-600,
.dark .text-gray-700,
.dark .text-gray-600 { color: var(--text-secondary) !important; }
.dark .text-slate-500,
.dark .text-gray-500,
.dark .text-gray-400 { color: var(--text-muted) !important; }

/* 보더 */
.dark .border-gray-100,
.dark .border-gray-200,
.dark .border-slate-100,
.dark .border-slate-200 { border-color: var(--border-color) !important; }
.dark .border-gray-300 { border-color: var(--border-hover) !important; }

/* 인풋 필드 */
.dark input,
.dark select,
.dark textarea {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
.dark input:focus,
.dark select:focus,
.dark textarea:focus {
  background: var(--bg-secondary) !important;
  border-color: var(--accent) !important;
}
.dark input::placeholder,
.dark textarea::placeholder { color: var(--text-muted) !important; }

/* 설정 탭 버튼 */
.dark .stab.bg-white {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}
.dark .stab { color: var(--text-muted) !important; }
.dark .stab:hover { color: var(--text-secondary) !important; }

/* 설정 탭 배경 바 */
.dark .bg-gray-100.rounded-2xl { background: var(--bg-secondary) !important; }

/* 토글 스위치 배경 */
.dark .bg-gray-200.rounded-full { background: #334155 !important; }

/* 프로그레스 바 트랙 */
.dark .bg-gray-100.rounded-full,
.dark .bg-gray-200.rounded-full { background: #334155 !important; }

/* 모달 배경 */
.dark [id$="-modal"] { background: rgba(0,0,0,0.75) !important; }
.dark [id$="-modal"] > div,
.dark .modal-content { 
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* 리뷰 카드 */
.dark .review-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* AI 답변 영역 */
.dark .bg-violet-50 { background: rgba(124,58,237,0.12) !important; }
.dark .bg-emerald-50 { background: rgba(16,185,129,0.12) !important; }
.dark .bg-amber-50 { background: rgba(245,158,11,0.12) !important; }
.dark .bg-red-50 { background: rgba(239,68,68,0.12) !important; }
.dark .bg-blue-50 { background: rgba(59,130,246,0.12) !important; }
.dark .bg-sky-50 { background: rgba(14,165,233,0.12) !important; }
.dark .bg-indigo-50 { background: rgba(99,102,241,0.12) !important; }
.dark .bg-purple-50 { background: rgba(168,85,247,0.12) !important; }

/* 보더 컬러 */
.dark .border-violet-100 { border-color: rgba(124,58,237,0.25) !important; }
.dark .border-emerald-100 { border-color: rgba(16,185,129,0.25) !important; }
.dark .border-amber-100 { border-color: rgba(245,158,11,0.25) !important; }
.dark .border-red-100 { border-color: rgba(239,68,68,0.25) !important; }
.dark .border-blue-100 { border-color: rgba(59,130,246,0.25) !important; }

/* 텍스트 컬러 뱃지 */
.dark .text-violet-700 { color: #a78bfa !important; }
.dark .text-emerald-700 { color: #34d399 !important; }
.dark .text-amber-700 { color: #fbbf24 !important; }
.dark .text-red-700 { color: #f87171 !important; }
.dark .text-blue-700 { color: #60a5fa !important; }
.dark .text-sky-700 { color: #38bdf8 !important; }
.dark .text-indigo-700 { color: #818cf8 !important; }

/* 분리선 */
.dark .divide-gray-100 > * + * { border-color: var(--border-color) !important; }
.dark hr { border-color: var(--border-color) !important; }

/* 체크박스 */
.dark input[type="checkbox"] { background: var(--bg-tertiary); }

/* 가격 페이지 카드 */
.dark .pricing-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}
.dark .pricing-card.highlight {
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(14,165,233,0.15)) !important;
}

/* 사이드바 내비 항목 호버 */
.dark .nav-item:hover {
  background: rgba(255,255,255,0.05) !important;
}
.dark .nav-item.active {
  background: rgba(124,58,237,0.12) !important;
}

/* 헤더 */
.dark header {
  background: rgba(15,23,42,0.95) !important;
  border-color: var(--border-color) !important;
}

/* 배경 그라디언트 섹션 (랜딩 페이지 제외) */
.dark .from-slate-50.to-white,
.dark .from-gray-50.to-white { 
  background: var(--bg-primary) !important; 
}

/* 설정 페이지 tone radio 라벨 */
.dark label.border-gray-100 {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
}
.dark label.border-gray-100:hover {
  background: var(--bg-secondary) !important;
}

/* 분석 페이지 플랫폼 아이템 */
.dark .bg-gray-50.rounded-xl {
  background: var(--bg-tertiary) !important;
}
.dark .bg-gray-50.rounded-xl:hover {
  background: var(--bg-secondary) !important;
}

/* 채널 연동 페이지 */
.dark .bg-white\/80 { background: rgba(30,41,59,0.8) !important; }
.dark .bg-white\/90 { background: rgba(30,41,59,0.9) !important; }

/* 테이블 */
.dark table { background: var(--bg-secondary) !important; }
.dark th { 
  background: var(--bg-tertiary) !important; 
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}
.dark td { 
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
.dark tr:hover td { background: rgba(255,255,255,0.03) !important; }

/* 페이지네이션 */
.dark .page-btn {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}
.dark .page-btn:hover {
  background: var(--bg-tertiary) !important;
}
