/* ============================================
   LEXICON STYLES
   ============================================ */

/* Container */
.e-con > .e-con-inner {
  max-width: unset;
}

.lexicon-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  font-family: Heebo, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Header */
.lexicon-header {
  margin-bottom: 30px;
}

.lexicon-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0;
  color: #1a1a1a;
}

/* Search Bar */
.lexicon-search-container {
  margin-bottom: 30px;
  display: flex;
  gap: 1rem;
}

.lexicon-search-wrapper {
  position: relative;
  flex-grow: 6;
}

.lexicon-search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
  font-size: 1.1rem;
  pointer-events: none;
}

button.lexicon-search-clear {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #999;
  font-size: 1rem;
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

button.lexicon-search-clear:hover {
  color: #8b4545;
  background: #f0f0f0;
}

.lexicon-search-input {
  width: 100%;
  padding: 15px 20px 15px 55px;
  font-size: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.lexicon-search-input:focus {
  outline: none;
  border-color: #8b4545;
  background: #fff;
  box-shadow: 0 2px 8px rgba(139, 69, 69, 0.1);
}

/* Alphabet Navigation */
.lexicon-alphabet-nav {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
  background: linear-gradient(0.25turn, #0000, #0001, #0000);
  flex: 1;
  justify-content: space-between;
}

a.letter-link {
  min-width: 26px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #333;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  padding: 0 8px;
}

a.letter-link.active:hover {
  background: #f0f0f0;
  color: #8b4545;
}

a.letter-link.active.selected {
  background: #8b4545;
  color: white;
}

a.letter-link.disabled {
  cursor: unset;
}

/* Category Filter */
.lexicon-category-filter {
  position: relative;
  flex-grow: 1;
}

/* Hide mobile version by default */
.lexicon-category-filter-mobile {
  display: none;
}

button.category-dropdown-btn {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: white;
  color: unset;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

button.category-dropdown-btn:hover {
  border-color: #8b4545;
  background: #f8f8f8;
}

.category-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  inset-inline-start: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 200px;
  width: 100%;
  z-index: 10;
  padding: 8px 0;
  max-height: 70vh;
  overflow-y: auto;
}

.category-dropdown-menu.open {
  display: block;
}

.category-option {
  display: block;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.2s ease;
  color: #333;
  text-decoration: none;
}

.category-option:hover {
  background: #f8f8f8;
}

.category-option.active {
  background: #e8d5d5;
  color: #8b4545;
  font-weight: 600;
}

/* Main Content */
.lexicon-content {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 30px;
  min-height: 600px;
}

/* List Panel */
.lexicon-list-panel {
  border-radius: 8px;
  overflow: hidden;
}

.lexicon-list-scroll {
  height: 70vh;
  overflow-y: auto;
  padding: 20px;
}

.lexicon-letter-section {
  margin-bottom: 30px;
}

.lexicon-section-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.lexicon-letter-heading {
  font-size: 1.8rem;
  font-weight: 300;
  color: #8b4545;
  margin: 0;
  flex-shrink: 0;
  min-width: 1.5rem;
}

.lexicon-items-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  border-inline-start: 1px solid black;
  padding-inline-start: 2rem;
}

.lexicon-list-item {
  margin-bottom: 8px;
}

.lexicon-list-item.hidden,
.lexicon-definition-item.hidden {
  display: none;
}

.lexicon-letter-section.hidden {
  display: none;
}

.lexicon-definitions-section.hidden {
  display: none;
}

a.lexicon-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 8px;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  color: unset;
  font-family: Heebo, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

a.lexicon-item-link.active {
  background: #8b4545;
  border-color: #8b4545;
  color: white;
}

.lexicon-item-title {
  font-size: 1rem;
  font-weight: 400;
  flex: 1;
}

.lexicon-item-category {
  display: none; /* Hidden in button, shown separately */
}

.lexicon-item-meta {
  margin-top: 4px;
  padding-left: 16px;
}

/* Definitions Panel */
.lexicon-definitions-panel {
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.lexicon-definitions-scroll {
  height: 70vh;
  overflow-y: auto;
  padding: 30px;
}

.lexicon-definitions-section {
  margin-bottom: 40px;
}

.lexicon-definition-item {
  margin-bottom: 40px;
  padding-bottom: 40px;
}

.lexicon-definition-item:last-child {
  border-bottom: none;
}

.definition-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 15px;
}

.definition-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
  flex: 1;
}

.definition-categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

a.definition-category-badge {
  display: inline-block;
  color: #cb9999;
  font-weight: 700;
  text-decoration: underline;
}

.definition-content {
  font-size: 1rem;
  line-height: 1.7;
  color: #333;
  margin-bottom: 20px;
}

.definition-content p {
  margin: 0 0 15px 0;
}

.definition-meta {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #666;
}

button.sources-btn {
  position: relative;
  background: none;
  border: none;
  color: #8b4545;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
  letter-spacing: unset;
}

.sources-btn:hover {
  color: #6d3535;
}

.sources-popup {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-bottom: 8px;
  background: linear-gradient(0deg, rgba(152, 52, 52, 0.075) 12.35%, rgba(255, 255, 255, 0.3) 73.54%), #fff;
  border-bottom: 3px solid #983434;
  padding: 15px;
  min-width: 250px;
  max-width: 400px;
  z-index: 10;
}

.sources-popup.show {
  display: block;
}

.sources-popup-content {
  font-size: 0.85rem;
  font-weight: 400;
  color: #333;
  line-height: 1.5;
  text-align: start;
}

.sources-popup-content p {
  margin: 0 0 8px 0;
}

.sources-popup-content p:last-child {
  margin-bottom: 0;
}

/* Scrollbar Styles */
.lexicon-list-scroll::-webkit-scrollbar,
.lexicon-definitions-scroll::-webkit-scrollbar {
  width: 8px;
}

.lexicon-list-scroll::-webkit-scrollbar-track,
.lexicon-definitions-scroll::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.lexicon-list-scroll::-webkit-scrollbar-thumb,
.lexicon-definitions-scroll::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.lexicon-list-scroll::-webkit-scrollbar-thumb:hover,
.lexicon-definitions-scroll::-webkit-scrollbar-thumb:hover {
  background: #8b4545;
}

/* RTL Support */
.lexicon-container[dir="rtl"] .lexicon-search-icon {
  left: auto;
  right: 20px;
}

.lexicon-container[dir="rtl"] .lexicon-search-clear {
  right: auto;
  left: 15px;
}

.lexicon-container[dir="rtl"] .lexicon-search-input {
  padding: 15px 55px 15px 20px;
}

.lexicon-container[dir="rtl"] .category-dropdown-menu {
  right: auto;
  left: 0;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

@media (max-width: 768px) {
  .lexicon-container {
    padding: 2rem;
  }

  .lexicon-title {
    font-size: 1.8rem;
  }

  /* Hide desktop category filter on mobile */
  .lexicon-category-filter-desktop {
    display: none;
  }

  button.category-dropdown-btn {
    width: 100%;
  }

  /* Mobile category filter: above alphabet nav, visible only in definitions mode */
  .lexicon-category-filter-mobile {
    display: none;
    margin-bottom: 15px;
  }

  .lexicon-container.mobile-definitions-mode .lexicon-category-filter-mobile {
    display: flex;
  }

  /* Alphabet nav scrollable on mobile */
  .lexicon-alphabet-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .lexicon-alphabet-nav::-webkit-scrollbar {
    display: none;
  }

  .lexicon-alphabet-nav {
    padding-block: 1rem;
    flex-wrap: nowrap;
    gap: 8px;
  }

  a.letter-link {
    min-width: 32px;
    height: 32px;
    font-weight: 400;
    font-size: 1.2rem;
    padding: 0 16px;
  }

  /* Single column layout */
  .lexicon-content {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Default: List mode - show only list panel */
  .lexicon-list-panel {
    display: block;
  }

  .lexicon-definitions-panel {
    display: none;
  }

  /* Definitions mode - show only definitions panel */
  .lexicon-container.mobile-definitions-mode .lexicon-list-panel {
    display: none;
  }

  .lexicon-container.mobile-definitions-mode .lexicon-definitions-panel {
    display: block;
  }

  .lexicon-list-scroll,
  .lexicon-definitions-scroll {
    height: auto;
    min-height: 60vh;
    padding: 0;
  }

  .lexicon-section-content {
    gap: 1rem;
    flex-direction: column;
  }

  .lexicon-items-list {
    border-inline-start: unset;
    padding-inline-start: unset;
  }

  .lexicon-item-title {
    font-size: 1rem;
    font-size: 1.2rem;
  }

  .definition-title {
    font-size: 1.3rem;
  }

  .lexicon-letter-heading {
    font-size: 1.5rem;
    font-size: 2.4rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid black;
    width: 100%;
  }
  
  /* Sources popup adjustments for mobile */
  .sources-popup {
    position: absolute;
    margin: 0;
    max-width: 90%;
    width: 320px;
  }
}

@media (max-width: 480px) {
  .lexicon-title {
    font-size: 2.2rem;
    font-weight: 600;
  }

  .lexicon-search-input {
    padding: 12px 15px 12px 45px;
    font-size: 0.95rem;
  }

  .lexicon-search-icon {
    left: 15px;
    font-size: 1rem;
  }

  .letter-link {
    min-width: 28px;
    height: 28px;
    font-size: 0.85rem;
    gap: 4px;
  }

  .definition-title {
    font-size: 1.2rem;
  }

  .definition-content {
    font-size: 0.95rem;
  }
}
