/* =========================================================
   GLK Game Picker V2 — picker.css
   모바일 우선(420px 세로 모달), 데스크탑 동일 레이아웃 사용
   ========================================================= */

/* --- 오버레이 --- */
.glk-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.glk-overlay[aria-hidden="true"] { display: none !important; }

/* --- 모달 컨테이너 --- */
.glk-modal {
  background: #1a1d2e;
  color: #e8eaf0;
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  height: 85vh;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  overflow: hidden;
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  font-size: 14px;
}

/* --- 헤더 --- */
.glk-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  background: #13152a;
  border-bottom: 1px solid #2a2d45;
  flex-shrink: 0;
}
.glk-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #a78bfa;
  letter-spacing: -0.3px;
}
.glk-close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.glk-close-btn:hover { background: #2a2d45; color: #fff; }

/* --- 검색바 --- */
.glk-search-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: #13152a;
  border-bottom: 1px solid #2a2d45;
  flex-shrink: 0;
}
.glk-search-input {
  flex: 1;
  background: #0f1120;
  border: 1px solid #2a2d45;
  border-radius: 8px;
  color: #e8eaf0;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.glk-search-input:focus { border-color: #7c3aed; }
.glk-search-btn {
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.glk-search-btn:hover { background: #6d28d9; }
.glk-search-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.glk-cancel-btn {
  background: #2a2d45;
  color: #d9def5;
  border: 1px solid #3a3f61;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.glk-cancel-btn:hover { background: #333858; }

/* --- 정렬 버튼 바 --- */
.glk-sort-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #13152a;
  border-bottom: 1px solid #2a2d45;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.glk-sort-bar::-webkit-scrollbar { display: none; }
.glk-sort-label {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}
.glk-sort-btn {
  background: #1e2038;
  border: 1px solid #2a2d45;
  color: #aaa;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.glk-sort-btn:hover { background: #2a2d45; color: #ccc; }
.glk-sort-btn.active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

/* --- 결과 스크롤 영역 --- */
.glk-results-wrap {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2a2d45 transparent;
}
.glk-results-wrap::-webkit-scrollbar { width: 5px; }
.glk-results-wrap::-webkit-scrollbar-track { background: transparent; }
.glk-results-wrap::-webkit-scrollbar-thumb { background: #2a2d45; border-radius: 3px; }

.glk-results { padding: 0; }

/* 힌트/로딩/에러 메시지 */
.glk-hint, .glk-loading, .glk-error {
  text-align: center;
  padding: 40px 20px;
  color: #555;
  font-size: 13px;
  line-height: 1.6;
}
.glk-loading { color: #7c3aed; }
.glk-error { color: #f87171; }
.glk-loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #a78bfa;
  font-weight: 600;
}
.glk-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(167, 139, 250, 0.25);
  border-top-color: #a78bfa;
  animation: glkSpin 0.8s linear infinite;
}
@keyframes glkSpin {
  to { transform: rotate(360deg); }
}

/* --- 결과 테이블 --- */
.glk-table {
  width: 100%;
  border-collapse: collapse;
}
.glk-table-header {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  background: #0f1120;
  border-bottom: 1px solid #1e2038;
  font-size: 11px;
  color: #555;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.glk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid #1a1d2e;
  transition: background 0.1s;
  cursor: default;
}
.glk-row:hover { background: #1e2038; }
.glk-row:last-child { border-bottom: none; }

.glk-row-thumb {
  width: 60px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #0f1120;
  display: flex;
  align-items: center;
  justify-content: center;
}
.glk-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.glk-row-thumb .glk-no-img {
  font-size: 10px;
  color: #444;
}

.glk-row-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.glk-row-title {
  font-size: 13px;
  font-weight: 600;
  color: #e8eaf0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.glk-row-meta {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.glk-select-btn {
  flex-shrink: 0;
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.glk-select-btn:hover { background: #6d28d9; }
.glk-select-btn:active { transform: scale(0.97); }

/* 결과 count 바 */
.glk-result-count {
  padding: 6px 14px;
  background: #0f1120;
  font-size: 11px;
  color: #555;
  border-bottom: 1px solid #1e2038;
}

/* --- 상태 바 --- */
.glk-status-bar {
  padding: 8px 14px;
  background: #13152a;
  border-top: 1px solid #2a2d45;
  font-size: 11px;
  color: #666;
  min-height: 30px;
  flex-shrink: 0;
  text-align: center;
}

/* --- meta 모드 선택 표시 --- */
.glk-meta-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: #1a1d2e;
  border: 1px solid #2a2d45;
  border-radius: 6px;
  font-size: 13px;
  color: #e8eaf0;
  cursor: pointer;
}
.glk-meta-display img {
  width: 40px;
  height: 19px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}
.glk-meta-display .glk-meta-clear {
  margin-left: auto;
  color: #666;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

/* 에디터 위 게임 버튼 — 완전 새 디자인 */
.glk-editor-btn-wrap {
  display: block;
  width: 100%;
  margin: 0 0 14px 0;
  box-sizing: border-box;
}
.glk-open-picker-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
  background: linear-gradient(135deg, #6d28d9 0%, #4c1d95 60%, #2e1065 100%);
  color: #fff;
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  letter-spacing: -0.2px;
  box-shadow: 0 6px 24px rgba(109, 40, 217, 0.38), inset 0 1px 0 rgba(255,255,255,0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
}
.glk-open-picker-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}
.glk-open-picker-btn .glk-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.14);
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
}
.glk-open-picker-btn .glk-btn-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.glk-open-picker-btn .glk-btn-title {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
}
.glk-open-picker-btn .glk-btn-sub {
  font-size: 11px;
  font-weight: 400;
  color: rgba(221, 214, 254, 0.85);
  white-space: nowrap;
}
.glk-open-picker-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(109, 40, 217, 0.52), inset 0 1px 0 rgba(255,255,255,0.16);
}
.glk-open-picker-btn:active { transform: translateY(0); }

/* meta 모드 버튼 (input 옆) */
.glk-meta-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 8px;
  box-shadow: 0 3px 10px rgba(124,58,237,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.glk-meta-picker-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(124,58,237,0.5); }
.glk-meta-picker-btn:active { transform: translateY(0); }

/* =========================================================
   에디터 삽입 카드 스타일 (인라인 스타일로도 처리되지만 fallback)
   ========================================================= */
.glk-game-card {
  display: block;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  max-width: 460px;
  font-family: 'Noto Sans KR', sans-serif;
  text-decoration: none;
  color: inherit;
  margin: 12px 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
/* Global overlay placement guard: keep the picker above the page flow. */
.glk-overlay {
	position: fixed !important;
	inset: 0 !important;
	z-index: 2147483647 !important;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(8, 10, 22, 0.78);
	padding: 24px;
}

.glk-overlay[aria-hidden="true"] { display: none !important; }
.glk-overlay[aria-hidden="false"] { display: flex !important; }
