/* ============================================
   태그 검색 — Apple Minimal
   ============================================ */

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

html {
  font-family: var(--font-sans);
  background: #ffffff;
  color: #1d1d1f;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

/* ── Page Content ── */
.page {
  flex: 1;
  padding-top: 48px;
}

.tag-search-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 52px 24px 80px;
}

/* ── Page Header ── */
.tag-search-header {
  margin-bottom: 40px;
}

.tag-search-header h1 {
  font-size: var(--text-4xl, 36px);
  font-weight: 800;
  letter-spacing: -1px;
  color: #1d1d1f;
  margin-bottom: 8px;
  animation: fadeInUp 0.6s ease-out;
}

.tag-search-description {
  font-size: var(--text-base, 16px);
  color: #86868b;
  margin: 0;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

/* ── Search Section ── */
.tag-search-section {
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin-bottom: 40px;
  box-shadow: none;
  animation: fadeInUp 0.6s ease-out 0.15s both;
}

.search-input-wrapper {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tag-search-input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: #f5f5f7;
  border-radius: 12px;
  font-size: 15px;
  font-family: var(--font-sans);
  color: #1d1d1f;
  transition: all 0.2s;
  outline: none;
}

.tag-search-input:focus {
  background: #efefef;
  box-shadow: 0 0 0 4px rgba(29, 47, 78, 0.08);
}

.tag-search-input::placeholder { color: #aeaeb2; }

.tag-search-button {
  padding: 12px 24px;
  background: #1D2F4E;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  font-family: var(--font-sans);
}

.tag-search-button:hover { background: #2a4366; }
.tag-search-button:active { background: #1a2a3f; }

/* ── Autocomplete ── */
.tag-autocomplete {
  position: relative;
  margin-bottom: 12px;
}

.autocomplete-dropdown {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
}

.autocomplete-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.15s;
  font-size: 14px;
}

.autocomplete-item:hover { background: #f5f5f7; }
.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-tag {
  display: inline-block;
  background: rgba(29, 47, 78, 0.06);
  color: #1D2F4E;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-right: 8px;
}

.autocomplete-count {
  color: #aeaeb2;
  font-size: 13px;
  float: right;
}

/* ── Selected Tags ── */
.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  min-height: 0;
}

.selected-tag {
  display: inline-flex;
  align-items: center;
  background: #1D2F4E;
  color: #fff;
  padding: 6px 12px;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 500;
  gap: 6px;
}

.selected-tag-remove {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 18px; height: 18px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 0;
  transition: background 0.2s;
}

.selected-tag-remove:hover { background: rgba(255,255,255,0.35); }

/* ── Popular Tags ── */
.popular-tags-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.popular-tags-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.popular-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.popular-tag {
  display: inline-block;
  background: #f5f5f7;
  color: #1d1d1f;
  padding: 7px 14px;
  border: none;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.popular-tag:hover {
  background: #1D2F4E;
  color: #fff;
}

.popular-tag-count {
  margin-left: 4px;
  color: #aeaeb2;
  font-size: 11px;
  transition: color 0.2s;
}

.popular-tag:hover .popular-tag-count {
  color: rgba(255,255,255,0.6);
}

.loading-tags {
  color: #aeaeb2;
  font-size: 13px;
}

/* ── Filter Section ── */
.filter-section {
  display: flex;
  gap: 12px;
  margin-bottom: 40px;
  flex-wrap: wrap;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.filter-group {
  flex: 1;
  min-width: 120px;
}

.filter-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.filter-select {
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: #f5f5f7;
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: #1d1d1f;
  cursor: pointer;
  outline: none;
  transition: background 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23aeaeb2' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.filter-select:focus {
  background-color: #efefef;
  box-shadow: 0 0 0 4px rgba(29, 47, 78, 0.08);
}

.admin-only-toggle {
  flex: 0 !important;
  min-width: auto !important;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #aeaeb2;
  white-space: nowrap;
  margin-top: 20px;
}

/* ── Results ── */
.search-results-section {
  margin-top: 0;
  animation: fadeInUp 0.6s ease-out 0.25s both;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.results-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1d1d1f;
  margin: 0;
}

.results-count {
  font-size: 14px;
  color: #86868b;
  font-weight: 500;
}

.search-results {
  display: grid;
  gap: 0;
}

/* ── Question Card ── */
.question-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  border-radius: 0;
  padding: 20px 0;
  transition: background 0.2s;
  cursor: pointer;
}

.question-card:first-child {
  border-top: 1px solid rgba(0,0,0,0.06);
}

.question-card:hover {
  background: rgba(0,0,0,0.02);
  box-shadow: none;
}

.question-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0;
}

.question-card-info { flex: 1; }

.question-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 4px;
  line-height: 1.4;
}

.question-card-meta {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: #86868b;
}

.question-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.question-card-tag {
  display: inline-block;
  background: rgba(29, 47, 78, 0.06);
  color: #1D2F4E;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s;
}

.question-card-tag.active {
  background: #1D2F4E;
  color: #fff;
}

.tag-remove-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  margin-left: 2px;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.5;
}

.tag-remove-btn:hover { opacity: 1; }

.question-card-action {
  padding: 7px 14px;
  background: #f5f5f7;
  color: #1d1d1f;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.question-card-action:hover { background: #e8e8ed; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: #aeaeb2;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 15px;
  margin: 0;
  color: #86868b;
}

/* ── Loading ── */
.loading-results {
  text-align: center;
  padding: 40px;
  color: #aeaeb2;
  font-size: 14px;
}

/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 734px) {
  .tag-search-page { padding: 40px 20px 60px; }
  .tag-search-header h1 { font-size: var(--text-3xl, 28px); }

  .search-input-wrapper { flex-direction: column; }
  .tag-search-button { width: 100%; }

  .filter-section { flex-direction: column; gap: 12px; }
  .filter-group { width: 100%; }
  .admin-only-toggle { margin-left: 0 !important; }
  .switch-label { margin-top: 0; }

  .results-header { flex-direction: column; align-items: flex-start; gap: 4px; }

  .question-card-header { flex-direction: column; gap: 8px; }
  .question-card-action { width: 100%; text-align: center; }
}

@media (max-width: 480px) {
  .tag-search-header h1 { font-size: var(--text-2xl, 24px); }
}

/* ── Login Modal ── */
.login-modal {
  display: none !important;
  position: fixed !important;
  top: 0 !important; left: 0 !important;
  width: 100% !important; height: 100% !important;
  z-index: 2000 !important;
  background-color: rgba(0,0,0,0.5) !important;
  justify-content: center !important;
  align-items: center !important;
}

.login-modal.show { display: flex !important; }
