/* ==========================================================================
   CosyUI - Dynamic Frontend Player UI Styling
   User customizable interface rendered directly from UI Graph Nodes
   ========================================================================== */

.player-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--cosy-bg-surface);
  color: var(--cosy-text-main);
  position: relative;
  overflow: hidden;
}

/* Player Top Bar */
.player-topbar {
  height: 44px;
  min-height: 44px;
  background-color: var(--cosy-bg-surface-elevated);
  border-bottom: 1px solid var(--cosy-border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}

.player-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--cosy-text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cosy-success);
  box-shadow: 0 0 8px var(--cosy-success-glow);
}

.status-dot.busy {
  background: var(--cosy-warning);
  box-shadow: 0 0 8px var(--cosy-warning);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* Player Main Viewport Content */
.player-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* UI Layout Container Node Component */
.ui-layout-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--cosy-bg-card);
  border: 1px solid var(--cosy-border);
  border-radius: var(--cosy-radius-md);
  padding: 14px;
  box-shadow: var(--cosy-shadow-sm);
}

.ui-layout-box.horizontal {
  flex-direction: row;
  align-items: center;
}

.ui-layout-box.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* UI Story / Narrative Box */
.ui-story-card {
  background: var(--cosy-bg-card);
  border: 1px solid var(--cosy-border);
  border-radius: var(--cosy-radius-md);
  padding: 16px;
  line-height: 1.6;
  font-size: 14px;
  color: var(--cosy-text-main);
  position: relative;
  box-shadow: var(--cosy-shadow-sm);
}

.ui-story-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--cosy-accent);
  margin-bottom: 8px;
}

.ui-story-prose {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Typewriter Cursor */
.typewriter-cursor::after {
  content: '▋';
  color: var(--cosy-accent);
  animation: blink 0.8s infinite;
}

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

/* UI Stat Bars / Gauges */
.ui-stat-bar-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--cosy-bg-card);
  border: 1px solid var(--cosy-border);
  border-radius: var(--cosy-radius-md);
  padding: 12px;
}

.ui-stat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ui-stat-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--cosy-text-muted);
}

.ui-stat-track {
  height: 10px;
  background: var(--cosy-bg-base);
  border-radius: var(--cosy-radius-round);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ui-stat-fill {
  height: 100%;
  border-radius: var(--cosy-radius-round);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ui-stat-fill.hp {
  background: linear-gradient(90deg, #ef4444 0%, #f43f5e 100%);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.ui-stat-fill.mana {
  background: linear-gradient(90deg, #0284c7 0%, #38bdf8 100%);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.ui-stat-fill.energy {
  background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.ui-stat-fill.sanity {
  background: linear-gradient(90deg, #7c3aed 0%, #a855f7 100%);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

/* UI Inventory / Grid */
.ui-inventory-panel {
  background: var(--cosy-bg-card);
  border: 1px solid var(--cosy-border);
  border-radius: var(--cosy-radius-md);
  padding: 12px;
}

.ui-inventory-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--cosy-text-main);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.ui-inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.ui-inventory-slot {
  aspect-ratio: 1;
  background: var(--cosy-bg-surface-elevated);
  border: 1px solid var(--cosy-border);
  border-radius: var(--cosy-radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: transform var(--cosy-transition-fast), border-color var(--cosy-transition-fast);
  padding: 4px;
}

.ui-inventory-slot:hover {
  border-color: var(--cosy-accent);
  transform: translateY(-2px);
  background: var(--cosy-bg-card-hover);
}

.slot-item-icon {
  font-size: 20px;
}

.slot-item-name {
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  color: var(--cosy-text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-item-qty {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 9px;
  font-weight: 700;
  color: var(--cosy-accent);
}

/* UI Choice Buttons */
.ui-choice-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ui-choice-btn {
  background: var(--cosy-bg-card);
  border: 1px solid var(--cosy-border-light);
  border-radius: var(--cosy-radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--cosy-text-main);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all var(--cosy-transition-fast);
}

.ui-choice-btn:hover {
  background: var(--cosy-bg-card-hover);
  border-color: var(--cosy-accent);
  transform: translateX(4px);
  box-shadow: 0 2px 8px var(--cosy-accent-glow);
}

.choice-hotkey {
  width: 20px;
  height: 20px;
  border-radius: var(--cosy-radius-xs);
  background: var(--cosy-bg-surface-elevated);
  border: 1px solid var(--cosy-border);
  color: var(--cosy-accent);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* UI Chatbox Component */
.ui-chatbox {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--cosy-bg-card);
  border: 1px solid var(--cosy-border);
  border-radius: var(--cosy-radius-md);
  overflow: hidden;
  min-height: 240px;
}

.chatbox-header {
  padding: 10px 14px;
  background: var(--cosy-bg-surface-elevated);
  border-bottom: 1px solid var(--cosy-border);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chatbox-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--cosy-radius-md);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  animation: fadeIn 0.2s ease-out;
}

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

.chat-bubble.user {
  align-self: flex-end;
  background: var(--cosy-accent);
  color: #121215;
  font-weight: 500;
  border-bottom-right-radius: 2px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--cosy-bg-surface-elevated);
  border: 1px solid var(--cosy-border);
  color: var(--cosy-text-main);
  border-bottom-left-radius: 2px;
}

.chat-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--cosy-text-subtle);
  font-size: 11px;
  font-style: italic;
  padding: 4px 8px;
}

/* Typing Indicator */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cosy-text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* Chat Input Bar */
.chatbox-input-row {
  padding: 10px;
  background: var(--cosy-bg-surface-elevated);
  border-top: 1px solid var(--cosy-border);
  display: flex;
  gap: 8px;
}

.chatbox-input {
  flex: 1;
  background: var(--cosy-bg-base);
  border: 1px solid var(--cosy-border);
  border-radius: var(--cosy-radius-sm);
  color: var(--cosy-text-main);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.chatbox-input:focus {
  border-color: var(--cosy-accent);
}

.chatbox-send-btn {
  background: var(--cosy-accent);
  color: #121215;
  border: none;
  border-radius: var(--cosy-radius-sm);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--cosy-transition-fast);
}

.chatbox-send-btn:hover {
  filter: brightness(1.1);
}
