/* 카드 교환 게시판 스타일 */
.cardtrade-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: calc(100vh - 200px);
}

.cardtrade-container .header-section .main-title {
  color: var(--primary-color, #2c3e50);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.cardtrade-container .header-section .subtitle {
  color: #666;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.cardtrade-container .header-section .subtitle:last-child {
  margin-bottom: 2rem;
}

.market-description {
  color: #666;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* 로그인 필요 카드 */
.login-required {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.login-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 60px 40px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-icon {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.login-icon svg {
    width: 3rem;
    height: 3rem;
}

.login-card h2 {
    font-size: 28px;
    margin-bottom: 20px;
    color: #667eea;
}

.login-card p {
    font-size: 16px;
    color: #b8c5d6;
    margin-bottom: 30px;
    line-height: 1.6;
}

.login-btn {
    background: #667eea;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    transition: all 0.3s;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    color: white;
    text-decoration: none;
}

.profile-link {
  color: var(--primary-color, #3498db);
  text-decoration: none;
  font-weight: 500;
}

.profile-link:hover {
  text-decoration: underline;
}

/* 탭 메뉴 */
.market-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #e0e0e0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #666;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #2c3e50;
  background-color: rgba(0, 0, 0, 0.02);
}

.tab-btn.active {
  color: var(--primary-color, #3498db);
  border-bottom-color: var(--primary-color, #3498db);
}

/* 필터 영역 */
.filter-section {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.filter-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-row .form-control {
  flex: 1;
  min-width: 150px;
  height: 50px;
  border-radius: 8px;
  border: 1px solid #ddd;
  transition: all 0.3s ease;
  font-size: 1rem;
  line-height: 1.6;
  padding: 0.5rem 0.75rem;
}

.filter-row .form-control option {
  padding: 0.5rem;
  line-height: 2;
}

.filter-row .form-control:focus {
  border-color: var(--primary-color, #3498db);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.filter-row .btn {
  height: 50px;
  padding: 0 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
}

#btn-create-listing {
  background: var(--primary-color, #3498db);
  border: none;
  color: white;
}

#btn-create-listing:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* 게시글 그리드 */
.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.listing-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.listing-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--primary-color, #3498db);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.listing-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border-color: var(--primary-color, #3498db);
}

.listing-card:hover::before {
  transform: scaleX(1);
}

.listing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.trade-type-badge {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.trade-type-badge.sale {
  background: #e91e63;
  color: white;
}

.trade-type-badge.buy {
  background: #2196f3;
  color: white;
}

.listing-job-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.listing-job-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #2c2c2c;
  padding: 0.4rem;
  border-radius: 8px;
}

.listing-job {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2c3e50;
  margin: 0;
}

.listing-details {
  margin: 1rem 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: #666;
  font-size: 0.9rem;
  font-weight: 500;
}

.detail-value {
  color: #2c3e50;
  font-weight: 600;
}

.detail-value-with-img {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ability-small-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.postcard-price-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.postcard-price-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: #f5f5f5;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.postcard-price-item img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.postcard-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
}

.price-row {
  flex-wrap: wrap;
}

.no-price {
  color: #999;
  font-style: italic;
}

.price-value {
  color: #f39c12;
  font-size: 1.1rem;
  font-weight: 700;
}

.guild-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.guild-badge.no {
  background: #ffebee;
  color: #c62828;
}

.listing-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #f0f0f0;
  font-size: 0.85rem;
  color: #999;
}

.listing-author {
  font-weight: 500;
  color: #666;
}

.listing-date {
  font-size: 0.8rem;
}

/* 빈 상태 */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #999;
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  color: #666;
  margin-bottom: 0.5rem;
}

/* 페이지네이션 */
.pagination-container {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.page-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  min-width: 40px;
}

.page-btn:hover {
  background: var(--primary-color, #3498db);
  color: white;
  border-color: var(--primary-color, #3498db);
}

.page-btn.active {
  background: var(--primary-color, #3498db);
  color: white;
  border-color: var(--primary-color, #3498db);
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 모달 스타일 */
.modal-content {
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  background: var(--primary-color, #3498db);
  color: white;
  border-radius: 12px 12px 0 0;
  border-bottom: none;
  padding: 1.5rem;
}

.modal-header .modal-title {
  font-weight: 700;
}

.modal-header .close {
  color: white;
  opacity: 0.9;
  text-shadow: none;
}

.modal-body {
  padding: 2rem;
}

.form-group label {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.form-control {
  border-radius: 8px;
  border: 1px solid #ddd;
  padding: 0.75rem;
  transition: all 0.3s ease;
}

.form-control:focus {
  border-color: var(--primary-color, #3498db);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-check-label {
  font-weight: 500;
  color: #555;
}

/* 엽서 가격 입력 그룹 */
.postcard-price-group {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.postcard-price-group .form-row {
  margin-bottom: 0.5rem;
}

.postcard-price-group .form-row:last-child {
  margin-bottom: 0;
}

.postcard-price-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #555;
}

.postcard-price-group .form-control {
  height: 40px;
}

#postcard-price-preview {
  font-size: 0.95rem;
  font-weight: 600;
  color: #2c3e50;
}

.modal-footer {
  border-top: 1px solid #e0e0e0;
  padding: 1rem 2rem;
}

.modal-footer .btn {
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
}

/* 상세보기 모달 */
.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.detail-section-content {
  font-size: 1.1rem;
  color: #2c3e50;
  font-weight: 600;
}

.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.detail-info-item {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  border-left: 3px solid var(--primary-color, #3498db);
}

.detail-info-label {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.3rem;
}

.detail-info-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2c3e50;
}

.detail-job-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #2c2c2c;
  padding: 0.4rem;
  border-radius: 8px;
}

.detail-ability-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.detail-price-item .detail-info-value {
  width: 100%;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .cardtrade-container {
    padding: 1rem 0.5rem;
  }

  .filter-row {
    flex-direction: column;
  }

  .filter-row .form-control,
  .filter-row .btn {
    width: 100%;
    min-width: unset;
  }

  .listings-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .listing-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-body {
    padding: 1rem;
  }

  .detail-info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .cardtrade-container h1 {
    font-size: 1.5rem;
  }

  .tab-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  .listing-card {
    padding: 1rem;
  }

  .listing-job {
    font-size: 1.2rem;
  }
}

/* 로딩 애니메이션 */
.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary-color, #3498db);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 완료된 거래 스타일 */
.listing-card.completed {
  opacity: 0.6;
  position: relative;
}

.listing-card.completed::after {
  content: '거래 완료';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-15deg);
  background: rgba(46, 125, 50, 0.9);
  color: white;
  padding: 0.5rem 2rem;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ==================== 모달 이미지 선택 스타일 ==================== */

/* 모달 크기 확장 */
.modal-xl {
  max-width: 1400px;
  max-height: 95vh;
}

.modal-xl .modal-content {
  height: auto;
  max-height: 95vh;
}

.modal-xl .modal-body {
  overflow-y: auto;
  max-height: calc(95vh - 120px); /* 헤더+푸터 높이 고려 */
  -webkit-overflow-scrolling: touch; /* iOS 스무스 스크롤 */
}

/* Bootstrap의 modal-dialog-scrollable 클래스와 함께 사용 */
.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
}

/* 모바일에서 모달 높이 조정 */
@media (max-width: 768px) {
  .modal-xl {
    max-width: 100%;
    margin: 10px;
    max-height: calc(100vh - 20px);
  }
  
  .modal-xl .modal-content {
    max-height: calc(100vh - 20px);
  }
  
  .modal-xl .modal-body {
    max-height: calc(100vh - 140px);
    padding: 1rem;
  }
}

/* 거래 유형 버튼 */
.trade-type-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.trade-type-btn {
  flex: 1;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: var(--background-color, #f8f9fa);
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
}

.trade-type-btn:hover {
  border-color: var(--primary-color, #3498db);
}

.trade-type-btn.active {
  background: var(--primary-dark, #2c3e50);
  color: white;
  border-color: var(--primary-dark, #2c3e50);
}

/* 직업 선택 그리드 */
.job-selection-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.75rem;
  max-height: 350px;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: transparent;
}

.job-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #3a3a3a;
}

.job-item:hover {
  border-color: var(--primary-color, #3498db);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.job-item.selected {
  border-color: var(--primary-dark, #2c3e50);
  background: #e3f2fd;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.job-item img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  margin-bottom: 0.25rem;
}

.job-item span {
  font-size: 0.75rem;
  text-align: center;
  color: #fff;
  font-weight: 500;
}

/* 3티어 능력 선택 그리드 */
.ability-selection-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.75rem;
  padding: 0.5rem;
}

.ability-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
}

.ability-item:hover {
  border-color: var(--primary-color, #3498db);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ability-item.selected {
  border-color: var(--primary-dark, #2c3e50);
  background: #e3f2fd;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.ability-item img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  margin-bottom: 0.25rem;
}

.ability-item span {
  font-size: 0.85rem;
  text-align: center;
  color: #333;
  font-weight: 500;
}

/* 엽서 선택 그리드 */
.postcard-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  padding: 1rem;
  background: #fafafa;
  border-radius: 8px;
}

.postcard-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background: white;
  border: 2px solid #ddd;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.postcard-item:hover {
  border-color: var(--primary-color, #3498db);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.postcard-item img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}

.postcard-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.5rem;
}

.postcard-counter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.counter-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: var(--primary-color, #3498db);
  color: white;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.counter-btn:hover {
  background: var(--primary-dark, #2c3e50);
  transform: scale(1.1);
}

.counter-btn:active {
  transform: scale(0.95);
}

.counter-value {
  min-width: 30px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
}

/* 카드 수량 컨트롤 */
.quantity-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  padding: 1rem;
  background: #fafafa;
  border-radius: 8px;
}

.quantity-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 8px;
  background: var(--primary-color, #3498db);
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quantity-btn:hover {
  background: var(--primary-dark, #2c3e50);
  transform: scale(1.1);
}

.quantity-btn:active {
  transform: scale(0.95);
}

.quantity-input {
  width: 100px;
  height: 48px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: white;
}

.quantity-input:focus {
  outline: none;
  border-color: var(--primary-color, #3498db);
}

/* 수량 디스플레이 */
.quantity-display {
  min-width: 80px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
  background: white;
  border: 2px solid #ddd;
  border-radius: 8px;
}

/* 길드 이동 버튼 */
.guild-transfer-btn {
  width: 100%;
  padding: 1.2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #f44336;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.guild-transfer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.guild-transfer-btn.active {
  background: #4caf50;
  border-color: #4caf50;
}

.guild-transfer-btn .btn-text::before {
  content: '❌ ';
}

.guild-transfer-btn.active .btn-text::before {
  content: '✅ ';
}

.guild-transfer-btn.active .btn-text {
  content: '길드 이동 가능';
}

.profile-link {
  color: var(--primary-color, #3498db);
  text-decoration: none;
  font-weight: 600;
}

/* 모달 반응형 추가 */
@media (max-width: 768px) {
  .job-selection-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }

  .job-item img {
    width: 40px;
    height: 40px;
  }

  .job-item span {
    font-size: 0.65rem;
  }

  .ability-selection-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
  }

  .ability-item img {
    width: 50px;
    height: 50px;
  }

  .ability-item span {
    font-size: 0.75rem;
  }

  .postcard-selection-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .postcard-item img {
    width: 60px;
    height: 60px;
  }

  .trade-type-buttons {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .job-selection-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .ability-selection-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .postcard-selection-grid {
    grid-template-columns: 1fr;
  }
}
