/* ==========================================================================
   Word Voyage 관리자 콘솔 전용 스타일 (css/admin.css)
   ========================================================================== */

.admin-body {
  background: #042422 url('../assets/inner_bg.png') center top / cover fixed;
  color: #fff5d8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

/* 상단 관리자 헤더 */
.admin-header {
  background: rgba(2, 28, 26, 0.95);
  border-bottom: 1px solid rgba(202, 166, 83, 0.4);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.admin-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-badge {
  background: #d4af37;
  color: #1a1405;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.08em;
}

.admin-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: #fce8a6;
  margin: 0;
  letter-spacing: 0.02em;
}

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

.btn-back-game {
  color: #d4af37;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 10px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-back-game:hover {
  background: rgba(212, 175, 55, 0.15);
  color: #ffffff;
  border-color: #fce8a6;
}

.admin-user-tag {
  font-size: 0.82rem;
  color: #a7f3d0;
  background: rgba(22, 107, 99, 0.6);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(74, 222, 128, 0.4);
}

.btn-admin-logout {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #fca5a5;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-admin-logout:hover {
  background: #ef4444;
  color: #ffffff;
}

/* 관리자 메인 컨테이너 */
.admin-container {
  max-width: 1200px;
  width: calc(100% - 32px);
  margin: 20px auto 40px;
  flex: 1;
}

/* 탭 네비게이션 */
.admin-tab-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: rgba(2, 28, 26, 0.8);
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(202, 166, 83, 0.35);
  overflow-x: auto;
}

.admin-tab-btn {
  flex: 1;
  min-width: 130px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: #caa653;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.admin-tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.admin-tab-btn.active {
  background: linear-gradient(180deg, #166b63 0%, #0d5751 100%);
  color: #ffffff;
  border: 1px solid #e5c673;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* 카드 및 그리드 */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: linear-gradient(135deg, rgba(8, 52, 48, 0.95), rgba(4, 38, 36, 0.98));
  border: 1.5px solid #caa653;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.metric-icon {
  font-size: 2rem;
}

.metric-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.8rem;
  color: #caa653;
  font-weight: 700;
}

.metric-val {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.7rem;
  font-weight: 800;
  color: #ffffff;
}

.overview-dual-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .overview-dual-grid {
    grid-template-columns: 1fr;
  }
}

.admin-card {
  background: linear-gradient(135deg, rgba(8, 52, 48, 0.9), rgba(4, 35, 33, 0.95));
  border: 1.5px solid #caa653;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.15rem;
  color: #fce8a6;
  margin: 0;
  font-weight: 800;
}

.card-desc {
  font-size: 0.82rem;
  color: #aebfba;
  margin: -6px 0 16px;
}

.recovery-queue-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e5c673;
  font-size: 0.78rem;
  font-weight: 700;
}

.admin-filter-select {
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid #caa653;
  border-radius: 5px;
  background: rgba(2, 28, 26, 0.8);
  color: #ffffff;
  font: inherit;
}

.recovery-queue-summary {
  min-height: 1.2em;
  margin: 0 0 12px;
  color: #aebfba;
  font-size: 0.8rem;
}

.recovery-table {
  min-width: 860px;
}

.recovery-table small {
  color: #aebfba;
}

.recovery-status,
.recovery-gate-count {
  display: inline-block;
  border: 1px solid rgba(229, 198, 115, 0.7);
  border-radius: 4px;
  padding: 3px 6px;
  color: #fce8a6;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.recovery-status-approved,
.recovery-status-authorized,
.recovery-status-completed {
  border-color: #4ade80;
  color: #bbf7d0;
}

.recovery-status-rejected,
.recovery-status-ineligible,
.recovery-status-expired {
  border-color: #ef4444;
  color: #fca5a5;
}

.recovery-risk-cell {
  max-width: 210px;
  color: #fca5a5 !important;
  font-size: 0.72rem;
  line-height: 1.35;
}

.search-box input {
  background: rgba(2, 28, 26, 0.8);
  border: 1px solid #caa653;
  border-radius: 6px;
  padding: 8px 14px;
  color: #ffffff;
  font-size: 0.85rem;
  width: 240px;
  outline: none;
}

.search-box input:focus {
  border-color: #fce8a6;
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.4);
}

.btn-refresh {
  background: rgba(22, 107, 99, 0.6);
  border: 1px solid #caa653;
  color: #fce8a6;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-refresh:hover {
  background: #166b63;
  color: #ffffff;
}

/* 테이블 스타일 */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.admin-table-scroll {
  max-height: min(70vh, 640px);
  overflow: auto;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.admin-table-scroll:focus-visible {
  outline: 2px solid #fce8a6;
  outline-offset: 2px;
}

.admin-table-scroll .admin-table {
  border-collapse: separate;
  border-spacing: 0;
}

.admin-table-scroll .admin-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0c4a44;
  box-shadow: 0 2px 0 #caa653;
}

.admin-table-scroll .admin-table th {
  position: static;
  background: #0c4a44;
  border-bottom: 0;
}

.admin-log-table-scroll {
  max-height: min(70vh, 640px);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.admin-log-table-scroll:focus-visible {
  outline: 2px solid #fce8a6;
  outline-offset: 2px;
}

.admin-log-table-scroll .admin-table {
  border-collapse: separate;
  border-spacing: 0;
}

.admin-log-table-scroll .admin-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0c4a44;
  box-shadow: 0 2px 0 #caa653;
}

.admin-log-table-scroll .admin-table th {
  position: static;
  background: #0c4a44;
  border-bottom: 0;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

.admin-table th {
  background: rgba(202, 166, 83, 0.15);
  color: #e5c673;
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 2px solid #caa653;
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(202, 166, 83, 0.2);
  color: #f1f5f9;
  vertical-align: middle;
}

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

.btn-action-view {
  background: rgba(22, 107, 99, 0.8);
  border: 1px solid #4ade80;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.74rem;
  cursor: pointer;
  margin-right: 4px;
}

.btn-action-delete {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #fca5a5;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.74rem;
  cursor: pointer;
}

.btn-action-delete:hover {
  background: #ef4444;
  color: #ffffff;
}

.badge-admin-tag {
  background: #d4af37;
  color: #1a1405;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

/* 상위 국가 목록 */
.top-countries-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.country-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(2, 28, 26, 0.6);
  border-radius: 6px;
  border: 1px solid rgba(202, 166, 83, 0.2);
}

.country-item-name {
  font-weight: 700;
  font-size: 0.86rem;
}

.country-item-count {
  color: #fce8a6;
  font-weight: 800;
  font-family: Georgia, 'Times New Roman', serif;
}

/* 최근 로그 목록 */
.recent-logs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.recent-logs-list:focus-visible,
.user-detail-body:focus-visible,
.detail-scroll-area:focus-visible,
.detail-vocab-list:focus-visible {
  outline: 2px solid #fce8a6;
  outline-offset: 2px;
}

.recent-log-item {
  padding: 8px 12px;
  background: rgba(2, 28, 26, 0.6);
  border-radius: 6px;
  border: 1px solid rgba(202, 166, 83, 0.15);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.log-action-tag {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.log-action-tag.REGISTER { background: rgba(59, 130, 246, 0.3); color: #93c5fd; border: 1px solid #3b82f6; }
.log-action-tag.LOGIN { background: rgba(34, 197, 94, 0.3); color: #86efac; border: 1px solid #22c55e; }
.log-action-tag.GAME_COMPLETE { background: rgba(234, 179, 8, 0.3); color: #fde047; border: 1px solid #eab308; }

/* 관리자 로그인 모달 */
.admin-login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 15, 14, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.admin-login-card {
  background: linear-gradient(135deg, rgba(255, 245, 218, 0.98), rgba(238, 220, 172, 0.98));
  border: 2px solid #caa653;
  border-radius: 12px;
  padding: 30px;
  max-width: 380px;
  width: 100%;
  color: #153d3a;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.admin-login-header {
  text-align: center;
  margin-bottom: 20px;
}

.login-badge {
  background: #dc2626;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.08em;
}

.admin-login-header h2 {
  font-family: Georgia, 'Times New Roman', serif;
  margin: 8px 0 4px;
  font-size: 1.4rem;
  color: #153d3a;
}

.admin-login-header p {
  font-size: 0.8rem;
  color: #554429;
  margin: 0;
}

.admin-login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-login-form label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #3f311d;
  margin-bottom: -6px;
}

.admin-login-form input {
  padding: 10px 12px;
  border: 1.5px solid #b88d3d;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #ffffff;
  color: #153d3a;
}

.btn-admin-submit {
  margin-top: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #166b63 0%, #0d5751 100%);
  color: #ffffff;
  border: 1px solid #e5c673;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-admin-submit:hover {
  background: linear-gradient(180deg, #1c7c73 0%, #0f625b 100%);
}

.admin-login-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 0.78rem;
}

.admin-login-footer a {
  color: #0d5751;
  text-decoration: none;
  font-weight: 700;
}

.admin-error-msg {
  color: #dc2626;
  font-size: 0.8rem;
  font-weight: 700;
  margin: 0;
  text-align: center;
}

/* 사용자 상세 모달 */
.user-detail-modal {
  max-width: 700px;
  width: 90%;
  color: #153d3a;
}

.user-detail-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}

.recovery-detail-modal {
  max-width: 720px;
  color: #153d3a;
}

.recovery-detail-body {
  display: grid;
  gap: 12px;
  max-height: 74vh;
  overflow-y: auto;
  padding-right: 4px;
}

.recovery-detail-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid #caa653;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
}

.recovery-detail-summary div {
  display: grid;
  gap: 3px;
}

.recovery-detail-summary strong {
  color: #0d5751;
  font-size: 0.72rem;
}

.recovery-detail-section {
  padding: 12px;
  border: 1px solid #caa653;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
}

.recovery-detail-section h3 {
  margin: 0 0 9px;
  color: #0d5751;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.94rem;
}

.recovery-detail-section p {
  margin: 5px 0;
}

.recovery-gate-list,
.recovery-risk-list,
.recovery-device-list,
.recovery-event-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recovery-gate-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(13, 87, 81, 0.08);
}

.recovery-gate-list li span {
  min-width: 34px;
  font-size: 0.7rem;
  font-weight: 800;
}

.gate-pass span {
  color: #15803d;
}

.gate-fail span {
  color: #b91c1c;
}

.recovery-risk-list li,
.recovery-event-list li,
.recovery-device-list li {
  line-height: 1.45;
}

.recovery-risk-list li {
  color: #b91c1c;
}

.recovery-review-actions,
.recovery-authorize-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.recovery-review-actions button,
.btn-recovery-authorize {
  border: 1px solid #0d5751;
  border-radius: 5px;
  padding: 8px 11px;
  background: #ffffff;
  color: #0d5751;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.recovery-review-actions button:hover,
.btn-recovery-authorize:hover {
  background: #e8f3ef;
}

.recovery-review-actions .is-approve,
.btn-recovery-authorize {
  background: #0d5751;
  color: #ffffff;
}

.recovery-review-actions .is-reject {
  border-color: #b91c1c;
  color: #b91c1c;
}

.recovery-review-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.recovery-authorize-actions {
  border-top: 1px solid #caa653;
}

.recovery-authorize-actions p {
  flex-basis: 100%;
  margin: 0;
  color: #6d5b40;
  font-size: 0.76rem;
}

.detail-scroll-area {
  max-height: 160px;
  overflow-y: auto;
}

.detail-access-log-list {
  max-height: 150px;
}

.detail-vocab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.detail-section {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid #caa653;
  border-radius: 8px;
  padding: 14px;
}

.detail-section h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #0d5751;
  font-family: Georgia, 'Times New Roman', serif;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  font-size: 0.82rem;
}

.admin-password-reset-section {
  border-color: #d4af37;
}

.admin-password-reset-desc {
  margin: 0 0 12px;
  color: #554429;
  font-size: 0.8rem;
  line-height: 1.45;
}

.admin-password-reset-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-password-reset-form label {
  color: #3f311d;
  display: grid;
  font-size: 0.78rem;
  font-weight: 700;
  gap: 5px;
}

.admin-password-reset-form input {
  background: #ffffff;
  border: 1px solid #b88d3d;
  border-radius: 4px;
  color: #153d3a;
  font: inherit;
  padding: 8px 10px;
}

.admin-password-reset-error {
  color: #b91c1c;
  font-size: 0.78rem;
  font-weight: 700;
  grid-column: 1 / -1;
}

.btn-action-password-reset {
  background: #0d5751;
  border: 1px solid #166b63;
  border-radius: 4px;
  color: #ffffff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  justify-self: start;
  padding: 8px 12px;
}

.btn-action-password-reset:hover {
  background: #166b63;
}

@media (max-width: 640px) {
  .admin-header {
    padding: 10px 12px;
  }

  .admin-header-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .admin-brand {
    justify-content: space-between;
  }

  .admin-title {
    font-size: 1.05rem;
  }

  .admin-header-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .btn-back-game {
    grid-column: 1 / -1;
    text-align: center;
  }

  .admin-user-tag {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .admin-container {
    margin: 12px auto 24px;
    width: calc(100% - 20px);
  }

  .admin-tab-nav {
    gap: 6px;
    margin-bottom: 12px;
    padding: 5px;
    scroll-snap-type: x proximity;
  }

  .admin-tab-btn {
    flex: 0 0 auto;
    font-size: 0.82rem;
    min-width: 116px;
    padding: 9px 12px;
    scroll-snap-align: start;
  }

  .metrics-grid {
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 12px;
  }

  .metric-card {
    gap: 10px;
    min-width: 0;
    padding: 14px 12px;
  }

  .metric-icon {
    font-size: 1.5rem;
  }

  .metric-val {
    font-size: 1.35rem;
  }

  .metric-label {
    line-height: 1.3;
  }

  .overview-dual-grid {
    gap: 12px;
  }

  .admin-card {
    border-radius: 8px;
    padding: 16px 12px;
  }

  .card-header-flex {
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }

  .recovery-queue-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .recovery-queue-controls .admin-filter-select,
  .recovery-queue-controls .btn-refresh {
    width: 100%;
  }

  .card-title {
    font-size: 1rem;
    line-height: 1.35;
  }

  .search-box,
  .search-box input,
  .btn-refresh {
    width: 100%;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  #users-table {
    min-width: 1060px;
  }

  #geo-table {
    min-width: 580px;
  }

  #logs-table {
    min-width: 780px;
  }

  #recovery-table {
    min-width: 860px;
  }

  .admin-log-table-scroll {
    max-height: min(62vh, 520px);
  }

  .admin-table-scroll {
    max-height: min(62vh, 520px);
  }

  .recent-log-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .admin-login-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 16px 12px;
  }

  .admin-login-card {
    margin: auto 0;
    padding: 24px 20px;
  }

  .user-detail-modal {
    margin: 10px;
    width: calc(100% - 20px);
  }

  .recovery-detail-modal {
    margin: 10px;
    width: calc(100% - 20px);
  }

  .user-detail-body {
    max-height: 66vh;
  }

  .detail-section {
    padding: 12px;
  }

  .detail-meta-grid,
  .admin-password-reset-form,
  .recovery-detail-summary {
    grid-template-columns: 1fr;
  }

  .btn-action-password-reset {
    justify-self: stretch;
  }
}

@media (max-width: 380px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
