/* Sogo Digital Human – Kiosk UI */

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

:root {
  --primary: #c9a84c;
  --primary-light: #e0c980;
  --primary-dim: rgba(201, 168, 76, 0.12);
  --bg-dark: #080812;
  --bg-panel: rgba(10, 10, 26, 0.75);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-msg-user: rgba(40, 48, 100, 0.55);
  --bg-msg-asst: rgba(20, 20, 50, 0.5);
  --border: rgba(201, 168, 76, 0.15);
  --border-focus: rgba(201, 168, 76, 0.4);
  --text: #f0ebe3;
  --text-secondary: #b8a88a;
  --text-muted: #7a6f5e;
  --success: #6dba7a;
  --danger: #c94040;
  --radius: 14px;
  --radius-sm: 10px;
  --chat-width: 680px;
  --quick-sidebar-width: 140px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
}

/* ---- Quick Actions: left sidebar (config-page style, no background) ---- */
#quick-actions-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--quick-sidebar-width);
  z-index: 50;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: transparent;
}
body.config-mode #quick-actions-sidebar {
  display: none;
}
#quick-actions-sidebar .quick-btn {
  flex-shrink: 0;
  width: 100%;
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 168, 76, 0.2);
  background: rgba(255, 255, 255, 0.03) !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: center;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#quick-actions-sidebar .quick-btn-icon {
  font-size: 1.75rem;
  line-height: 1;
}
#quick-actions-sidebar .quick-btn-icon-img {
  width: 1.75rem;
  height: auto;
  display: block;
  object-fit: contain;
}
#quick-actions-sidebar .quick-btn-label {
  font-size: 13px;
  line-height: 1.3;
}
#quick-actions-sidebar .quick-btn:hover {
  border-color: rgba(201, 168, 76, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  background: rgba(201, 168, 76, 0.12) !important;
}
#quick-actions-sidebar .quick-btn:active {
  transform: scale(0.98);
}
#quick-actions-sidebar .quick-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- 3D Canvas (full width so background shows under sidebar; buttons float on it) ---- */
#canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#avatar-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: var(--bg-dark);
  background-size: cover;
  background-position: center;
}

#avatar-background.blur {
  filter: blur(5px);
}

#avatar-background.theme-starry {
  background-color: transparent;
  background-image: radial-gradient(ellipse 120% 100% at 50% 0%, #1a1a3e 0%, #0d0d1a 50%, #050508 100%);
}

#avatar-background.theme-galaxy {
  background-color: transparent;
  background-image: radial-gradient(ellipse 150% 120% at 50% 20%, #2d1b4e 0%, #1a0f2e 40%, #0a0612 100%);
}

#avatar-bg-stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
}

#avatar-bg-stars.active {
  display: block;
}

#avatar-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
}

/* ---- Loading Overlay ---- */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
}
#loading-overlay.hidden {
  display: none;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(201, 168, 76, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--text-muted); font-size: 0.9rem; }

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

/* ---- Subtitle Bar (hidden: only chat bubbles used) ---- */
#subtitle-bar {
  display: none;
}

#subtitle-text {
  display: inline-block;
  max-width: 600px;
  padding: 12px 24px;
  background: rgba(12, 12, 28, 0.92);
  backdrop-filter: blur(4px);
  border-radius: var(--radius);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#subtitle-text.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Logo (top left) ---- */
#app-logo {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 50;
  pointer-events: none;
}
body.config-mode #app-logo {
  top: auto;
  left: auto;
  bottom: 24px;
  right: 24px;
}
#app-logo img {
  display: block;
  max-height: 48px;
  max-width: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ---- Chat Panel (no background: floating bubbles only) ---- */
#chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--chat-width);
  background: transparent !important;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding-top: 80px;
}

/* ---- Language Toggle (rightmost of screen; above chat panel so clicks work) ---- */
.lang-float {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 110;
  display: flex;
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
body.config-mode .lang-float { display: none; }

.lang-btn {
  padding: 5px 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn:hover { background: var(--primary-dim); color: var(--primary-light); }
.lang-btn.active { background: var(--primary-dim); color: var(--primary-light); }

/* ---- Chat History ---- */
#chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: transparent !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 76, 0.25) transparent;
}

#chat-history::-webkit-scrollbar { width: 5px; }
#chat-history::-webkit-scrollbar-track { background: transparent; }
#chat-history::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, 0.25);
  border-radius: 3px;
}

/* ---- Chat Bubbles (floating) ---- */
.chat-msg {
  padding: 20px 28px;
  border-radius: var(--radius-sm);
  font-size: 28px;
  line-height: 1.5;
  max-width: 96%;
  animation: floatIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  word-wrap: break-word;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--bg-msg-asst);
  color: var(--text);
  border-bottom-right-radius: 3px;
  border: 1px solid rgba(201, 168, 76, 0.12);
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg-msg-user);
  color: var(--text);
  border-bottom-left-radius: 3px;
  border: 1px solid rgba(201, 168, 76, 0.25);
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Thinking Indicator ---- */
#thinking-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 16px;
}

#thinking-indicator.visible { display: flex; }

.dot-loader span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: dotBounce 1.4s infinite ease-in-out both;
}

.dot-loader span:nth-child(1) { animation-delay: -0.32s; }
.dot-loader span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ---- Input Row (aligned right with language control) ---- */
#input-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px 20px;
}

.btn-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.btn-icon-mic { color: inherit; }
.btn-icon-refresh { color: var(--text); }

#btn-mic .btn-icon-mic { width: 20px; height: 20px; }

.btn-start-over {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}
.btn-start-over .btn-icon-refresh { width: 20px; height: 20px; }
.btn-start-over:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  font-size: 18px;
}

.btn:active { transform: scale(0.9); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

#btn-mic {
  width: 44px;
  min-width: 44px;
  height: 44px;
  background: var(--primary);
  color: #1b1f3b;
  border: 2px solid rgba(201, 168, 76, 0.5);
  box-shadow: 0 4px 16px rgba(201, 168, 76, 0.3);
}

#btn-mic:hover:not(:disabled) {
  background: var(--primary-light);
  box-shadow: 0 6px 20px rgba(201, 168, 76, 0.4);
}

#btn-mic.recording {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 4px 16px rgba(201, 68, 68, 0.4);
  animation: pulse 1s infinite;
}

/* ---- Config Panel ---- */
body.config-mode #chat-panel    { display: none !important; }
body.config-mode #canvas-container {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
}
body.config-mode #subtitle-bar  { width: 100% !important; }

#config-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  background: transparent;
}
#config-panel.visible {
  display: flex;
  align-items: stretch;
}

.cfg-side {
  width: 240px;
  flex-shrink: 0;
  padding: 16px 12px;
  pointer-events: all;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  overflow-y: auto;
  background: transparent;
}

.cfg-glass-card {
  /* Minimal background so backdrop-filter runs (browsers often skip it when fully transparent) */
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  -moz-backdrop-filter: blur(4px);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: var(--radius);
  padding: 14px 12px;
  flex-shrink: 0;
}
.cfg-glass-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-light);
  margin: 0 0 10px 0;
}
.cfg-preview-only-note {
  font-size: 11px;
  line-height: 1.35;
  color: var(--primary-light);
  background: rgba(201, 168, 76, 0.12);
  border: 1px solid rgba(201, 168, 76, 0.35);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 10px 0;
}
.cfg-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cfg-preview-btn {
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
}
.cfg-preview-btn:hover {
  background: rgba(201, 168, 76, 0.15);
  border-color: rgba(201, 168, 76, 0.3);
}
.cfg-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cfg-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.cfg-label span:first-child {
  font-size: 11px;
  color: var(--text-muted);
}
.cfg-label span:last-child {
  font-size: 11px;
  color: var(--primary-light);
  font-variant-numeric: tabular-nums;
}
.cfg-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.cfg-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #1b1f3b;
}
.cfg-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #1b1f3b;
}

#config-panel .cfg-group select {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 6px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0c980' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
#config-panel .cfg-group select option {
  background: #12121f;
  color: var(--text);
}

#config-panel > .cfg-actions {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
  pointer-events: all;
}
.cfg-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cfg-action-btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(201, 168, 76, 0.2);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.cfg-action-btn:hover {
  background: rgba(201, 168, 76, 0.12);
  border-color: rgba(201, 168, 76, 0.35);
}
.cfg-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  pointer-events: all;
  position: relative;
}
.cfg-center .cfg-avatar-select {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.cfg-avatar-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cfg-avatar-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cfg-avatar-btn:hover {
  background: rgba(201, 168, 76, 0.12);
  border-color: rgba(201, 168, 76, 0.3);
}
.cfg-avatar-btn.active {
  background: rgba(201, 168, 76, 0.2);
  border-color: var(--primary);
  color: var(--primary-light);
}
#cfg-save.cfg-action-save {
  background: var(--primary);
  color: #1b1f3b;
  border-color: var(--primary);
  backdrop-filter: none;
}
#cfg-save.cfg-action-save:hover {
  background: #d4b85a;
  border-color: #d4b85a;
}
#cfg-save.cfg-action-save.cfg-saved {
  background: var(--success);
  color: #0a0a12;
  border-color: var(--success);
}
#cfg-save.cfg-action-save.cfg-saved:hover {
  background: #7dc989;
  border-color: #7dc989;
}
#cfg-reset:hover {
  background: rgba(255, 255, 255, 0.06);
}
#cfg-exit.cfg-action-exit {
  background: rgba(200, 60, 60, 0.12);
  color: #ff8080;
  border-color: rgba(200, 60, 60, 0.3);
}
#cfg-exit.cfg-action-exit:hover {
  background: rgba(200, 60, 60, 0.22);
  border-color: rgba(200, 60, 60, 0.45);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  :root { --chat-width: 480px; }
}

@media (max-width: 640px) {
  :root { --chat-width: 100%; --quick-sidebar-width: 0; }

  .lang-float { right: 16px; }

  #quick-actions-sidebar { display: none; }
  #canvas-container {
    left: 0;
    width: 100%;
    height: 45%;
  }

  #subtitle-bar {
    left: 0;
    width: 100%;
    bottom: auto;
    top: calc(45% - 52px);
  }

  #chat-panel {
    top: 45%;
    width: 100%;
    border-left: none;
    border-top: none;
  }
}
