/* ============================================
   Quest System UI Styles for OpenMUD
   Matches the knowledge-ui pattern with 2-column grid layout
   Uses theme variables from theme.css
   ============================================ */

/* Quest window positioning and base styles */
#quest-window {
  position: absolute;
  top: 100px;
  left: 250px;
  width: 850px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--theme-bg-secondary);
  border: 2px solid var(--theme-border-primary);
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: none;
  flex-direction: column;
}

/* Dragging state */
#quest-window.window-dragging {
  transition: none !important;
  user-select: none;
}

/* Window header drag handle styling */
#quest-window .window-header {
  cursor: move;
  user-select: none;
}

#quest-window .window-header:active {
  cursor: grabbing;
}

/* Override window-content to use flex layout */
#quest-window .window-content {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  overflow: hidden;
}

/* ============================================
   Two-Column Grid Layout
   ============================================ */

.quest-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.quest-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  padding: 12px;
  height: 100%;
  overflow: hidden;
}

/* ============================================
   Left Sidebar - Quest List
   ============================================ */

.quest-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

/* Quest Summary Stats */
.quest-summary {
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 2px;
  padding: 8px;
  font-size: 12px;
}

.quest-summary .summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.quest-summary .summary-row:last-child {
  margin-bottom: 0;
}

.quest-summary .summary-label {
  color: var(--theme-text-muted);
}

.quest-summary .summary-value {
  color: var(--theme-info);
  font-weight: bold;
}

/* Search and Filter Controls */
.quest-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quest-search-input {
  width: 100%;
  padding: 6px 8px;
  background: var(--theme-bg-input);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  color: var(--theme-text-primary);
  font-family: var(--theme-font-family);
  font-size: 12px;
}

.quest-search-input:focus {
  outline: none;
  border-color: var(--theme-accent-green);
}

.quest-search-input::placeholder {
  color: var(--theme-text-muted);
}

/* Filter Buttons */
.quest-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.quest-filters .filter-btn {
  padding: 4px 8px;
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 2px;
  color: var(--theme-text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quest-filters .filter-btn:hover {
  background: var(--theme-bg-hover);
  border-color: var(--theme-border-primary);
}

.quest-filters .filter-btn.active {
  background: var(--theme-room-name);
  border-color: var(--theme-room-name);
  color: var(--theme-bg-primary);
}

/* Quest List Container */
.quest-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

/* Custom scrollbar for quest list */
.quest-list::-webkit-scrollbar {
  width: 6px;
}

.quest-list::-webkit-scrollbar-track {
  background: var(--theme-bg-tertiary);
  border-radius: 3px;
}

.quest-list::-webkit-scrollbar-thumb {
  background: var(--theme-border-secondary);
  border-radius: 3px;
}

.quest-list::-webkit-scrollbar-thumb:hover {
  background: var(--theme-border-primary);
}

/* Quest List Item */
.quest-item {
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quest-item:hover {
  background: var(--theme-bg-hover);
  border-color: var(--theme-border-primary);
}

.quest-item.selected {
  background: var(--theme-bg-selected);
  border-color: var(--theme-room-name);
}

.quest-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.quest-item-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quest-name {
  color: var(--theme-text-primary);
  font-weight: bold;
  font-size: 12px;
}

.quest-timer {
  color: var(--theme-warning);
  font-size: 10px;
}

/* Quest Status Badges */
.quest-status {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 2px;
  text-transform: uppercase;
  font-weight: bold;
}

.quest-status.status-active {
  background: var(--theme-info);
  color: var(--theme-bg-primary);
}

.quest-status.status-ready {
  background: var(--theme-success);
  color: var(--theme-bg-primary);
}

.quest-status.status-completed {
  background: var(--theme-text-muted);
  color: var(--theme-bg-primary);
}

.quest-status.status-failed {
  background: var(--theme-error);
  color: var(--theme-bg-primary);
}

.quest-status.status-available {
  background: var(--theme-accent-gold);
  color: var(--theme-bg-primary);
}

/* Quest Progress Bar */
.quest-progress {
  margin-bottom: 6px;
}

.quest-progress-bar {
  position: relative;
  height: 12px;
  background: var(--theme-bg-primary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 2px;
  overflow: hidden;
}

.quest-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--theme-success), var(--theme-room-name));
  transition: width 0.3s ease;
}

.quest-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  color: var(--theme-text-primary);
  text-shadow: 0 0 2px var(--theme-bg-primary);
  white-space: nowrap;
}

/* Large progress bar for detail view */
.quest-progress.large .quest-progress-bar {
  height: 18px;
}

.quest-progress.large .quest-progress-text {
  font-size: 11px;
}

/* Quest Item Info */
.quest-item-info {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--theme-text-muted);
}

/* ============================================
   Right Panel - Quest Detail
   ============================================ */

.quest-detail {
  display: flex;
  flex-direction: column;
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  overflow-y: auto;
}

.quest-detail-content {
  padding: 16px;
}

/* Detail Header */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--theme-border-secondary);
}

.detail-title {
  color: var(--theme-accent-gold);
  font-size: 16px;
  font-weight: bold;
}

/* Quest Description */
.quest-description {
  color: var(--theme-text-secondary);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Timer Display */
.quest-timer-display {
  background: var(--theme-bg-primary);
  border: 1px solid var(--theme-warning);
  border-radius: 3px;
  padding: 8px;
  color: var(--theme-warning);
  font-size: 12px;
  text-align: center;
  margin-bottom: 16px;
}

/* Section Styling */
.quest-section {
  margin-bottom: 16px;
}

.section-title {
  color: var(--theme-text-primary);
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--theme-border-secondary);
}

/* Progress Section */
.quest-progress-section {
  margin-bottom: 16px;
}

/* Objectives */
.quest-objectives {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quest-objective {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--theme-bg-primary);
  border-radius: 2px;
  font-size: 12px;
}

.quest-objective.objective-complete {
  color: var(--theme-success);
}

.quest-objective.objective-incomplete {
  color: var(--theme-text-secondary);
}

.objective-check {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.objective-text {
  flex: 1;
}

.objective-progress {
  color: var(--theme-text-muted);
  font-size: 11px;
}

/* Objectives list (for quest offer) */
.quest-objectives-list {
  margin: 0;
  padding-left: 20px;
  color: var(--theme-text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

/* Rewards */
.quest-rewards {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reward-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--theme-bg-primary);
  border-radius: 2px;
  font-size: 12px;
  color: var(--theme-text-secondary);
}

.reward-icon {
  font-size: 14px;
}

/* Action Buttons */
.quest-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--theme-border-secondary);
}

.quest-btn {
  padding: 8px 16px;
  border: 1px solid var(--theme-border-secondary);
  border-radius: 3px;
  font-size: 12px;
  font-family: var(--theme-font-family);
  cursor: pointer;
  transition: all 0.15s ease;
}

.quest-btn-accept {
  background: var(--theme-success);
  border-color: var(--theme-success);
  color: var(--theme-bg-primary);
}

.quest-btn-accept:hover {
  background: var(--theme-accent-green);
}

.quest-btn-decline,
.quest-btn-abandon {
  background: var(--theme-bg-tertiary);
  color: var(--theme-text-secondary);
}

.quest-btn-decline:hover,
.quest-btn-abandon:hover {
  background: var(--theme-error);
  border-color: var(--theme-error);
  color: var(--theme-bg-primary);
}

/* Quest Offer Styling */
.quest-offer {
  padding: 16px;
}

.quest-offer-header {
  margin-bottom: 12px;
}

.quest-offer-title {
  color: var(--theme-accent-gold);
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 4px;
}

.quest-offer-npc {
  color: var(--theme-text-muted);
  font-size: 11px;
}

.quest-offer-name {
  color: var(--theme-text-primary);
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 8px;
}

.quest-offer-description {
  color: var(--theme-text-secondary);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.quest-offer-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* Placeholder styling */
.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  color: var(--theme-text-muted);
}

.placeholder-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.placeholder-text {
  font-size: 13px;
}

/* No data message */
.no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--theme-text-muted);
  font-size: 12px;
  text-align: center;
  padding: 16px;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 900px) {
  #quest-window {
    width: 95vw;
    left: 2.5vw;
  }

  .quest-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .quest-sidebar {
    max-height: 200px;
  }
}
