/* ─────────────────────────────────────────────────────
   농업 공고·공모 모아보기 — 메인 스타일시트
   Design: Dark Green Premium, Glassmorphism
───────────────────────────────────────────────────── */

/* ── 디자인 토큰 ─────────────────────────────────── */
:root {
  --bg-base:       #0d1117;
  --bg-surface:    #161b22;
  --bg-elevated:   #1c2128;
  --bg-hover:      #21262d;

  --border:        rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);

  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #6e7681;

  --green-400:     #4ade80;
  --green-500:     #22c55e;
  --green-600:     #16a34a;
  --green-700:     #15803d;
  --green-glow:    rgba(34,197,94,0.15);

  --blue-400:      #60a5fa;
  --blue-500:      #3b82f6;
  --purple-500:    #a855f7;
  --cyan-500:      #06b6d4;
  --red-500:       #ef4444;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     20px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
  --shadow:        0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.6);

  --transition:    0.18s cubic-bezier(0.4,0,0.2,1);

  --header-h:      72px;
  --stats-h:       64px;
}

/* ── 리셋 & 기반 ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Pretendard', 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ── 헤더 ────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(13,17,23,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 12px var(--green-500));
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--green-400), #86efac);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.meta-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-500);
  flex-shrink: 0;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}
.blink { animation: blink 2s infinite; }

/* ── 통계 바 ─────────────────────────────────────── */
.stats-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  height: var(--stats-h);
  overflow-x: auto;
}

.stats-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}
.stat-item:hover { background: var(--bg-hover); }

.stat-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-num {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

#stat-total .stat-num {
  font-size: 1.2rem;
  color: var(--green-400);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ── 레이아웃 ────────────────────────────────────── */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── 사이드바 ────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.sidebar-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: 0.2px;
}

.form-group { margin-bottom: 18px; }
.form-group:last-of-type { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 9px 30px 9px 32px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px var(--green-glow);
}
.search-input::placeholder { color: var(--text-muted); }

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  display: none;
}
.search-clear:hover { color: var(--text-primary); background: var(--bg-hover); }
.search-clear.visible { display: block; }

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.chip:hover {
  border-color: var(--chip-color, var(--green-600));
  color: var(--chip-color, var(--green-400));
}
.chip.chip-active {
  background: var(--chip-color, var(--green-700));
  border-color: var(--chip-color, var(--green-600));
  color: white;
}

.form-select {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 9px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236e7681'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
}
.form-select:focus { border-color: var(--green-600); }
.form-select option { background: var(--bg-surface); }

.sidebar-footer { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }

.btn-reset {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-reset:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.sidebar-info { display: flex; flex-direction: column; }

.crawl-history {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crawl-history li {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ── 메인 콘텐츠 ─────────────────────────────────── */
.main-content { min-width: 0; }

/* 결과 바 */
.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.result-count {
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.result-count strong { color: var(--green-400); }

.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.view-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}
.view-btn.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.view-btn:hover { color: var(--text-primary); }

/* ── 카드 그리드 뷰 ──────────────────────────────── */
.notice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.notice-grid.list-view {
  grid-template-columns: 1fr;
  gap: 8px;
}

/* ── 공고 카드 ───────────────────────────────────── */
.notice-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}
.notice-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--green-glow), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.notice-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--green-700);
}
.notice-card:hover::before { opacity: 1; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  position: relative;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
}
.badge-bizinfo    { background: rgba(59,130,246,0.15); color: var(--blue-400); border-color: rgba(59,130,246,0.25); }
.badge-mafra      { background: rgba(34,197,94,0.12);  color: var(--green-400); border-color: rgba(34,197,94,0.25); }
.badge-koat       { background: rgba(168,85,247,0.15); color: #c084fc; border-color: rgba(168,85,247,0.25); }
.badge-smartfarm  { background: rgba(6,182,212,0.15);  color: #67e8f9; border-color: rgba(6,182,212,0.25); }
.badge-default    { background: rgba(255,255,255,0.08); color: var(--text-secondary); }

.card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.card-org {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-arrow {
  font-size: 0.9rem;
  color: var(--green-500);
  transition: transform var(--transition);
}
.notice-card:hover .card-arrow { transform: translateX(4px); }

/* ── 리스트 아이템 ────────────────────────────────── */
.notice-list-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: all var(--transition);
}
.notice-list-item:hover {
  background: var(--bg-hover);
  border-color: var(--green-700);
}

.list-badge { flex-shrink: 0; }
.list-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-org {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.list-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.list-arrow {
  font-size: 0.85rem;
  color: var(--green-500);
  flex-shrink: 0;
}

/* ── 빈 상태 ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-sub { font-size: 0.85rem; color: var(--text-muted); }

/* ── 로딩 ─────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--text-secondary);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── 카드 진입 애니메이션 ─────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.notice-card, .notice-list-item {
  animation: fadeInUp 0.25s both;
}

/* ── 반응형 ───────────────────────────────────────── */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 220px 1fr;
    padding: 20px 16px;
    gap: 16px;
  }
  .notice-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .sidebar {
    position: static;
    order: -1;
  }
  .stats-inner { gap: 0; }
  .stat-item { padding: 6px 10px; }
  .stat-label { display: none; }
  .notice-grid { grid-template-columns: 1fr; }
  .header-meta { display: none; }
  .notice-list-item {
    grid-template-columns: auto 1fr auto;
  }
  .list-org, .list-arrow { display: none; }
}
