/**
 * SpellViewer Styles
 * Single-page navigation interface optimized for mobile and desktop
 */

/* Reset and base */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: #f5f5f5;
  color: #2c3e50;
  overflow-x: hidden;
}

/* Navigation Bar - Sticky at top */
.nav-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  border-bottom: 2px solid #4a9eff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nav-button {
  background: #4a9eff;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-button:hover {
  background: #3a8ee0;
  transform: translateY(-1px);
}

.nav-button:active {
  transform: translateY(0);
}

.nav-button:disabled {
  background: #666;
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

#pageTitle {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main Content Area */
.main-content {
  padding: 20px 16px;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}

/* Loading Indicator */
.loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 20px 40px;
  border-radius: 8px;
  font-size: 16px;
  z-index: 2000;
}

/* Home Screen */
.home-screen {
  max-width: 800px;
  margin: 0 auto;
}

.home-screen h2 {
  color: #4a9eff;
  margin-bottom: 20px;
  font-size: 24px;
}

.tab-container {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 2px solid #ddd;
}

.tab-button {
  background: transparent;
  color: #666;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab-button.active {
  color: #4a9eff;
  border-bottom-color: #4a9eff;
}

.tab-button:hover:not(.active) {
  color: #2c3e50;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Search Bar */
.search-container {
  margin-bottom: 24px;
}

.search-bar {
  display: flex;
  gap: 8px;
  background: #ffffff;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #ddd;
}

.search-bar input {
  flex: 1;
  background: #f5f5f5;
  border: 1px solid #ccc;
  color: #2c3e50;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 16px;
}

.search-bar input:focus {
  outline: none;
  border-color: #4a9eff;
}

.search-bar button {
  background: #4a9eff;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.search-bar button:hover {
  background: #3a8ee0;
}

/* Sequence/Temple Lists */
.sequence-list-container,
.temple-list-container,
.spell-list-container,
.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sequence-item,
.spell-item,
.result-item {
  background: #ffffff;
  padding: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #ddd;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sequence-item:hover,
.spell-item:hover,
.result-item:hover {
  background: #f0f8ff;
  border-color: #4a9eff;
  transform: translateX(4px);
}

.sequence-item:active,
.spell-item:active,
.result-item:active {
  transform: translateX(2px);
}

.tree-button {
  background: #27ae60;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.tree-button:hover {
  background: #229954;
}

.sequence-name {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
}

.spell-name {
  flex: 1;
  font-size: 16px;
  font-weight: 500;
  color: #2c3e50;
}

.spell-meta,
.result-meta {
  font-size: 14px;
  color: #666;
  white-space: nowrap;
}

.result-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-name {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
}

/* Spell Detail View */
.spell-detail-container {
  max-width: 900px;
  margin: 0 auto;
}

/* Spell Content Rendering (from shared component) */
.spell-content {
  padding: 16px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.spell-field {
  margin-bottom: 4px;
  line-height: 1.5;
}

.field-label {
  font-weight: 600;
  color: #2980b9;
  font-size: 14px;
  display: inline;
}

.field-label::after {
  content: ': ';
}

.field-value {
  color: #000000;
  font-size: 14px;
  display: inline;
}

/* Description Section */
.description-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
}

.description-section .field-label {
  font-size: 16px;
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
  color: #2c3e50;
}

.description-content {
  color: #2c3e50;
  line-height: 1.7;
  font-size: 15px;
}

.description-content p {
  margin-bottom: 12px;
}

.description-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.description-content th,
.description-content td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
}

/* Large spacing for specific tables (e.g., aiming table) */
.description-content .large-table table,
.spell-description .large-table table {
  width: auto;
  min-width: 50%;
}

.description-content .large-table th,
.description-content .large-table td,
.spell-description .large-table th,
.spell-description .large-table td {
  padding: 4px 16px;
  font-size: 12px;
  border: 1px solid #ddd;
}

.description-content th {
  background: #f5f5f5;
  font-weight: 600;
  color: #2c3e50;
}

/* Comments Section */
.comments-section {
  margin-top: 16px;
}

.comments-toggle {
  background: #95a5a6;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.comments-toggle:hover {
  background: #7f8c8d;
}

.comments-content {
  display: none;
  color: #555;
  line-height: 1.6;
  font-size: 14px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.comments-content.visible {
  display: block;
}

/* Skill Progression Section */
.skill-progression-section {
  margin-top: 16px;
}

.skill-progression-toggle {
  background: #27ae60;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.skill-progression-toggle:hover {
  background: #229954;
}

.skill-progression-content {
  display: none;
  color: #0e4d2f;
  line-height: 1.6;
  font-size: 14px;
  padding: 12px;
  background: #e8f8f5;
  border-radius: 4px;
  border: 1px solid #a9dfbf;
}

.skill-progression-content.visible {
  display: block;
}

/* Tables in skill progression */
.skill-progression-content table {
  border-collapse: collapse;
  margin: 10px 0;
  width: 100%;
  max-width: 400px;
}

.skill-progression-content th,
.skill-progression-content td {
  border: 1px solid #a9dfbf;
  padding: 6px 12px;
  text-align: left;
  font-size: 13px;
}

.skill-progression-content th {
  background-color: #d4efdf;
  font-weight: 600;
  color: #0e4d2f;
}

.spell-detail-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #ddd;
}

.spell-detail-header h2 {
  color: #4a9eff;
  margin: 0 0 12px 0;
  font-size: 28px;
}

.spell-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-button {
  background: #4a9eff;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.action-button:hover {
  background: #3a8ee0;
}

.action-button.secondary {
  background: #27ae60;
}

.action-button.secondary:hover {
  background: #229954;
}

/* Sequence View with Filter */
.sequence-view-container {
  max-width: 900px;
  margin: 0 auto;
}

.sequence-header {
  margin-bottom: 24px;
}

.sequence-header h2 {
  color: #4a9eff;
  margin: 0 0 16px 0;
  font-size: 28px;
}

.sequence-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.sequence-controls input {
  flex: 1;
  background: #f5f5f5;
  border: 1px solid #ccc;
  color: #2c3e50;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 16px;
}

.sequence-controls input:focus {
  outline: none;
  border-color: #4a9eff;
}

.sequence-controls button {
  background: #4a9eff;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.sequence-controls button:hover {
  background: #3a8ee0;
}

/* Tree View */
.tree-container {
  background: #ffffff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin-top: 16px;
}

#tree-network {
  min-height: 400px;
  width: 100%;
}

/* No Results / Error Messages */
.no-results,
.error-message,
.loading {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 16px;
}

.error-message {
  color: #e74c3c;
}

/* Responsive Design */
@media (max-width: 768px) {
  .nav-bar {
    padding: 10px 12px;
  }

  .nav-button {
    padding: 6px 12px;
    font-size: 13px;
  }

  #pageTitle {
    font-size: 16px;
  }

  .main-content {
    padding: 16px 12px;
  }

  .home-screen h2 {
    font-size: 20px;
  }

  .tab-button {
    padding: 10px 16px;
    font-size: 14px;
  }

  .sequence-item,
  .spell-item,
  .result-item {
    padding: 12px;
  }

  .spell-meta,
  .result-meta {
    font-size: 12px;
  }

  .spell-detail-header h2 {
    font-size: 24px;
  }

  .sequence-header h2 {
    font-size: 24px;
  }
}

/* Temple-specific styles (for Holy/non-key spells) */
.holy-spell {
  font-weight: 700;
}

.non-key-spell {
  font-style: italic;
}

/* Level Headers (for temple by-level view) */
.level-header {
  background: #4a9eff;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  margin: 16px 0 8px 0;
}
