/* WIA Talk - Demo Page Styles */
/* Philosophy: 홍익인간 (弘益人間) - Benefit All Humanity */

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: rgba(255, 255, 255, 0.95);
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 2.5em;
  color: #667eea;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 1.2em;
  color: #764ba2;
  font-weight: 500;
  margin-bottom: 5px;
}

.phase {
  font-size: 0.9em;
  color: #666;
  font-style: italic;
}

.container {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.panel {
  background: white;
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.panel h2 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 1.5em;
  border-bottom: 2px solid #667eea;
  padding-bottom: 10px;
}

.panel h3 {
  color: #764ba2;
  margin-top: 20px;
  margin-bottom: 15px;
  font-size: 1.2em;
}

/* Video Panel */
.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

#video, #canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#canvas {
  z-index: 10;
}

/* Controls */
.controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.btn {
  flex: 1;
  padding: 12px 20px;
  font-size: 1em;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #764ba2;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #63408a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(118, 75, 162, 0.4);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Metrics */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.metric {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  color: white;
}

.metric .label {
  display: block;
  font-size: 0.85em;
  opacity: 0.9;
  margin-bottom: 5px;
}

.metric .value {
  display: block;
  font-size: 1.5em;
  font-weight: bold;
}

.status-idle { color: #fff; }
.status-running { color: #4ade80; }
.status-error { color: #f87171; }

/* Gesture Result */
.gesture-result {
  background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
  padding: 30px;
  border-radius: 15px;
  margin-bottom: 25px;
  text-align: center;
}

.gesture-emoji {
  font-size: 5em;
  margin-bottom: 15px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.gesture-code {
  font-size: 1.8em;
  font-weight: bold;
  color: #d63031;
  margin-bottom: 8px;
  font-family: 'Courier New', monospace;
}

.gesture-name-ko {
  font-size: 1.5em;
  font-weight: bold;
  color: #2d3436;
  margin-bottom: 5px;
}

.gesture-name-en {
  font-size: 1.2em;
  color: #636e72;
  font-style: italic;
}

/* Confidence Bar */
.confidence-bar {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.confidence-label {
  font-weight: 600;
  color: #2d3436;
  min-width: 90px;
}

.confidence-progress {
  flex: 1;
  height: 25px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, #00b894 0%, #00cec9 100%);
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: white;
  font-weight: bold;
  font-size: 0.85em;
}

.confidence-value {
  min-width: 50px;
  font-weight: bold;
  color: #2d3436;
  font-size: 1.1em;
}

/* Components */
.components {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.component {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 10px;
  background: white;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.component-label {
  font-weight: 600;
  color: #2d3436;
  min-width: 120px;
}

.component-code {
  font-family: 'Courier New', monospace;
  background: #667eea;
  color: white;
  padding: 4px 12px;
  border-radius: 5px;
  font-weight: bold;
  margin-right: 10px;
}

.component-name {
  color: #636e72;
  font-style: italic;
}

.component-code-full {
  display: block;
  padding: 15px;
  background: #2d3436;
  color: #00b894;
  border-radius: 8px;
  margin-top: 15px;
  font-family: 'Courier New', monospace;
  font-size: 0.95em;
}

.component-code-full code {
  color: #00b894;
  font-weight: bold;
}

/* Debug Panel */
.debug-panel {
  background: #f1f3f5;
  padding: 15px;
  border-radius: 10px;
  margin-top: 20px;
}

.debug-panel h3 {
  cursor: pointer;
  user-select: none;
  margin: 0;
  padding: 10px;
  background: #e9ecef;
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.debug-panel h3:hover {
  background: #dee2e6;
}

.debug-content {
  padding-top: 15px;
}

.debug-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #dee2e6;
}

.debug-label {
  font-weight: 600;
  color: #495057;
}

.debug-item span:last-child {
  color: #667eea;
  font-family: 'Courier New', monospace;
}

/* Footer */
footer {
  background: rgba(255, 255, 255, 0.95);
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 0.9em;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

footer p {
  margin: 5px 0;
}

footer a {
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
}

footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1200px) {
  .container {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 768px) {
  header h1 {
    font-size: 1.8em;
  }

  .subtitle {
    font-size: 1em;
  }

  .panel {
    padding: 15px;
  }

  .gesture-emoji {
    font-size: 3.5em;
  }

  .gesture-code {
    font-size: 1.3em;
  }

  .gesture-name-ko {
    font-size: 1.2em;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .component {
    flex-direction: column;
    align-items: flex-start;
  }

  .component-label {
    margin-bottom: 8px;
  }
}

/* Translation Controls (Phase 3) */
.translation-controls {
  display: flex;
  gap: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.control-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #2d3436;
  cursor: pointer;
}

.control-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.control-label select {
  padding: 6px 12px;
  border: 2px solid #667eea;
  border-radius: 6px;
  font-size: 0.95em;
  background: white;
  color: #2d3436;
  cursor: pointer;
  transition: all 0.3s ease;
}

.control-label select:hover {
  border-color: #764ba2;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.control-label select:focus {
  outline: none;
  border-color: #764ba2;
  box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

/* Translation Panel (Phase 3) */
.translation-panel {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.translation-output {
  background: white;
  border-radius: 8px;
  padding: 20px;
  min-height: 150px;
  margin-bottom: 15px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.translation-text {
  font-size: 1.3em;
  line-height: 1.6;
  color: #2d3436;
  min-height: 60px;
  padding: 10px;
  border-bottom: 2px solid #e9ecef;
  margin-bottom: 15px;
}

.translation-text:empty::before {
  content: 'Make gestures to create a sentence...';
  color: #95a5a6;
  font-style: italic;
}

.translation-history {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
}

.gesture-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 600;
  animation: slideIn 0.3s ease;
}

.gesture-chip-emoji {
  font-size: 1.2em;
}

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

.translation-actions {
  display: flex;
  gap: 10px;
}

.btn-small {
  flex: 1;
  padding: 10px 16px;
  font-size: 0.95em;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  background: #667eea;
  color: white;
}

.btn-small:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-small:active {
  transform: translateY(0);
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

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

/* Settings Modal (Phase 4) */
.settings-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.8);
  animation: fadeIn 0.3s ease;
}

.settings-modal-content {
  background: white;
  margin: 2% auto;
  padding: 0;
  border-radius: 20px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  animation: slideDown 0.3s ease;
}

.settings-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 25px 30px;
  border-radius: 20px 20px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-header h2 {
  margin: 0;
  font-size: 1.8em;
}

.settings-close {
  font-size: 2em;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.settings-close:hover {
  transform: scale(1.2);
}

.settings-body {
  padding: 30px;
}

.settings-section {
  margin-bottom: 30px;
  padding-bottom: 25px;
  border-bottom: 2px solid #e9ecef;
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  color: #667eea;
  font-size: 1.3em;
  margin-bottom: 15px;
}

.settings-description {
  color: #666;
  font-size: 0.95em;
  line-height: 1.6;
  margin-bottom: 15px;
}

/* Provider Selection */
.provider-select {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.provider-option {
  cursor: pointer;
}

.provider-option input[type="radio"] {
  display: none;
}

.provider-card {
  padding: 15px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  transition: all 0.3s ease;
  background: #f8f9fa;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.provider-option input[type="radio"]:checked + .provider-card {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.provider-card:hover {
  border-color: #764ba2;
  transform: translateY(-2px);
}

.provider-name {
  font-weight: 700;
  font-size: 1em;
  color: #2d3436;
  margin-bottom: 8px;
}

.provider-desc {
  font-size: 0.85em;
  color: #636e72;
  margin-bottom: 10px;
  flex: 1;
}

.provider-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  align-self: flex-start;
}

.provider-badge.free {
  background: #00b894;
  color: white;
}

.provider-badge.paid {
  background: #fdcb6e;
  color: #2d3436;
}

/* API Key Input */
.api-key-input {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.api-key-input input {
  flex: 1;
  padding: 12px 15px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 0.95em;
  font-family: 'Courier New', monospace;
}

.api-key-input input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-icon {
  padding: 10px 15px;
  border: 2px solid #e9ecef;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2em;
  transition: all 0.3s ease;
}

.btn-icon:hover {
  background: #f8f9fa;
  border-color: #667eea;
}

.api-key-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.api-key-status {
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 0.95em;
  margin-top: 10px;
}

.api-key-status.success {
  background: #d5f4e6;
  color: #00b894;
  border: 1px solid #00b894;
}

.api-key-status.error {
  background: #ffeaa7;
  color: #d63031;
  border: 1px solid #d63031;
}

.api-key-status.info {
  background: #dfe6e9;
  color: #2d3436;
  border: 1px solid #b2bec3;
}

.api-key-desc {
  font-size: 0.9em;
  margin-bottom: 15px;
}

.api-key-desc a {
  color: #667eea;
  font-weight: 600;
  text-decoration: none;
}

.api-key-desc a:hover {
  text-decoration: underline;
}

/* Other Settings */
.setting-item {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
}

.setting-item label {
  font-weight: 600;
  color: #2d3436;
  min-width: 180px;
}

.setting-item input[type="range"] {
  flex: 1;
  cursor: pointer;
}

.setting-item span {
  min-width: 70px;
  text-align: right;
  font-weight: 600;
  color: #667eea;
  font-family: 'Courier New', monospace;
}

/* Status Grid */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.status-item {
  padding: 12px 15px;
  background: #f8f9fa;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-label {
  font-weight: 600;
  color: #636e72;
  font-size: 0.9em;
}

.status-item span:last-child {
  font-weight: 700;
  color: #667eea;
  font-family: 'Courier New', monospace;
}

.settings-footer {
  padding: 20px 30px;
  border-top: 2px solid #e9ecef;
  text-align: right;
  background: #f8f9fa;
  border-radius: 0 0 20px 20px;
}

.btn-danger {
  background: #d63031;
  color: white;
}

.btn-danger:hover {
  background: #c0211f;
}

/* Responsive */
@media (max-width: 768px) {
  .provider-select {
    grid-template-columns: 1fr;
  }

  .settings-modal-content {
    margin: 5% auto;
    width: 95%;
  }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .setting-item label {
    min-width: auto;
  }

  .setting-item input[type="range"] {
    width: 100%;
  }

  .api-key-actions {
    flex-direction: column;
  }

  .api-key-actions button {
    width: 100%;
  }
}
