/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Montserrat:wght@300;400;500;600;700&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

/* CSS Variables */
:root {
  --bg-primary: #050810; /* 더 진한 남색 */
  --bg-secondary: #0a0e1a;
  --accent-purple: #2A0B5E;
  --accent-gold: #FFD700;
  --accent-cyan: #00B4D8;
  --accent-ivory: #fffff0; /* 아이보리 */
  --text-primary: #FFFFFF;
  --text-secondary: #B8C1CC;
  --error: #FF6B6B;
  --success: #4ECDC4;
  
  /* Attribute Colors */
  --attr-fire: #FF6B35;
  --attr-water: #4A90E2;
  --attr-grass: #2ECC71;
  --attr-earth: #A67C52;
  --attr-wind: #87CEEB;
  --attr-none: #9B59B6;
  
  /* Rarity Colors */
  --rarity-common: #B8C1CC;
  --rarity-uncommon: #2ECC71;
  --rarity-rare: #4A90E2;
  --rarity-epic: #9B59B6;
  --rarity-legendary: #FFD700;
  --rarity-mythic: #FF6B35;
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Montserrat', 'Noto Sans KR', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Animated Background */
.animated-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--accent-cyan);
  border-radius: 50%;
  opacity: 0.5;
  animation: float 20s infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  25% { transform: translateY(-50px) translateX(50px); }
  50% { transform: translateY(-100px) translateX(-50px); }
  75% { transform: translateY(-50px) translateX(50px); }
}

/* Navigation */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(18, 24, 38, 0.95);
  backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  border-bottom: 1px solid rgba(42, 11, 94, 0.3);
}

/* 햄버거 메뉴 버튼 */
.navbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  margin-right: 1rem;
  z-index: 1001;
}

.navbar-logo {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-logo::before {
  content: '⬟';
  display: inline-block;
  color: #ff3333; /* 장미 레드 */
  text-shadow: 0 0 10px #FFD700; /* 골드 광채 */
  animation: rose-bloom 3s infinite alternate;
}

@keyframes rose-bloom {
  0% { transform: scale(1) rotate(0deg); color: #ff3333; }
  100% { transform: scale(1.2) rotate(10deg); color: #ff6666; text-shadow: 0 0 20px #FFD700; }
}

.navbar-menu {
  display: flex;
  gap: 2rem;
  list-style: none;
  flex-wrap: wrap;
}

.navbar-menu.active {
  display: flex;
}

.navbar-menu a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
  position: relative;
}

.navbar-menu a:hover {
  color: var(--accent-cyan);
}

.navbar-menu a::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-cyan);
  transition: width 0.3s;
}

.navbar-menu a:hover::after {
  width: 100%;
}

.navbar-user {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.navbar-user-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.user-avatar {
  width: 40px;
  height: 40px;
  borde.btn-primary {
  background: var(--accent-ivory);
  color: #050810;
  font-weight: 700;
}

.btn-primary:hover {
  background: #f0f0e0;
  transform: translateY(-2px);
}  align-items: center;
  justify-content: center;
  font-weight: 600;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(135deg, #9B7EBD 0%, #B8A4D4 100%);
  color: var(--text-primary);
  box-shadow: 0 4px 15px rgba(155, 126, 189, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(155, 126, 189, 0.6);
}

.btn-secondary {
  background: linear-gradient(135deg, #B8A4D4 0%, #D4C4E8 100%);
  color: var(--text-primary);
  border: 1px solid rgba(184, 164, 212, 0.3);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #C4B4E4 0%, #E0D4F4 100%);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, #A890C8 0%, #C4B4E4 100%);
  color: var(--text-primary);
  box-shadow: 0 4px 15px rgba(168, 144, 200, 0.4);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(168, 144, 200, 0.6);
}

.btn-danger {
  background: var(--error);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
}

/* Cards */
.card {
  background: rgba(18, 24, 38, 0.8);
  border: 1px solid rgba(42, 11, 94, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.card-header {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--accent-gold);
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--accent-purple);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.form-input option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* select 요소의 텍스트 색상 강제 지정 */
select.form-input {
  color: var(--text-primary) !important;
}

/* 숫자 입력 필드 등 모든 입력 필드의 텍스트 색상 보장 */
input.form-input {
  color: var(--text-primary) !important;
}

.filter-select {
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-purple);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  font-weight: 500;
}

.filter-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 500;
}

.filter-select:hover {
  border-color: var(--accent-cyan);
  background: rgba(18, 24, 38, 0.95);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.1);
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.password-toggle:hover {
  color: var(--accent-cyan);
}

.form-input::placeholder {
  color: #6B7280;
}

/* 카테고리 버튼 스타일 */
.category-btn {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 500;
}

.category-btn:hover {
  background: rgba(42, 11, 94, 0.5);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.category-btn.active {
  background: var(--accent-purple);
  border-color: var(--accent-cyan);
  color: var(--text-primary);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.main-content {
  margin-top: 80px;
  min-height: calc(100vh - 80px);
  padding-bottom: 4rem; /* 하단 여백 추가 */
}

/* 게시글 카드 스타일 (포럼용) */
.post-card {
  background: rgba(18, 24, 38, 0.8);
  border: 1px solid rgba(42, 11, 94, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: transform 0.3s;
  cursor: pointer;
}

.post-card:hover {
  transform: translateX(10px);
  border-color: var(--accent-cyan);
}

.post-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.post-category {
  color: var(--accent-cyan);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.post-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.post-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Pentagon Animation */
.pentagon {
  width: 200px;
  height: 200px;
  position: relative;
  animation: rotate-pentagon 10s linear infinite;
}

@keyframes rotate-pentagon {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.pentagon svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 20px var(--accent-purple));
}

/* Attribute Badges */
.attribute-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
}

.attribute-fire { background: var(--attr-fire); }
.attribute-water { background: var(--attr-water); }
.attribute-grass { background: var(--attr-grass); }
.attribute-earth { background: var(--attr-earth); }
.attribute-wind { background: var(--attr-wind); }
.attribute-none { background: var(--attr-none); }

/* Rarity Borders */
.rarity-common { border-color: var(--rarity-common); }
.rarity-uncommon { border-color: var(--rarity-uncommon); }
.rarity-rare { border-color: var(--rarity-rare); }
.rarity-epic { border-color: var(--rarity-epic); }
.rarity-legendary { 
  border-color: var(--rarity-legendary);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}
.rarity-mythic { 
  border-color: var(--rarity-mythic);
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.3);
}

/* Loading Spinner */
.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-gold { color: var(--accent-gold); }
.text-cyan { color: var(--accent-cyan); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Responsive */
@media (max-width: 1200px) {
  .navbar {
    padding: 1rem;
  }
  
  .navbar-logo {
    font-size: 1.25rem;
  }
  
  .navbar-menu {
    gap: 1rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 992px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* 태블릿 환경에서 카테고리 버튼 스타일 조정 */
  .category-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }
  
  .category-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }
  
  /* 게시글 메타 정보 태블릿 최적화 */
  .post-meta {
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    justify-content: flex-start;
  }
  
  /* 모바일 햄버거 메뉴 버튼 표시 */
  .navbar-toggle {
    display: block;
  }
  
  .navbar-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(18, 24, 38, 0.98);
    flex-direction: column;
    gap: 0;
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(42, 11, 94, 0.3);
    width: 100%;
    z-index: 999;
  }
  
  .navbar-menu.active {
    display: flex;
  }
  
  .navbar-menu li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .navbar-menu li:last-child {
    border-bottom: none;
  }
  
  .navbar-menu a {
    display: block;
    padding: 0.5rem 0;
  }
  
  .navbar-logo {
    font-size: 1rem;
    flex: 1;
  }
  
  .navbar-user {
    width: 100%;
    margin-top: 0.5rem;
    justify-content: flex-start;
    order: 3;
  }
  
  .navbar-user-buttons {
    width: 100%;
    justify-content: flex-start;
    gap: 0.5rem;
  }
  
  .navbar-user-buttons .btn {
    flex: 1;
    min-width: 100px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
  
  .user-info {
    width: 100%;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
  }
  
  .user-info span {
    display: none;
  }
  
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  
  .container {
    padding: 1rem;
    margin-top: 0;
  }
  
  .hero-title {
    font-size: 1.75rem !important;
  }
  
  .card {
    padding: 1rem;
  }
  
  .modal-content {
    width: 95%;
    padding: 1.25rem;
    margin: 1rem;
  }

  /* 카테고리 버튼 모바일 최적화 - 수평 스크롤 */
  .category-container {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    flex-wrap: nowrap;
  }

  .category-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }

  .category-btn {
    flex: 0 0 auto;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
    border-radius: 6px;
  }
  
  /* 게시글 메타 정보 모바일 최적화 */
  .post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
  }
  
  .post-meta span {
    display: inline-block;
    padding: 0.25rem 0;
  }
  
  /* 게시글 카드 모바일 최적화 */
  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .card > div {
    flex-direction: column;
  }
  
  .market-header {
    flex-direction: column;
  }
  
  .search-bar {
    min-width: 100%;
  }
  
  .market-filters {
    flex-direction: column;
  }
  
  .market-filters .btn {
    margin-left: 0 !important;
    width: 100%;
  }

  /* 게시글 작성 버튼 모바일 대응 */
  #openCreatePostBtn {
    width: 100%;
    margin-top: 0.5rem;
  }

  /* 게시글 상세 모달 내부 이미지 모바일 대응 */
  #postDetailContent img {
    max-width: 100%;
    height: auto;
  }
  
  /* 포럼 페이지 헤더 모바일 최적화 */
  .forum-header {
    flex-direction: column;
    gap: 1rem;
  }
  
  .forum-header > div:first-child {
    width: 100%;
  }
  
  .forum-header > button {
    width: 100%;
  }
  
  /* 네비게이션 메뉴 닫기 버튼 스타일 */
  .navbar-menu a::after {
    display: none;
  }
}

@media (max-width: 480px) {
  .navbar {
    padding: 0.5rem 0.75rem;
  }
  
  .navbar-logo {
    font-size: 0.85rem;
  }
  
  .navbar-toggle {
    font-size: 1.25rem;
    margin-right: 0.5rem;
  }
  
  .navbar-menu {
    padding: 0.75rem 1rem;
  }
  
  .navbar-user-buttons .btn {
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
  }
  
  .user-info {
    display: none;
  }
  
  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
  
  .form-input {
    font-size: 0.9rem;
  }
  
  .toast {
    right: 1rem;
    left: 1rem;
    bottom: 1rem;
  }
  
  /* 초소형 화면에서 카테고리 버튼 추가 최적화 */
  .category-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }
  
  /* 초소형 화면에서 게시글 메타 정보 최적화 */
  .post-meta {
    font-size: 0.65rem;
    gap: 0.25rem;
  }
  
  .post-title {
    font-size: 1rem;
  }
  
  .attribute-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
  
  /* 초소형 화면에서 네비게이션 추가 최적화 */
  .main-content {
    margin-top: 60px;
  }
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid var(--accent-cyan);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: none; /* 기본적으로 숨김 */
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.modal.active {
  display: flex !important; /* active 클래스 시 flex로 표시 */
}

.modal-content {
  background: #0a0e1a; /* 배경색 명시적 지정 */
  border: 1px solid var(--accent-purple);
  border-radius: 16px;
  padding: 2rem;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  position: relative;
  margin: auto; /* 중앙 정렬 보조 */
}

@keyframes modal-slide-in {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.3s;
  z-index: 10;
}

.modal-close:hover {
  color: var(--accent-cyan);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--accent-gold);
}

/* Text Utilities */
.text-secondary {
  color: var(--text-secondary);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
