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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
  min-height: 100vh;
  color: #e4e4e7;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  color: #a1a1aa;
  font-size: 1.1rem;
}

/* Search Form */
.search-form {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 40px;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.form-row input {
  flex: 1;
  padding: 14px 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.form-row input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-row input::placeholder {
  color: #71717a;
}

.form-row button {
  padding: 14px 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-row button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.form-hint {
  font-size: 0.85rem;
  color: #71717a;
  margin: 0;
}

/* Feed Rows Section */
.feeds-section {
  margin-top: 20px;
}

.feeds-header {
  margin-bottom: 16px;
}

.feeds-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #e4e4e7;
  margin-bottom: 4px;
}

#feed-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  transition: all 0.3s ease;
}

.feed-row:hover {
  border-color: rgba(102, 126, 234, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.row-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

/* Feed column labels */
.feed-labels {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 8px;
}

.feed-label {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 600;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.label-spacer {
  width: 28px;
  flex-shrink: 0;
}

.label-spacer-btn {
  width: 36px;
  flex-shrink: 0;
}

.feed-row select {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #e4e4e7;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.feed-row select:hover,
.feed-row select:focus {
  border-color: #667eea;
  outline: none;
}

.feed-row select option {
  background: #1a1a2e;
  color: #e4e4e7;
}

.btn-add,
.btn-remove {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  font-size: 1.4rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-add {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.btn-add:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-remove {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-remove:hover {
  background: rgba(239, 68, 68, 0.3);
  transform: scale(1.1);
}

/* Keep old form-options for compatibility but hide */
.form-options {
  display: none;
}
  color: #e4e4e7;
  padding: 8px 12px;
}

.form-options select option:checked {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.form-options select option:hover {
  background: rgba(102, 126, 234, 0.3);
}

/* Results Section */
.results h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  color: #fff;
}

.news-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* News Card */
.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  transition: all 0.3s ease;
  position: relative;
  animation: slideIn 0.5s ease forwards;
  animation-delay: calc(var(--rank) * 0.1s);
  opacity: 0;
  transform: translateY(20px);
}

@keyframes slideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card:hover {
  border-color: rgba(102, 126, 234, 0.5);
  transform: translateX(8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.rank-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 20px;
  z-index: 10;
}

.card-image {
  width: 280px;
  min-height: 180px;
  flex-shrink: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card:hover .card-image img {
  transform: scale(1.05);
}

.card-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
}

.card-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.4;
}

.card-content h3 a {
  color: #fff;
  text-decoration: none;
  transition: color 0.3s ease;
}

.card-content h3 a:hover {
  color: #667eea;
}

.meta {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.source {
  background: rgba(102, 126, 234, 0.2);
  color: #a5b4fc;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.topic {
  background: rgba(118, 75, 162, 0.2);
  color: #c4b5fd;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.stats {
  display: flex;
  gap: 16px;
  color: #71717a;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.ai-score {
  color: #4ade80;
  font-weight: 500;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #52525b;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.8rem;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .card {
    flex-direction: column;
  }
  
  .card-image {
    width: 100%;
    height: 200px;
  }
  
  .rank-badge {
    top: 12px;
    left: 12px;
  }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 26, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-content {
  text-align: center;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(102, 126, 234, 0.2);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 1.4rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loading-subtext {
  font-size: 0.9rem;
  color: #71717a;
  animation: pulse 2s ease-in-out infinite;
}

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

/* ===== Prompt Engineering Section ===== */
.prompt-engineering,
.result-stats {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  margin-top: 40px;
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.3s ease;
}

.section-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #e4e4e7;
}

.toggle-icon {
  font-size: 0.9rem;
  color: #71717a;
  transition: transform 0.3s ease;
}

.section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
  padding: 0 24px;
}

.section-content.expanded {
  max-height: 2000px;
  padding: 24px;
}

.prompt-group {
  margin-bottom: 20px;
}

.prompt-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #a1a1aa;
  margin-bottom: 8px;
}

.prompt-hint {
  font-size: 0.8rem;
  color: #71717a;
  margin-bottom: 8px;
}

.prompt-hint code {
  background: rgba(102, 126, 234, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', monospace;
  color: #667eea;
}

.prompt-group textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: #e4e4e7;
  font-family: 'Fira Code', 'Monaco', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  transition: all 0.3s ease;
}

.prompt-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.prompt-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-save,
.btn-reset {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-save {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.btn-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.btn-reset {
  background: rgba(255, 255, 255, 0.1);
  color: #a1a1aa;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-reset:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

#save-status {
  font-size: 0.85rem;
  margin-left: 12px;
}

#save-status.saving { color: #f59e0b; }
#save-status.success { color: #10b981; }
#save-status.error { color: #ef4444; }

/* ===== Result Statistics Section ===== */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.logs-container {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  overflow: hidden;
}

.logs-container h4 {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  font-weight: 600;
  color: #a1a1aa;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-output {
  padding: 16px;
  font-family: 'Fira Code', 'Monaco', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #10b981;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.log-output::-webkit-scrollbar {
  width: 8px;
}

.log-output::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.log-output::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: 4px;
}

.log-output::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}
