/* === Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f172a; color: #e2e8f0; line-height: 1.6; }
a { color: #60a5fa; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navbar === */
.navbar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.5rem; background: #1e293b; border-bottom: 1px solid #334155; }
.nav-brand { font-size: 1.25rem; font-weight: 700; color: #f8fafc; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: #94a3b8; }
.nav-links a:hover { color: #f8fafc; text-decoration: none; }

/* === Container === */
.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

/* === Buttons === */
.btn { display: inline-block; padding: 0.5rem 1rem; border-radius: 6px; border: none; cursor: pointer; font-size: 0.875rem; font-weight: 500; text-decoration: none; transition: opacity 0.2s; color: white; }
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-primary { background: #3b82f6; }
.btn-secondary { background: #475569; }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-full { width: 100%; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0.25rem 0.5rem; color: #94a3b8; }
.btn-icon:hover { color: #f8fafc; }
.btn-danger { color: #f87171; }
.btn-danger:hover { color: #ef4444; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-size: 0.875rem; color: #94a3b8; }
.form-group label small { color: #64748b; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid #334155; border-radius: 6px; background: #1e293b; color: #e2e8f0; font-size: 0.875rem; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: #3b82f6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-error { background: #7f1d1d; color: #fca5a5; }

/* === Login === */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #1e293b; padding: 2rem; border-radius: 12px; width: 100%; max-width: 400px; border: 1px solid #334155; }
.login-card h1 { text-align: center; margin-bottom: 0.5rem; }
.login-card .subtitle { text-align: center; color: #94a3b8; margin-bottom: 1.5rem; }

/* === Dashboard === */
.dashboard-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.run-info { color: #94a3b8; font-size: 0.8rem; }
.empty-state { text-align: center; padding: 3rem; color: #64748b; }

.research-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.research-card { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 1.25rem; transition: border-color 0.2s; }
.research-card:hover { border-color: #475569; }
.card-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.75rem; }
.card-header h3 { font-size: 1rem; }
.card-summary { font-size: 0.85rem; color: #94a3b8; margin-bottom: 0.75rem; line-height: 1.4; }
.card-links { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
.link-finn { background: #1d4ed8; color: white; padding: 0.25rem 0.75rem; border-radius: 4px; font-size: 0.75rem; }
.link-temu { background: #ea580c; color: white; padding: 0.25rem 0.75rem; border-radius: 4px; font-size: 0.75rem; }
.card-footer { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #334155; padding-top: 0.75rem; }
.card-date { font-size: 0.75rem; color: #64748b; }
.card-actions { display: flex; gap: 0.25rem; }

/* === Score Badges === */
.score-badge { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.score-high { background: #166534; color: #4ade80; }
.score-mid { background: #713f12; color: #facc15; }
.score-low { background: #7f1d1d; color: #f87171; }
.score-none { background: #334155; color: #94a3b8; }

/* === Search Portal === */
.search-section { margin-bottom: 1.5rem; }
.search-bar { display: flex; gap: 0.75rem; max-width: 600px; }
.search-bar input { flex: 1; padding: 0.75rem; border: 1px solid #334155; border-radius: 6px; background: #1e293b; color: #e2e8f0; font-size: 1rem; }
.url-details { margin-top: 0.75rem; }
.url-details summary { color: #64748b; font-size: 0.85rem; cursor: pointer; }
.search-urls { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.75rem; padding: 1rem; background: #1e293b; border-radius: 8px; }
.panel { background: #1e293b; border: 1px solid #334155; border-radius: 10px; overflow: hidden; }
.panel-header { padding: 0.75rem 1rem; border-bottom: 1px solid #334155; display: flex; align-items: center; justify-content: space-between; }
.panel-header h2 { font-size: 1rem; margin: 0; }
.result-count { background: #334155; padding: 0.1rem 0.5rem; border-radius: 10px; font-size: 0.75rem; margin-left: 0.5rem; }
.save-section { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 1.5rem; }
.save-form .form-row { margin-bottom: 0; }

/* === Loading Animation === */
.loading-state { padding: 2rem; }
.loading-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; width: 100%; max-width: 700px; margin: 0 auto; }
.loading-card { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 1.5rem; text-align: center; }
.loading-icon { font-size: 2rem; font-weight: 800; margin-bottom: 1rem; }
.finn-loading .loading-icon { color: #3b82f6; }
.temu-loading .loading-icon { color: #f97316; }
.loading-bar { width: 100%; height: 6px; background: #334155; border-radius: 3px; margin-bottom: 0.75rem; overflow: hidden; }
.loading-progress { height: 100%; border-radius: 3px; transition: width 0.8s ease-out; width: 0%; }
.finn-loading .loading-progress { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.temu-loading .loading-progress { background: linear-gradient(90deg, #f97316, #fb923c); }
.loading-card span { font-size: 0.8rem; color: #94a3b8; }

/* === Search Results Items === */
.results-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.items-list { display: flex; flex-direction: column; max-height: 600px; overflow-y: auto; }
.item-row { display: flex; gap: 0.75rem; padding: 0.6rem 0.75rem; align-items: center; border-bottom: 1px solid #1e293b; transition: background 0.15s; color: #e2e8f0; text-decoration: none; }
.item-row:hover { background: #0f172a; text-decoration: none; }
.item-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: #334155; }
.item-details { flex: 1; min-width: 0; }
.item-title { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.15rem; }
.item-meta { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.item-price { color: #4ade80; font-weight: 600; font-size: 0.8rem; }
.item-favs { color: #f87171; font-size: 0.75rem; }
.item-sold { color: #f97316; font-size: 0.75rem; }
.item-rating { color: #facc15; font-size: 0.75rem; }
.item-loc { color: #64748b; font-size: 0.7rem; }
.temu-link { color: #f97316; font-weight: 400; font-size: 0.75rem; }

/* === Detail Page === */
.detail-header { margin-bottom: 1.5rem; }
.back-link { font-size: 0.85rem; color: #94a3b8; display: inline-block; margin-bottom: 0.5rem; }
.detail-meta { display: flex; gap: 1rem; align-items: center; margin-top: 0.5rem; font-size: 0.85rem; color: #94a3b8; }
.ai-summary-box { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 1.25rem; margin-bottom: 1.5rem; }
.ai-summary-box h3 { font-size: 1rem; margin-bottom: 0.5rem; color: #60a5fa; }
.edit-section { background: #1e293b; border: 1px solid #334155; border-radius: 10px; margin-bottom: 1rem; }
.edit-section summary { padding: 0.75rem 1rem; cursor: pointer; color: #94a3b8; }
.edit-section .save-form { padding: 1rem; }
.source-links { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; }

/* === Snapshot === */
.snapshot-section { margin-bottom: 1.5rem; }
.snapshot-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.items-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.items-table th, .items-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid #334155; }
.items-table th { color: #94a3b8; font-weight: 500; }
.muted { color: #64748b; font-size: 0.8rem; }

/* === Analysis History === */
.analysis-section { margin-bottom: 1.5rem; }
.chart-container { background: #1e293b; border-radius: 10px; padding: 1rem; margin-bottom: 1rem; max-height: 300px; }
.analysis-list { display: flex; flex-direction: column; gap: 0.75rem; }
.analysis-entry { display: flex; gap: 0.75rem; align-items: flex-start; background: #1e293b; border-radius: 8px; padding: 1rem; border: 1px solid #334155; }
.analysis-date { font-size: 0.8rem; color: #94a3b8; white-space: nowrap; min-width: 80px; }
.analysis-content { flex: 1; }
.analysis-content p { font-size: 0.85rem; margin-bottom: 0.25rem; }

/* === Responsive === */
@media (max-width: 768px) {
    .results-panels, .snapshot-panels, .form-row, .search-urls, .loading-cards { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; align-items: flex-start; }
}
