/*
 * URLFavorites — Application Styles
 */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #273549;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --purple: #a855f7;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── 헤더 ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.app-header form {
  display: flex;
  flex: 1;
  gap: 8px;
  max-width: 640px;
}

.url-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.url-input:focus {
  border-color: var(--accent);
}
.url-input::placeholder {
  color: var(--text-dim);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

/* ── 메인 레이아웃 ── */
.board-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 57px);
}

/* ── 즐겨찾기 목록 ── */
.favorites-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.favorites-list::-webkit-scrollbar {
  width: 4px;
}
.favorites-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── 탭 네비게이션 ── */
.type-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.type-tab {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.type-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.type-tab.active {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.type-tab-github.active {
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(168, 85, 247, 0.1);
}
.type-tab-youtube.active {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
}

/* ── 대분류 섹션 ── */
.type-section {
  margin-bottom: 4px;
}
.type-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 6px 10px 4px;
  color: var(--text-dim);
}
.type-header-github {
  color: #d8b4fe;
}
.type-header-youtube {
  color: #fca5a5;
}
.type-header-webpage {
  color: var(--text-dim);
}

/* ── 개별 항목 ── */
.favorite-item {
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid transparent;
  transition:
    background 0.15s,
    border-color 0.15s;
  overflow: hidden;
  flex-shrink: 0;
}
.favorite-item:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.favorite-item.selected {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid #3b82f6;
}
.favorite-item a {
  display: block;
  padding: 12px;
  text-decoration: none;
  color: inherit;
}

.favorite-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.favicon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 2px;
}
.favorite-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.favorite-summary {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.analyzing {
  font-size: 12px;
  color: var(--yellow);
  font-style: italic;
}
.error {
  font-size: 12px;
  color: var(--red);
}

/* ── 배지 ── */
.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-youtube {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
.badge-github {
  background: rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
}
.badge-done {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}
.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}
.badge-analyzing {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}
.badge-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* ── 태그 ── */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  font-weight: 500;
}

.btn-retry {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  cursor: pointer;
  margin-top: 6px;
}
.btn-retry:hover {
  background: rgba(239, 68, 68, 0.35);
}

/* ── 분석 패널 ── */
turbo-frame#analysis_panel {
  display: contents;
}

.empty-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 14px;
}

.analysis-panel {
  padding: 28px 32px;
  overflow-y: auto;
  height: 100%;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.panel-header h2 {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}

.btn-link {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-link:hover {
  background: var(--bg-hover);
}

.btn-danger {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 7px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* YouTube 메타 */
.youtube-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.thumbnail {
  width: 200px;
  border-radius: 8px;
  flex-shrink: 0;
}
.meta-info {
  font-size: 12px;
  color: var(--text-muted);
}
.subtitle-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
}

/* 패널 섹션 */
.panel-section {
  margin-bottom: 20px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel-section h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.panel-section p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}
.panel-section ul {
  padding-left: 18px;
}
.panel-section li {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 4px;
}
.timestamp {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 6px;
}
.panel-section .tags {
  margin-top: 0;
}

.panel-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
}

/* 분석 중 */
.analyzing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--yellow);
  font-size: 14px;
  padding: 24px;
}
.analyzing-indicator::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--yellow);
  animation: pulse 1.2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.75);
  }
}

/* 반응형 */
@media (max-width: 768px) {
  .board-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 280px 1fr;
  }
  .favorites-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .analysis-panel {
    padding: 16px;
  }
  .app-header {
    flex-wrap: wrap;
  }
}

/* ── 로그인 페이지 ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
    var(--bg);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.03);
  animation: cardEntrance 0.5s ease-out;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 24px;
  box-shadow: 0 8px 24px -4px rgba(59, 130, 246, 0.4);
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.login-logo p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 14px 16px;
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-input::placeholder {
  color: var(--text-dim);
}

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
  box-shadow: 0 4px 14px -2px rgba(59, 130, 246, 0.4);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -2px rgba(59, 130, 246, 0.5);
}

.login-btn:active {
  transform: translateY(0);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.login-footer a {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.login-footer a:hover {
  color: var(--text);
}

.login-alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
  animation: shake 0.4s ease;
}

.login-alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.login-alert-notice {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
