/**
 * Chakra UI v3 디자인 시스템 기반 스타일
 */

/* === Font Face === */
@font-face {
  font-family: 'LINESeedKR';
  font-weight: 300;
  font-style: normal;
  src: url('/fonts/LINESeedKR-Th.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'LINESeedKR';
  font-weight: 400;
  font-style: normal;
  src: url('/fonts/LINESeedKR-Rg.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'LINESeedKR';
  font-weight: 700;
  font-style: normal;
  src: url('/fonts/LINESeedKR-Bd.woff2') format('woff2');
  font-display: swap;
}

/* === Design Tokens === */
:root {
  /* Colors - Chakra UI v3 */
  --chakra-colors-blue-50: #eff6ff;
  --chakra-colors-blue-100: #dbeafe;
  --chakra-colors-blue-500: #3b82f6;
  --chakra-colors-blue-600: #2563eb;
  --chakra-colors-blue-700: #1d4ed8;

  --chakra-colors-red-50: #fef2f2;
  --chakra-colors-red-500: #ef4444;
  --chakra-colors-red-600: #dc2626;

  --chakra-colors-green-50: #f0fdf4;
  --chakra-colors-green-500: #22c55e;

  --chakra-colors-gray-50: #f9fafb;
  --chakra-colors-gray-100: #f3f4f6;
  --chakra-colors-gray-200: #e5e7eb;
  --chakra-colors-gray-300: #d1d5db;
  --chakra-colors-gray-500: #6b7280;
  --chakra-colors-gray-600: #4b5563;
  --chakra-colors-gray-700: #374151;
  --chakra-colors-gray-800: #1f2937;
  --chakra-colors-gray-900: #111827;

  /* Spacing - 4px 기반 */
  --chakra-space-1: 0.25rem; /* 4px */
  --chakra-space-2: 0.5rem;  /* 8px */
  --chakra-space-3: 0.75rem; /* 12px */
  --chakra-space-4: 1rem;    /* 16px */
  --chakra-space-5: 1.25rem; /* 20px */
  --chakra-space-6: 1.5rem;  /* 24px */
  --chakra-space-8: 2rem;    /* 32px */
  --chakra-space-10: 2.5rem; /* 40px */
  --chakra-space-12: 3rem;   /* 48px */

  /* Radius */
  --chakra-radii-sm: 0.25rem;
  --chakra-radii-md: 0.5rem;
  --chakra-radii-lg: 0.75rem;
  --chakra-radii-xl: 1rem;
  --chakra-radii-full: 9999px;

  /* Shadows */
  --chakra-shadows-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --chakra-shadows-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --chakra-shadows-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --chakra-shadows-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);

  /* Typography */
  --chakra-font-body: 'LINESeedKR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --chakra-font-sizes-sm: 0.875rem;
  --chakra-font-sizes-md: 1rem;
  --chakra-font-sizes-lg: 1.125rem;
  --chakra-font-sizes-xl: 1.25rem;
  --chakra-font-sizes-2xl: 1.5rem;
  --chakra-font-sizes-3xl: 1.875rem;

  /* Transitions */
  --chakra-transition-duration-normal: 200ms;
  --chakra-transition-easing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--chakra-font-body);
  background: var(--chakra-colors-gray-50);
  color: var(--chakra-colors-gray-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Container === */
.chakra-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
.chakra-header {
  background: white;
  border-bottom: 1px solid var(--chakra-colors-gray-200);
  padding: var(--chakra-space-4) var(--chakra-space-6);
  width: 100%;
}

.chakra-header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--chakra-space-4);
}

.chakra-heading {
  font-size: var(--chakra-font-sizes-2xl);
  font-weight: 700;
  color: var(--chakra-colors-gray-900);
}

.chakra-header-actions {
  display: flex;
  align-items: center;
  gap: var(--chakra-space-3);
}

/* === Badge (Status) === */
.chakra-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--chakra-space-2);
  padding: var(--chakra-space-2) var(--chakra-space-3);
  background: transparent;
  border-radius: var(--chakra-radii-full);
  font-size: var(--chakra-font-sizes-sm);
  font-weight: 500;
}

.chakra-badge-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--chakra-radii-full);
  background: var(--chakra-colors-gray-500);
  flex-shrink: 0;
  display: inline-block;
}

.chakra-badge-dot.connected {
  background: var(--chakra-colors-green-500);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.chakra-badge-dot.connecting {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.chakra-badge-dot.disconnected,
.chakra-badge-dot.error {
  background: var(--chakra-colors-red-500);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* === Icon Button === */
.chakra-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--chakra-radii-md);
  color: var(--chakra-colors-gray-700);
  cursor: pointer;
  transition: all var(--chakra-transition-duration-normal) var(--chakra-transition-easing);
  text-decoration: none;
}

.chakra-icon-button:hover {
  background: var(--chakra-colors-gray-100);
  color: var(--chakra-colors-gray-900);
}

.chakra-icon-button .material-icons {
  font-size: 22px;
}

/* === Main === */
.chakra-main {
  flex: 1;
  padding: var(--chakra-space-6);
  display: flex;
  flex-direction: column;
  gap: var(--chakra-space-6);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* === Button === */
.chakra-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--chakra-space-2);
  padding: var(--chakra-space-3) var(--chakra-space-4);
  border: none;
  border-radius: var(--chakra-radii-xl);
  font-family: inherit;
  font-size: var(--chakra-font-sizes-md);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--chakra-transition-duration-normal) var(--chakra-transition-easing);
  white-space: nowrap;
}

.chakra-button-sm {
  padding: var(--chakra-space-2) var(--chakra-space-3);
  font-size: var(--chakra-font-sizes-sm);
}

.chakra-button-lg {
  padding: var(--chakra-space-4) var(--chakra-space-6);
  font-size: var(--chakra-font-sizes-lg);
}

.chakra-button-full {
  width: 100%;
}

.chakra-button-primary {
  background: var(--chakra-colors-blue-500);
  color: white;
}

.chakra-button-primary:hover:not(:disabled) {
  background: var(--chakra-colors-blue-600);
}

.chakra-button-primary:active:not(:disabled) {
  background: var(--chakra-colors-blue-700);
}

.chakra-button-danger {
  background: var(--chakra-colors-red-500);
  color: white;
}

.chakra-button-danger:hover:not(:disabled) {
  background: var(--chakra-colors-red-600);
}

.chakra-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chakra-button .material-icons {
  font-size: 20px;
}

.chakra-button-group {
  display: flex;
  gap: var(--chakra-space-3);
  justify-content: center;
}

/* === Card === */
.chakra-card {
  background: white;
  border: 1px solid var(--chakra-colors-gray-200);
  border-radius: var(--chakra-radii-lg);
  box-shadow: var(--chakra-shadows-sm);
  overflow: hidden;
}

.chakra-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--chakra-space-4) var(--chakra-space-6);
  border-bottom: 1px solid var(--chakra-colors-gray-200);
}

.chakra-card-title {
  font-size: var(--chakra-font-sizes-lg);
  font-weight: 600;
  color: var(--chakra-colors-gray-900);
}

.chakra-card-body {
  padding: var(--chakra-space-6);
}

/* === Context Display === */
.chakra-context-display {
  color: var(--chakra-colors-gray-700);
  font-size: var(--chakra-font-sizes-md);
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chakra-context-display:empty::before {
  content: '설정에서 상황을 입력하세요.';
  color: var(--chakra-colors-gray-500);
}

/* === Visualizer === */
#visualizer {
  display: block;
  width: 100%;
  height: auto;
  padding: var(--chakra-space-6);
}

/* === Messages === */
.chakra-messages {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--chakra-space-4);
}

.message {
  display: flex;
  gap: var(--chakra-space-3);
  animation: slideIn 0.3s var(--chakra-transition-easing);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--chakra-radii-full);
  background: var(--chakra-colors-gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-avatar .material-icons {
  font-size: 20px;
  color: var(--chakra-colors-gray-600);
}

.message-content {
  flex: 1;
  padding: var(--chakra-space-3) var(--chakra-space-4);
  border-radius: var(--chakra-radii-lg);
  background: var(--chakra-colors-gray-100);
}

.message-user .message-content {
  background: var(--chakra-colors-blue-50);
}

.message-assistant .message-content {
  background: var(--chakra-colors-gray-100);
}

.message-system .message-content {
  background: var(--chakra-colors-gray-50);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--chakra-space-1);
}

.message-label {
  font-size: var(--chakra-font-sizes-sm);
  font-weight: 600;
  color: var(--chakra-colors-gray-600);
}

.message-text {
  color: var(--chakra-colors-gray-900);
  line-height: 1.6;
}

.message-time {
  font-size: var(--chakra-font-sizes-sm);
  color: var(--chakra-colors-gray-500);
}

/* === Stats === */
.chakra-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--chakra-space-4);
  padding: var(--chakra-space-6);
  background: white;
  border: 1px solid var(--chakra-colors-gray-200);
  border-radius: var(--chakra-radii-lg);
}

.chakra-stat {
  text-align: center;
}

.chakra-stat-label {
  font-size: var(--chakra-font-sizes-sm);
  color: var(--chakra-colors-gray-600);
  font-weight: 500;
  margin-bottom: var(--chakra-space-2);
}

.chakra-stat-value {
  font-size: var(--chakra-font-sizes-3xl);
  font-weight: 700;
  color: var(--chakra-colors-blue-600);
}

/* === Footer === */
.chakra-footer {
  background: white;
  border-top: 1px solid var(--chakra-colors-gray-200);
  padding: var(--chakra-space-4) var(--chakra-space-6);
}

.chakra-footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--chakra-space-2);
  font-size: var(--chakra-font-sizes-sm);
  color: var(--chakra-colors-gray-600);
}

.chakra-footer-content .material-icons {
  font-size: 16px;
}

/* === Drawer === */
.chakra-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1400;
  display: none;
}

.chakra-drawer.active {
  display: block;
}

.chakra-drawer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s var(--chakra-transition-easing);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.chakra-drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 70vw;
  max-width: 800px;
  background: white;
  box-shadow: var(--chakra-shadows-xl);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s var(--chakra-transition-easing);
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.chakra-drawer-header {
  padding: var(--chakra-space-6);
  border-bottom: 1px solid var(--chakra-colors-gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chakra-drawer-title {
  display: flex;
  align-items: center;
  gap: var(--chakra-space-2);
  font-size: var(--chakra-font-sizes-xl);
  font-weight: 700;
  color: var(--chakra-colors-gray-900);
}

.chakra-drawer-title .material-icons {
  font-size: 24px;
}

.chakra-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--chakra-space-6);
}

.chakra-drawer-footer {
  padding-top: var(--chakra-space-6);
  margin-top: var(--chakra-space-6);
  border-top: 1px solid var(--chakra-colors-gray-200);
}

/* === Form === */
.chakra-form-control {
  margin-bottom: var(--chakra-space-6);
}

.chakra-form-label {
  display: flex;
  align-items: center;
  gap: var(--chakra-space-2);
  font-size: var(--chakra-font-sizes-sm);
  font-weight: 600;
  color: var(--chakra-colors-gray-700);
  margin-bottom: var(--chakra-space-2);
}

.chakra-form-label .material-icons {
  font-size: 18px;
}

.chakra-form-helper {
  font-size: var(--chakra-font-sizes-sm);
  color: var(--chakra-colors-gray-500);
  margin-top: var(--chakra-space-2);
  line-height: 1.4;
}

/* === Textarea === */
.chakra-textarea {
  width: 100%;
  height: 250px;
  padding: var(--chakra-space-3);
  border: 1px solid var(--chakra-colors-gray-300);
  border-radius: var(--chakra-radii-md);
  font-family: inherit;
  font-size: var(--chakra-font-sizes-md);
  color: var(--chakra-colors-gray-900);
  background: white;
  resize: vertical;
  transition: all var(--chakra-transition-duration-normal) var(--chakra-transition-easing);
}

.chakra-textarea:hover {
  border-color: var(--chakra-colors-gray-400);
}

.chakra-textarea:focus {
  outline: none;
  border-color: var(--chakra-colors-blue-500);
  box-shadow: 0 0 0 1px var(--chakra-colors-blue-500);
}

/* === Select === */
.chakra-select {
  width: 100%;
  padding: var(--chakra-space-3);
  border: 1px solid var(--chakra-colors-gray-300);
  border-radius: var(--chakra-radii-md);
  font-family: inherit;
  font-size: var(--chakra-font-sizes-md);
  color: var(--chakra-colors-gray-900);
  background: white;
  cursor: pointer;
  transition: all var(--chakra-transition-duration-normal) var(--chakra-transition-easing);
}

.chakra-select:hover {
  border-color: var(--chakra-colors-gray-400);
}

.chakra-select:focus {
  outline: none;
  border-color: var(--chakra-colors-blue-500);
  box-shadow: 0 0 0 1px var(--chakra-colors-blue-500);
}

/* === Slider === */
.chakra-slider-wrapper {
  display: flex;
  align-items: center;
  gap: var(--chakra-space-3);
}

.chakra-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--chakra-colors-gray-300);
  border-radius: var(--chakra-radii-full);
  outline: none;
}

.chakra-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--chakra-radii-full);
  background: var(--chakra-colors-blue-500);
  cursor: pointer;
  transition: all var(--chakra-transition-duration-normal) var(--chakra-transition-easing);
}

.chakra-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.chakra-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: var(--chakra-radii-full);
  background: var(--chakra-colors-blue-500);
  cursor: pointer;
  transition: all var(--chakra-transition-duration-normal) var(--chakra-transition-easing);
}

.chakra-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
}

.chakra-slider-value {
  min-width: 3rem;
  text-align: center;
  font-weight: 600;
  color: var(--chakra-colors-blue-600);
}

/* === Scrollbar === */
.chakra-messages::-webkit-scrollbar,
.chakra-drawer-body::-webkit-scrollbar {
  width: 8px;
}

.chakra-messages::-webkit-scrollbar-track,
.chakra-drawer-body::-webkit-scrollbar-track {
  background: var(--chakra-colors-gray-100);
  border-radius: var(--chakra-radii-sm);
}

.chakra-messages::-webkit-scrollbar-thumb,
.chakra-drawer-body::-webkit-scrollbar-thumb {
  background: var(--chakra-colors-gray-300);
  border-radius: var(--chakra-radii-sm);
}

.chakra-messages::-webkit-scrollbar-thumb:hover,
.chakra-drawer-body::-webkit-scrollbar-thumb:hover {
  background: var(--chakra-colors-gray-400);
}

/* === Responsive === */
@media (max-width: 768px) {
  .chakra-header {
    padding: var(--chakra-space-4);
  }

  .chakra-header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .chakra-heading {
    font-size: var(--chakra-font-sizes-xl);
  }

  .chakra-main {
    padding: var(--chakra-space-4);
    gap: var(--chakra-space-4);
  }

  .chakra-button-group {
    flex-direction: column;
  }

  .chakra-button-group .chakra-button {
    width: 100%;
  }

  .chakra-stats {
    grid-template-columns: 1fr;
    gap: var(--chakra-space-3);
  }

  .chakra-drawer-content {
    width: 100%;
    max-width: 100%;
  }
}
