/* Modal Styles - Universal Modal System */

/* Universal Modal System */
.universal-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.universal-modal-container {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #bdc3c7;
  max-width: 95vw;
  width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #bdc3c7;
  background: #ecf0f1;
}

.modal-header-controls {
  display: flex;
  gap: 8px;
  margin-left: auto;
  /* Push to the right */
}

.modal-title-section {
  display: flex;
  align-items: center;
  gap: 12px;
  /* Gap between title and metadata */
}

.modal-metadata {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #7f8c8d;
  flex-wrap: nowrap;
}

.modal-title {
  margin: 0;
  font-size: 1.5rem;
  color: #2c3e50;
}

.modal-title.clickable {
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-title.clickable:hover {
  opacity: 0.8;
  transform: translateY(-1px);
}

.modal-back-button {
  background: #2c3e50;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
}

.modal-back-button:hover:not(:disabled) {
  background: #34495e;
  transform: translateY(-1px);
}

.modal-back-button:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
  opacity: 0.6;
}

.modal-close-button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #2c3e50;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal-close-button:hover {
  color: #e74c3c;
  transform: scale(1.1);
}

.modal-content {
  padding: 20px;
}

/* Modal Metadata - Single row display for metadata elements */
.modal-metadata {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 0.9rem;
  color: #7f8c8d;
}

.modal-number {
  font-weight: 600;
}

.modal-binary {
  font-family: 'Courier New', Courier, monospace;
  background: #f8f9fa;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.modal-symbol {
  font-size: 1.2rem;
}

/* Breadcrumb Navigation */
.modal-breadcrumb {
  display: none;
  align-items: center;
  padding: 10px 20px;
  background: #ffffff;
  border-bottom: 1px solid #bdc3c7;
  flex-wrap: wrap;
}

.breadcrumb-label {
  font-weight: 600;
  color: #2c3e50;
  margin-right: 8px;
}

.breadcrumb-item {
  background: none;
  border: none;
  color: #3498db;
  cursor: pointer;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.breadcrumb-item:hover {
  background: #5dade2;
  color: #2980b9;
}

.breadcrumb-current {
  color: #2c3e50;
  font-weight: 600;
}

.breadcrumb-separator {
  margin: 0 8px;
  color: #bdc3c7;
}

/* Hexagram Detail Modal */
.hexagram-detail-modal {
  background: #ffffff;
  border-radius: 8px;
  padding: 30px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.hexagram-detail-header {
  text-align: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #bdc3c7;
  padding-bottom: 15px;
}

.hexagram-detail-header h2 {
  margin: 0 0 10px 0;
  color: #2c3e50;
}

.hexagram-detail-number,
.hexagram-detail-binary {
  display: inline-block;
  margin: 0 10px;
  font-weight: bold;
}

/* Trigram Detail Modal */
.trigram-detail-modal {
  background: #ffffff;
  border-radius: 8px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  position: relative;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.trigram-detail-header {
  margin-bottom: 20px;
  border-bottom: 1px solid #bdc3c7;
  padding-bottom: 15px;
}

.trigram-detail-header h2 {
  margin: 0 0 10px 0;
  color: #2c3e50;
}

.trigram-detail-number,
.trigram-detail-symbol,
.trigram-detail-binary {
  display: inline-block;
  margin: 5px 10px;
  font-weight: bold;
}

.trigram-symbol-large {
  font-size: 4em;
  margin: 20px 0;
}

.trigram-binary-large {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.2em;
  opacity: 0.7;
}

/* Close Button */
.close-modal {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 2em;
  cursor: pointer;
  color: #2c3e50;
  width: 40px;
  height: 40px;
  display: flex;

  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

/* Name Expansion Section */
.name-expansion-section {
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 3px solid #3498db;
  transition: all 0.3s ease;
}

.name-expansion-section.hidden {
  display: none;
}

.name-expansion-section.visible {
  display: block;
}

.close-modal:hover {
  background: #bdc3c7;
}

/* Edit Mode Styles */
.edit-button-container {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #bdc3c7;
}

.edit-translation-button {
  background: #3498db;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
}

.edit-translation-button:hover {
  background: #2980b9;
  transform: translateY(-1px);
}

.hexagram-edit-content,
.trigram-edit-content {
  padding: 20px;
}

.hexagram-edit-form,
.trigram-edit-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.edit-section {
  background: #f8f9fa;
  border: 1px solid #bdc3c7;
  border-radius: 6px;
  padding: 15px;
}

.edit-section h3 {
  margin: 0 0 15px 0;
  color: #2c3e50;
  font-size: 1.2rem;
}

.field-group {
  margin-bottom: 15px;
}

.field-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #2c3e50;
}

.field-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.3s ease;
}

.field-group textarea:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.line-edit-group {
  background: white;
  border: 1px solid #d5dbdb;
  border-radius: 4px;
  padding: 15px;
  margin-bottom: 15px;
}

.line-edit-group h4 {
  margin: 0 0 10px 0;
  color: #2c3e50;
}

.edit-form-controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  padding-top: 20px;
  border-top: 1px solid #bdc3c7;
}

.save-button,
.cancel-button {
  padding: 10px 25px;
  border: none;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.save-button {
  background: #27ae60;
  color: white;
}

.save-button:hover:not(:disabled) {
  background: #229954;
  transform: translateY(-1px);
}

.save-button:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
  opacity: 0.6;
}

.cancel-button {
  background: #e74c3c;
  color: white;
}

.cancel-button:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

/* Invisible Expansion Styles */
.translation-text {
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.translation-text:hover {
  opacity: 0.8;
}

.translation-text:active {
  opacity: 0.6;
}

.translation-details {
  margin-top: 10px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 3px solid #3498db;
  transition: all 0.3s ease;
}

.translation-details.hidden {
  display: none;
}

.translation-details.visible {
  display: block;
}

.translation-details-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.detail-section {
  padding: 10px 0;
}

.detail-section:not(:last-child) {
  border-bottom: 1px solid #e9ecef;
}

.detail-section h4 {
  margin: 0 0 8px 0;
  color: #2c3e50;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.raw-text,
.interpretation-text {
  margin: 0;
  color: #555;
  font-size: 0.9rem;
  line-height: 1.5;
}

.raw-section .raw-text {
  font-family: 'Courier New', Courier, monospace;
  background: #fff;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.interpretation-section .interpretation-text {
  font-style: italic;

}

/* Reading Detail Modal */
.reading-detail-modal {
  background: #ffffff;
  border-radius: 8px;
  padding: 20px;
  max-width: 1500px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.reading-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #bdc3c7;
}

.reading-question {
  font-size: 1.3rem;
  font-weight: 500;
  color: #2c3e50;
  margin-bottom: 10px;
}

.reading-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  font-size: 0.9rem;
  color: #7f8c8d;
}

.reading-method {
  background: #ecf0f1;
  padding: 2px 8px;
  border-radius: 4px;
}

.reading-hexagrams {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  align-items: center;
}

.present-section,
.future-section {
  flex: 1;
  min-width: 300px;
}

.transformation-indicator {
  text-align: center;
  padding: 0 20px;
}

.transformation-indicator .arrow {
  font-size: 2rem;
  font-weight: bold;
  color: #3498db;
  margin: 10px 0;
}

.moving-lines-count {
  font-size: 0.9rem;
  color: #f39c12;
  font-weight: 500;
}

/* Translation Sections */
.translation-section {
  margin: 20px 0;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 3px solid #3498db;
  cursor: pointer;
  transition: all 0.3s ease;
}

.translation-section:hover {
  background: #ecf0f1;
}

.translation-section.expanded {
  background: #ffffff;
  border-left: 3px solid #f39c12;
}

.section-title {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.text-content {
  line-height: 1.6;
  color: #555;
}

.raw-text .text-content {
  font-family: 'Courier New', Courier, monospace;
  background: #fff;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #e9ecef;
  white-space: pre-wrap;
}

.interpretation-text .text-content {
  font-style: italic;
}

/* Lines Section */
.lines-section {
  margin: 25px 0;
}

.lines-section .section-title {
  color: #2c3e50;
  border-bottom: 1px solid #bdc3c7;
  padding-bottom: 5px;
  margin-bottom: 15px;
}

.line-translation {
  margin-bottom: 15px;
  padding: 10px;
  background: #ffffff;
  border-radius: 4px;
  border: 1px solid #e9ecef;
  cursor: pointer;
  transition: all 0.3s ease;
}

.line-translation:hover {
  border-color: #3498db;
  background: #f8f9fa;
}

.line-translation.expanded {
  background: #ecf0f1;
  border-color: #f39c12;
}

.line-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.line-number {
  font-weight: 600;
  color: #2c3e50;
}

.line-raw,
.line-interpretation {
  margin: 8px 0;
}

.line-raw .text-content {
  font-family: 'Courier New', Courier, monospace;
  background: #fff;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #e9ecef;
  white-space: pre-wrap;
}

.line-interpretation .text-content {
  font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
  .reading-hexagrams {
    flex-direction: column;
    gap: 10px;
  }

  .transformation-indicator .arrow {
    transform: rotate(90deg);
  }

  .present-section,
  .future-section {
    min-width: auto;
  }

  .reading-detail-modal {
    padding: 15px;
    width: 98%;
  }

  .reading-question {
    font-size: 1.1rem;
  }
}

/* Reading Detail Modal - Wider for dual hexagram display */
.universal-modal-overlay[data-modal-type="reading"] .universal-modal-container {
  width: 1500px;
  /* Override the fixed width */
  max-width: 95vw;
  /* Keep responsive behavior */
}

/* Keep other modals at normal width */
.universal-modal-overlay[data-modal-type="hexagram"] .universal-modal-container,
.universal-modal-overlay[data-modal-type="trigram"] .universal-modal-container {
  max-width: 800px;
  /* Original width */
}