/* ==========================================
   테마 스위처 UI 스타일
   theme-switcher.css
   ========================================== */

/* 테마 스위처 컨테이너 */
.theme-switcher {
  position: relative;
  display: inline-block;
  margin-right: var(--space-4);
}

/* 테마 토글 버튼 */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-2) var(--space-4);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.theme-toggle-btn:hover {
  background: var(--hover-bg);
  border-color: var(--primary-300);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.theme-icon {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-name {
  font-weight: 600;
}

.dropdown-arrow {
  transition: transform var(--transition-fast);
}

.theme-switcher.show .dropdown-arrow {
  transform: rotate(180deg);
}

/* 테마 드롭다운 */
.theme-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-2);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-6);
  min-width: 400px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-normal);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.theme-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 드롭다운 헤더 */
.theme-dropdown-header {
  margin-bottom: var(--space-6);
  text-align: center;
}

.theme-dropdown-header h3 {
  margin: 0 0 var(--space-2) 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.theme-dropdown-header p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* 테마 그리드 */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* 테마 옵션 */
.theme-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--hover-bg);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  position: relative;
  overflow: hidden;
}

.theme-option:hover {
  background: var(--primary-50);
  border-color: var(--primary-200);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.theme-option.active {
  background: var(--primary-100);
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.theme-option.active::after {
  content: '✓';
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  color: var(--primary-600);
  font-weight: bold;
  font-size: 1.1rem;
}

/* 테마 프리뷰 */
.theme-preview {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.theme-icon-large {
  font-size: 1.5rem;
  z-index: 2;
}

/* 테마별 프리뷰 스타일 */
.theme-preview.modern {
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
}

.theme-preview.cyberpunk {
  background: linear-gradient(135deg, #0a0a1a, #1a1a2e);
  color: #00ff88;
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
  animation: cyberpunkGlow 2s ease-in-out infinite alternate;
}

@keyframes cyberpunkGlow {
  0% { box-shadow: 0 0 15px rgba(0, 255, 136, 0.3); }
  100% { box-shadow: 0 0 25px rgba(0, 255, 136, 0.6); }
}

.theme-preview.glassmorphism {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #4f46e5;
}

.theme-preview.neumorphism {
  background: #f0f0f3;
  box-shadow: 6px 6px 12px #d1d1d9, -6px -6px 12px #ffffff;
  color: #6366f1;
}

.theme-preview.brutalism {
  background: #ffff00;
  border: 3px solid #000000;
  color: #000000;
  font-weight: 900;
}

.theme-preview.organic {
  background: radial-gradient(circle, #22c55e, #16a34a);
  color: #ffffff;
  border-radius: 50%;
}

/* 테마 정보 */
.theme-info {
  flex: 1;
  min-width: 0;
}

.theme-info h4 {
  margin: 0 0 4px 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-info p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* 드롭다운 푸터 */
.theme-dropdown-footer {
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-4);
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
}

.theme-option-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.theme-option-item:hover {
  background: var(--hover-bg);
}

.theme-checkbox {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.theme-checkbox:checked {
  background: var(--primary-500);
  border-color: var(--primary-500);
}

.theme-checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
}

.theme-option-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* 테마 전환 오버레이 */
.theme-transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.theme-transition-overlay.fade-in {
  opacity: 0.8;
}

.theme-transition-overlay.fade-out {
  opacity: 0;
}

/* 테마 변경 알림 */
.theme-notification {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  opacity: 0;
  transform: translateX(100%);
  transition: all var(--transition-normal);
  max-width: 300px;
}

.theme-notification.show {
  opacity: 1;
  transform: translateX(0);
}

.notification-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.notification-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.notification-text {
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.4;
}

.notification-text strong {
  font-weight: 600;
  color: var(--primary-600);
}

/* ==========================================
   반응형 디자인
   ========================================== */

/* 태블릿 */
@media (max-width: 768px) {
  .theme-dropdown {
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    min-width: 350px;
    width: 90vw;
    max-width: 400px;
  }
  
  .theme-dropdown.show {
    transform: translateX(-50%) translateY(0);
  }
  
  .theme-grid {
    grid-template-columns: 1fr;
  }
  
  .theme-dropdown-footer {
    flex-direction: column;
    gap: var(--space-2);
  }
  
  .theme-notification {
    right: var(--space-4);
    bottom: var(--space-4);
    left: var(--space-4);
    max-width: none;
  }
}

/* 모바일 */
@media (max-width: 480px) {
  .theme-toggle-btn {
    padding: var(--space-2) var(--space-3);
  }
  
  .theme-name {
    display: none;
  }
  
  .theme-dropdown {
    padding: var(--space-4);
    min-width: 300px;
  }
  
  .theme-option {
    padding: var(--space-2);
  }
  
  .theme-preview {
    width: 40px;
    height: 40px;
  }
  
  .theme-icon-large {
    font-size: 1.3rem;
  }
  
  .theme-info h4 {
    font-size: 0.9rem;
  }
  
  .theme-info p {
    font-size: 0.75rem;
  }
}

/* ==========================================
   다크 테마 대응
   ========================================== */

[data-theme="cyberpunk"] .theme-dropdown,
[data-dark="true"] .theme-dropdown {
  background: var(--bg-surface);
  border-color: var(--border-color);
}

[data-theme="cyberpunk"] .theme-option:hover,
[data-dark="true"] .theme-option:hover {
  background: var(--hover-bg);
}

[data-theme="cyberpunk"] .theme-toggle-btn,
[data-dark="true"] .theme-toggle-btn {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* ==========================================
   테마별 특수 스타일
   ========================================== */

/* Glassmorphism 테마 드롭다운 */
[data-theme="glassmorphism"] .theme-dropdown {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="glassmorphism"] .theme-toggle-btn {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Neumorphism 테마 드롭다운 */
[data-theme="neumorphism"] .theme-dropdown {
  background: #f0f0f3;
  box-shadow: 15px 15px 30px #d1d1d9, -15px -15px 30px #ffffff;
  border: none;
}

[data-theme="neumorphism"] .theme-toggle-btn {
  background: #f0f0f3;
  box-shadow: 6px 6px 12px #d1d1d9, -6px -6px 12px #ffffff;
  border: none;
}

[data-theme="neumorphism"] .theme-option {
  background: #f0f0f3;
  box-shadow: inset 4px 4px 8px #d1d1d9, inset -4px -4px 8px #ffffff;
  border: none;
}

[data-theme="neumorphism"] .theme-option:hover {
  box-shadow: 6px 6px 12px #d1d1d9, -6px -6px 12px #ffffff;
}

/* Brutalism 테마 드롭다운 */
[data-theme="brutalism"] .theme-dropdown {
  background: #ffffff;
  border: 3px solid #000000;
  box-shadow: 8px 8px 0px #000000;
  border-radius: 0;
}

[data-theme="brutalism"] .theme-toggle-btn {
  background: #ffff00;
  border: 3px solid #000000;
  border-radius: 0;
  font-weight: 800;
  text-transform: uppercase;
}

[data-theme="brutalism"] .theme-option {
  background: #ffffff;
  border: 2px solid #000000;
  border-radius: 0;
  font-weight: 700;
}

[data-theme="brutalism"] .theme-option:hover {
  background: #ffff00;
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0px #000000;
}

[data-theme="brutalism"] .theme-option.active {
  background: #ff0000;
  color: #ffffff;
}

/* Organic 테마 드롭다운 */
[data-theme="organic"] .theme-dropdown {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 30px;
  box-shadow: 0 8px 32px rgba(34, 197, 94, 0.2);
}

[data-theme="organic"] .theme-toggle-btn {
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

[data-theme="organic"] .theme-option {
  border-radius: 20px;
  background: rgba(240, 253, 244, 0.5);
}

[data-theme="organic"] .theme-option:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}

/* ==========================================
   애니메이션 및 특수 효과
   ========================================== */

/* 테마 옵션 호버 시 미리보기 효과 */
.theme-option:hover .theme-preview.cyberpunk {
  animation: cyberpunkPulse 1s ease-in-out infinite;
}

@keyframes cyberpunkPulse {
  0%, 100% { 
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
    transform: scale(1);
  }
  50% { 
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.8);
    transform: scale(1.05);
  }
}

.theme-option:hover .theme-preview.glassmorphism {
  backdrop-filter: blur(15px);
  transform: scale(1.05);
}

.theme-option:hover .theme-preview.neumorphism {
  box-shadow: inset 3px 3px 6px #d1d1d9, inset -3px -3px 6px #ffffff;
}

.theme-option:hover .theme-preview.brutalism {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0px #000000;
}

.theme-option:hover .theme-preview.organic {
  animation: organicBounce 0.6s ease-in-out;
}

@keyframes organicBounce {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(5deg); }
}

/* 테마 전환 시 특수 효과 */
.theme-switcher.switching .theme-toggle-btn {
  animation: themeSwitch 0.6s ease-in-out;
}

@keyframes themeSwitch {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(0.95) rotate(-5deg); }
  75% { transform: scale(1.05) rotate(5deg); }
}

/* 드롭다운 열림/닫힘 애니메이션 강화 */
.theme-dropdown {
  transform-origin: top right;
}

.theme-dropdown.show {
  animation: dropdownOpen 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropdownOpen {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================
   접근성 개선
   ========================================== */

/* 키보드 포커스 스타일 */
.theme-toggle-btn:focus,
.theme-option:focus,
.theme-checkbox:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* 고대비 모드 */
@media (prefers-contrast: high) {
  .theme-dropdown {
    border-width: 2px;
  }
  
  .theme-option {
    border-width: 2px;
  }
  
  .theme-toggle-btn {
    border-width: 2px;
  }
}

/* 모션 감소 모드 */
@media (prefers-reduced-motion: reduce) {
  .theme-dropdown,
  .theme-option,
  .theme-toggle-btn,
  .theme-notification,
  .theme-preview {
    transition: none;
    animation: none;
  }
  
  .theme-option:hover .theme-preview {
    transform: none;
  }
}

/* ==========================================
   인쇄 스타일
   ========================================== */

@media print {
  .theme-switcher {
    display: none !important;
  }
  
  .theme-notification {
    display: none !important;
  }
}

/* ==========================================
   터치 디바이스 최적화
   ========================================== */

@media (hover: none) and (pointer: coarse) {
  .theme-toggle-btn {
    padding: var(--space-3) var(--space-4);
    min-height: 44px; /* 터치 타겟 최소 크기 */
  }
  
  .theme-option {
    padding: var(--space-4);
    min-height: 60px;
  }
  
  .theme-checkbox {
    width: 20px;
    height: 20px;
  }
}

/* ==========================================
   로딩 상태 스타일
   ========================================== */

.theme-switcher.loading .theme-toggle-btn {
  pointer-events: none;
  opacity: 0.7;
}

.theme-switcher.loading .theme-toggle-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  right: var(--space-2);
  width: 12px;
  height: 12px;
  border: 2px solid transparent;
  border-top: 2px solid var(--primary-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translateY(-50%);
}

@keyframes spin {
  from { transform: translateY(-50%) rotate(0deg); }
  to { transform: translateY(-50%) rotate(360deg); }
}

/* ==========================================
   에러 상태 스타일
   ========================================== */

.theme-switcher.error .theme-toggle-btn {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.theme-switcher.error .theme-icon {
  color: var(--error);
}

/* ==========================================
   성공 상태 스타일
   ========================================== */

.theme-switcher.success .theme-toggle-btn {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.theme-switcher.success .theme-icon {
  color: var(--success);
}

/* ==========================================
   툴팁 스타일
   ========================================== */

.theme-option::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: white;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 1001;
}

.theme-option:hover::before {
  opacity: 1;
}

/* ==========================================
   성능 최적화
   ========================================== */

/* GPU 가속 활성화 */
.theme-dropdown,
.theme-option,
.theme-toggle-btn,
.theme-notification {
  will-change: transform, opacity;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* 레이어 분리 */
.theme-preview {
  transform: translateZ(0);
}

/* ==========================================
   실험적 기능
   ========================================== */

/* CSS Grid fallback for older browsers */
@supports not (display: grid) {
  .theme-grid {
    display: flex;
    flex-direction: column;
  }
  
  .theme-option {
    margin-bottom: var(--space-2);
  }
}

/* Backdrop-filter fallback */
@supports not (backdrop-filter: blur(10px)) {
  [data-theme="glassmorphism"] .theme-dropdown {
    background: rgba(255, 255, 255, 0.95);
  }
  
  [data-theme="glassmorphism"] .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.9);
  }
}