/* ============================================
   SHALOM SIDEBAR ENHANCEMENTS
   ============================================
   
   Styles for the Shalom page sidebar modifications:
   - Manage Bibles button styling
   - Saved Bibles dropdown
   - Bible Study modal
*/

/* ==========================================
   SAVED BIBLES CONTAINER
   ========================================== */

.saved-bibles-container {
  margin: 0;
  padding: 0;
}

/* Saved Bibles Header/Toggle */
.saved-bibles-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.saved-bibles-header .dropdown-arrow {
  margin-left: auto;
  transition: transform 0.3s ease;
  opacity: 0.7;
}

.saved-bibles-header.expanded .dropdown-arrow {
  transform: rotate(180deg);
}

/* Collapsed state - hide the dropdown arrow when sidebar is collapsed */
.sidebar.collapsed .saved-bibles-header .dropdown-arrow {
  display: none;
}

/* ==========================================
   SAVED BIBLES DROPDOWN LIST
   ========================================== */

.saved-bibles-list {
  max-height: 400px;
  overflow-y: auto;
  overflow-x: visible;
  margin: 0;
  padding: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  margin: 0 0.5rem 0.5rem 0.5rem;
  /* Allow context menus to overflow */
  position: relative;
}

.saved-bibles-list.collapsed {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* Light theme */
[data-theme="light"] .saved-bibles-list {
  background: rgba(0, 0, 0, 0.03);
}

/* Scrollbar styling */
.saved-bibles-list::-webkit-scrollbar {
  width: 6px;
}

.saved-bibles-list::-webkit-scrollbar-track {
  background: transparent;
}

.saved-bibles-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.saved-bibles-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

[data-theme="light"] .saved-bibles-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .saved-bibles-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ==========================================
   SAVED BIBLE ITEMS (ChatGPT-style)
   ========================================== */

.saved-bible-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.85rem;
  margin: 0.25rem 0.5rem;
  background: linear-gradient(135deg, rgba(157, 143, 201, 0.08), rgba(157, 143, 201, 0.05));
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: #cbd5e0;
  border: 1px solid rgba(157, 143, 201, 0.15);
  overflow: visible;
  position: relative;
  z-index: 1;
}

/* Increase z-index when menu is open to allow overflow */
.saved-bible-item.menu-open {
  z-index: 10000;
}

.saved-bible-item:hover {
  background: linear-gradient(135deg, rgba(157, 143, 201, 0.15), rgba(157, 143, 201, 0.1));
  border-color: rgba(157, 143, 201, 0.35);
  transform: translateX(3px);
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(157, 143, 201, 0.12);
}

/* Light theme */
[data-theme="light"] .saved-bible-item {
  background: linear-gradient(135deg, rgba(250, 249, 246, 0.95), rgba(248, 246, 255, 0.9));
  color: #2d3748;
  border-color: rgba(157, 143, 201, 0.15);
}

[data-theme="light"] .saved-bible-item:hover {
  background: linear-gradient(135deg, rgba(250, 249, 246, 1), rgba(248, 246, 255, 0.98));
  border-color: rgba(157, 143, 201, 0.3);
  box-shadow: 0 2px 6px rgba(157, 143, 201, 0.15);
}

/* Compact Bible Item Layout */
.bible-item-content-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.bible-item-left-sidebar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.bible-icon-sidebar {
  color: #9d8fc9;
  flex-shrink: 0;
}

[data-theme="light"] .bible-icon-sidebar {
  color: #7c6ba8;
}

.bible-item-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
}

.bible-item-name-input {
  font-size: 0.85rem;
  font-weight: 500;
  background: rgba(157, 143, 201, 0.1);
  border: 1px solid rgba(157, 143, 201, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  color: #cbd5e0;
  outline: none;
  width: 100%;
  min-width: 0;
}

.bible-item-name-input:focus {
  background: rgba(157, 143, 201, 0.15);
  border-color: rgba(157, 143, 201, 0.5);
}

[data-theme="light"] .bible-item-name-input {
  background: rgba(157, 143, 201, 0.08);
  color: #2d3748;
}

[data-theme="light"] .bible-item-name-input:focus {
  background: rgba(157, 143, 201, 0.12);
}

.bible-item-right-sidebar {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.bible-study-count {
    padding: 3px 8px;
    background: rgba(157, 143, 201, 0.15);
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.7rem;
    color: #b8a8e0;
    white-space: nowrap;
    border: 1px solid rgba(157, 143, 201, 0.2);
}

[data-theme="light"] .bible-study-count {
    background: rgba(157, 143, 201, 0.12);
    color: #7c6ba8;
    border-color: rgba(157, 143, 201, 0.18);
}

/* Sidebar three-dot menu */
.bible-menu-wrapper-sidebar {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 1;
}

.bible-menu-btn-sidebar {
    display: none;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 4px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.saved-bible-item:hover .bible-menu-btn-sidebar {
    display: flex;
}

.bible-menu-btn-sidebar:hover {
    background: rgba(157, 143, 201, 0.2);
    color: #cbd5e0;
}

[data-theme="light"] .bible-menu-btn-sidebar {
    color: #64748b;
}

[data-theme="light"] .bible-menu-btn-sidebar:hover {
    background: rgba(157, 143, 201, 0.15);
    color: #2d3748;
}

/* Sidebar context menu */
.bible-context-menu-sidebar {
    position: fixed; /* Changed from absolute to fixed for viewport positioning */
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 130px;
    z-index: 10002;
    overflow: visible;
    /* Ensure menu escapes clipping */
    transform: translateZ(0);
}

/* Removed - no longer needed with fixed positioning */

[data-theme="light"] .bible-context-menu-sidebar {
    background: white;
    border-color: #e5e7eb;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.bible-context-menu-item-sidebar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #cbd5e0;
    font-size: 0.8rem;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    transition: all 0.1s;
}

.bible-context-menu-item-sidebar:hover {
    background: rgba(157, 143, 201, 0.15);
}

.bible-context-menu-item-sidebar.delete {
    color: #fca5a5;
}

.bible-context-menu-item-sidebar.delete:hover {
    background: rgba(220, 38, 38, 0.2);
}

[data-theme="light"] .bible-context-menu-item-sidebar {
    color: #374151;
}

[data-theme="light"] .bible-context-menu-item-sidebar:hover {
    background: #f3f4f6;
}

[data-theme="light"] .bible-context-menu-item-sidebar.delete {
    color: #dc2626;
}

[data-theme="light"] .bible-context-menu-item-sidebar.delete:hover {
    background: #fee2e2;
}

.bible-context-menu-item-sidebar svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Bible Item Content */
.bible-item-content {
  flex: 1;
  min-width: 0; /* Allow text truncation */
}

.bible-item-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
}

.bible-item-translation {
  font-size: 0.75rem;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty Bibles Message */
.empty-bibles-message {
  padding: 1.5rem 1rem;
  text-align: center;
  color: #94a3b8;
}

.empty-bibles-message p {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
}

.empty-bibles-message small {
  font-size: 0.75rem;
  opacity: 0.8;
}

[data-theme="light"] .empty-bibles-message {
  color: #64748b;
}

/* ==========================================
   BIBLE STUDY MODAL
   ========================================== */

.bible-study-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.bible-study-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.bible-study-modal {
  background: linear-gradient(135deg, #6b5b7a 0%, #8a7a9a 100%);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

[data-theme="dark"] .bible-study-modal {
  background: #000000;
  border: 1px solid #2f2f2f;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
}

.bible-study-modal-overlay.active .bible-study-modal {
  transform: scale(1);
}

/* Light theme */
[data-theme="light"] .bible-study-modal {
  background: linear-gradient(135deg, #f8f6fc 0%, #ebe7f2 100%);
  border: 2px solid #d4c8e8;
  box-shadow: 0 20px 60px rgba(157, 143, 201, 0.3);
}

/* Modal Header */
.bible-study-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 2px solid rgba(157, 143, 201, 0.3);
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .bible-study-modal-header {
  border-bottom: 1px solid #2f2f2f;
  background: transparent;
}

[data-theme="light"] .bible-study-modal-header {
  border-bottom-color: #d4c8e8;
  background: rgba(157, 143, 201, 0.08);
}

.bible-study-modal-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #f1f5f9;
}

[data-theme="light"] .bible-study-modal-title {
  color: #1f2937;
}

.bible-study-modal-title svg {
  color: #b094c2;
}

[data-theme="light"] .bible-study-modal-title svg {
  color: #9d8fc9;
}

.bible-study-modal-close {
  background: transparent;
  border: none;
  color: #cbd5e0;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.bible-study-modal-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

[data-theme="light"] .bible-study-modal-close {
  color: #6b7280;
}

[data-theme="light"] .bible-study-modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

/* Modal Subtitle */
.bible-study-modal-subtitle {
  padding: 1rem 1.5rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid rgba(157, 143, 201, 0.2);
}

[data-theme="dark"] .bible-study-modal-subtitle {
  color: #8e8ea0;
  border-bottom: 1px solid #2f2f2f;
}

[data-theme="light"] .bible-study-modal-subtitle {
  color: #6b5b7a;
  border-bottom-color: #d4c8e8;
}

/* Modal Content */
.bible-study-modal-content {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.bible-study-modal-content::-webkit-scrollbar {
  width: 8px;
}

.bible-study-modal-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.bible-study-modal-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.bible-study-modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .bible-study-modal-content::-webkit-scrollbar-track {
  background: transparent;
}

[data-theme="dark"] .bible-study-modal-content::-webkit-scrollbar-thumb {
  background: #2f2f2f;
}

[data-theme="dark"] .bible-study-modal-content::-webkit-scrollbar-thumb:hover {
  background: #3f3f3f;
}

[data-theme="light"] .bible-study-modal-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .bible-study-modal-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .bible-study-modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Loading Spinner - Using BibliaTech loading animation */
/* See loading-animation.css for the new loading styles */

/* New Study Button */
.new-study-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #9d8fc9 0%, #8a7a9a 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  margin-bottom: 1rem;
}

.new-study-btn:hover {
  background: linear-gradient(135deg, #b094c2 0%, #9d8fc9 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .new-study-btn {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .new-study-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .new-study-btn {
  box-shadow: 0 4px 12px rgba(157, 143, 201, 0.3);
}

[data-theme="light"] .new-study-btn:hover {
  box-shadow: 0 6px 16px rgba(157, 143, 201, 0.4);
}

.new-study-btn:active {
  transform: translateY(0);
}

/* Bible Studies List */
.bible-studies-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Bible Study Item */
.bible-study-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.bible-study-item:hover {
  background: rgba(157, 143, 201, 0.25);
  border-color: rgba(157, 143, 201, 0.4);
  transform: translateX(6px);
  text-decoration: none;
}

[data-theme="dark"] .bible-study-item {
  background: #212121;
  border: 1px solid #2f2f2f;
}

[data-theme="dark"] .bible-study-item:hover {
  background: #2a2a2a;
  border-color: #3f3f3f;
}

[data-theme="light"] .bible-study-item {
  background: rgba(0, 0, 0, 0.03);
  border-color: #e2e8f0;
}

[data-theme="light"] .bible-study-item:hover {
  background: rgba(157, 143, 201, 0.15);
  border-color: rgba(157, 143, 201, 0.4);
}

.study-item-content {
  flex: 1;
  min-width: 0;
}

.study-item-name {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 0.25rem;
}

[data-theme="dark"] .study-item-name {
  color: #ececf1;
}

[data-theme="light"] .study-item-name {
  color: #1f2937;
}

.study-item-description {
  font-size: 0.85rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme="dark"] .study-item-description {
  color: #8e8ea0;
}

[data-theme="light"] .study-item-description {
  color: #64748b;
}

.study-item-arrow {
  color: #9d8fc9;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.bible-study-item:hover .study-item-arrow {
  opacity: 1;
  transform: translateX(4px);
}

/* Empty Studies Message */
.empty-studies-message {
  text-align: center;
  padding: 2rem 1rem;
  color: #94a3b8;
}

.empty-studies-message p {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

.empty-studies-message small {
  font-size: 0.85rem;
  opacity: 0.8;
}

[data-theme="light"] .empty-studies-message {
  color: #64748b;
}

/* Error Message */
.error-message {
  text-align: center;
  padding: 2rem 1rem;
  color: #f87171;
}

.error-message p {
  margin: 0 0 1rem 0;
  font-size: 1rem;
}

.retry-btn {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #9d8fc9 0%, #8a7a9a 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-btn:hover {
  background: linear-gradient(135deg, #b094c2 0%, #9d8fc9 100%);
  transform: translateY(-2px);
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 768px) {
  .bible-study-modal {
    width: 95%;
    max-height: 90vh;
  }

  .bible-study-modal-header {
    padding: 1rem;
  }

  .bible-study-modal-title {
    font-size: 1.25rem;
  }

  .bible-study-modal-content {
    padding: 1rem;
  }

  .saved-bibles-list {
    max-height: 300px;
  }
}

/* Hide Saved Bibles container when sidebar is collapsed */
.sidebar.collapsed .saved-bibles-container {
  display: none;
}

/* ==========================================
   SHALOM PAGE SPECIFIC HIDING
   ========================================== */

/* Hide Notes Mode button on Shalom page (only show when reading Bible) */
.shalom-welcome ~ * .notes-mode-item,
body:has(.shalom-welcome) .notes-mode-item {
  display: none !important;
}

/* Fallback for browsers that don't support :has() - use JavaScript to add class */
.shalom-page-active .notes-mode-item {
  display: none !important;
}

/* Hide Saved Bibles on non-Shalom pages (only show on Shalom welcome page) */
body:has(.bible-book-content) .saved-bibles-container {
  display: none !important;
}

/* Fallback for browsers that don't support :has() */
.bible-reading-active .saved-bibles-container {
  display: none !important;
}

/* Hide Manage Bibles modification on non-Shalom pages */
body:has(.bible-book-content) #reader-mode-toggle.shalom-manage-bibles {
  display: none !important;
}

.bible-reading-active #reader-mode-toggle.shalom-manage-bibles {
  display: none !important;
}

