/* CSS Reset & Variables */
:root {
  --bg-color: #08090f;
  --panel-bg: rgba(13, 15, 24, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f2f6;
  --text-secondary: #a4b0be;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-red: #ef4444;
  --glow-blue: rgba(59, 130, 246, 0.15);
  --glow-purple: rgba(139, 92, 246, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', 'Noto Sans KR', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background glows */
.bg-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.4;
  pointer-events: none;
}

.bg-glow-purple {
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
  top: -100px;
  right: -100px;
}

.bg-glow-blue {
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
}

/* Header styling (matching portal) */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 40px;
  height: 70px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: var(--panel-border);
}

.glass-header {
  background: rgba(8, 9, 15, 0.75);
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-text span {
  color: var(--accent-blue);
  background: linear-gradient(90deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-nav {
  display: flex;
  align-items: center;
}

.nav-list {
  display: flex;
  list-style: none;
  gap: 20px;
}

.nav-list a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  padding: 6px 12px;
  border-radius: 20px;
}

.nav-list a:hover, .nav-list a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.btn-back-dashboard {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-back-dashboard:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* Glass Panels */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Main Container */
.assembly-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* Header Section */
.assembly-header-section {
  text-align: center;
  padding: 20px 0;
}

.assembly-header-section .main-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.assembly-header-section .main-title i {
  color: var(--accent-blue);
}

.assembly-header-section .main-title span {
  background: linear-gradient(90deg, #60a5fa, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle-desc {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

.tag-badges {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Search Panel */
.search-panel {
  padding: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.panel-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-status {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.btn-turso-cache {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #a78bfa;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-turso-cache:hover {
  background: rgba(139, 92, 246, 0.25);
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

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

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input, .select-wrapper select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  width: 100%;
  transition: all 0.3s ease;
}

.form-group input:focus, .select-wrapper select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
  background: rgba(255, 255, 255, 0.05);
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.select-wrapper select {
  appearance: none;
  cursor: pointer;
  padding-right: 36px;
}

.select-wrapper i {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  font-size: 0.8rem;
}

.form-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  grid-column: span 1;
}

.btn-search {
  background: #3b82f6;
  border: none;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-grow: 1;
  transition: all 0.3s ease;
}

.btn-search:hover {
  background: #2563eb;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.btn-reset {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-reset:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Party Stats Bar */
.party-stats-bar {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.party-label {
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.party-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #fff;
}

.party-item {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.party-item span {
  font-weight: 700;
  color: var(--accent-blue);
  margin-left: 4px;
}

.loading-text {
  color: var(--text-secondary);
  font-style: italic;
}

/* Results Panel & Timeline */
.results-panel {
  padding: 24px;
}

.results-header {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 20px;
}

.results-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.results-title-row h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.badge-term-title {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Timeline grid slider */
.timeline-container {
  overflow-x: auto;
  padding-bottom: 8px;
}

.timeline-grid {
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.timeline-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 52px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 4px;
}

.timeline-btn strong {
  font-size: 0.75rem;
  color: #fff;
  margin-bottom: 2px;
}

.timeline-btn span {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

/* Custom border colors for timeline buttons to map the mockup */
/* Group 1-4 (Syngman Rhee): dark gray */
.timeline-btn[data-term="제1대"],
.timeline-btn[data-term="제2대"],
.timeline-btn[data-term="제3대"],
.timeline-btn[data-term="제4대"] {
  border-color: rgba(100, 116, 139, 0.4);
}
/* Group 5 (Yun Bo-seon): orange/yellow */
.timeline-btn[data-term="제5대"] {
  border-color: rgba(234, 179, 8, 0.4);
}
/* Group 6-9 (Park Chung-hee): green */
.timeline-btn[data-term="제6대"],
.timeline-btn[data-term="제7대"],
.timeline-btn[data-term="제8대"],
.timeline-btn[data-term="제9대"] {
  border-color: rgba(34, 197, 94, 0.4);
}
/* Group 10 (Choi Kyu-hah): teal */
.timeline-btn[data-term="제10대"] {
  border-color: rgba(20, 184, 166, 0.4);
}
/* Group 11-12 (Chun Doo-hwan): blue */
.timeline-btn[data-term="제11대"],
.timeline-btn[data-term="제12대"] {
  border-color: rgba(59, 130, 246, 0.4);
}
/* Group 13 (Roh Tae-woo): purple */
.timeline-btn[data-term="제13대"] {
  border-color: rgba(168, 85, 247, 0.4);
}
/* Group 14-15 (YS & DJ): orange-red */
.timeline-btn[data-term="제14대"],
.timeline-btn[data-term="제15대"] {
  border-color: rgba(249, 115, 22, 0.4);
}
/* Group 16-17 (Roh Moo-hyun & MB): green-blue */
.timeline-btn[data-term="제16대"],
.timeline-btn[data-term="제17대"] {
  border-color: rgba(16, 185, 129, 0.4);
}
/* Group 18-19 (MB & Park Geun-hye): blue-indigo */
.timeline-btn[data-term="제18대"],
.timeline-btn[data-term="제19대"] {
  border-color: rgba(79, 70, 229, 0.4);
}
/* Group 20-21 (Park & Moon): purple-magenta */
.timeline-btn[data-term="제20대"],
.timeline-btn[data-term="제21대"] {
  border-color: rgba(236, 72, 153, 0.4);
}
/* Active style: solid red background as in mockup */
.timeline-btn.active {
  background: var(--accent-red) !important;
  border-color: var(--accent-red) !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.timeline-btn.active strong, .timeline-btn.active span {
  color: #fff !important;
}

.timeline-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

/* Query Metadata Row */
.meta-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.meta-info-row .highlight {
  color: #fff;
  font-weight: 600;
}

.meta-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pagination-summary {
  font-weight: 500;
}

/* View Mode & Page Navigation */
.view-mode-group, .nav-page-group {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 2px;
}

.btn-view-mode, .btn-nav {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.btn-view-mode.active, .btn-view-mode:hover, .btn-nav:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.btn-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Results Content Area - Portrait Cards Grid */
.members-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
}

/* Individual card */
.member-card {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
}

.member-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(59, 130, 246, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.member-photo-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.member-photo-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.member-card:hover .member-photo-wrapper img {
  transform: scale(1.05);
}

.member-info-wrapper {
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.member-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.member-party {
  font-size: 0.75rem;
  font-weight: 600;
}

/* Party colors */
.party-minjoo { color: #60a5fa; } /* 더불어민주당 / 더불어민주연합 */
.party-kukmin { color: #f87171; } /* 국민의힘 / 국민의미래 / 미래통합당 */
.party-jookuk { color: #38bdf8; } /* 조국혁신당 */
.party-gaehyuk { color: #fb923c; } /* 개혁신당 */
.party-jinbo { color: #f43f5e; } /* 진보당 */
.party-saero { color: #a78bfa; } /* 새로운미래 */
.party-etc { color: var(--text-secondary); }

.member-district {
  font-size: 0.7rem;
  color: var(--text-secondary);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* List Table View */
.members-list-view {
  overflow-x: auto;
}

.members-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.members-table th, .members-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
}

.members-table th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
}

.members-table td {
  color: var(--text-primary);
  font-size: 0.85rem;
}

.members-table tbody tr {
  cursor: pointer;
  transition: all 0.2s ease;
}

.members-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table-photo {
  width: 32px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
}

/* Empty State / Loading State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  width: 100%;
  grid-column: 1 / -1;
  color: var(--text-secondary);
  gap: 16px;
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--panel-border);
}

.empty-state p {
  font-size: 0.9rem;
}

/* Modal details popup */
.detail-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.detail-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.detail-modal-content {
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  padding: 30px;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.detail-modal-overlay.open .detail-modal-content {
  transform: translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(90deg);
}

.modal-body-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 30px;
}

.modal-profile-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.modal-photo-wrapper {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.modal-photo-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-profile-header {
  text-align: center;
}

.modal-profile-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.modal-hanja, .modal-eng {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.modal-party-badge {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
}

.modal-info-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.info-section h4 {
  font-size: 0.9rem;
  font-weight: 700;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.info-section h4 i {
  color: var(--accent-blue);
}

.info-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.info-item {
  display: flex;
  font-size: 0.85rem;
  gap: 8px;
}

.info-item strong {
  width: 70px;
  color: var(--text-secondary);
  font-weight: 500;
  flex-shrink: 0;
}

.info-item span, .info-item a {
  color: var(--text-primary);
}

.info-item a {
  color: var(--accent-blue);
  text-decoration: none;
}

.info-item a:hover {
  text-decoration: underline;
}

.modal-committees-text {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.modal-career-box {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--panel-border);
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.modal-career-item {
  margin-bottom: 6px;
}

/* Toast Notifications */
.toast-notification {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(13, 15, 24, 0.9);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive Rules */
@media (max-width: 1024px) {
  .assembly-container {
    padding: 20px;
  }
  .main-header {
    padding: 0 20px;
  }
}

@media (max-width: 768px) {
  .search-grid {
    grid-template-columns: 1fr;
  }
  .modal-body-grid {
    grid-template-columns: 1fr;
  }
  .modal-photo-wrapper {
    width: 160px;
  }
  .info-details-grid {
    grid-template-columns: 1fr;
  }
  .meta-info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .meta-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .header-nav {
    display: none; /* Hide nav on mobile */
  }
}
