/**
 * SAHO Tools Citation & Sharing Styles - Refactored with SAHO Brand Colors
 * Using CSS custom properties for consistent theming
 * Improved UX with better button positioning and accessibility
 */

/* Container for both buttons - positioned on the right */
.saho-tools-wrapper {
  display: flex;
  gap: 0.5rem; /* Larger gap for bigger buttons */
  align-items: center;
  margin: 0;
  list-style: none;
  padding: 0;
  margin-left: auto; /* Push to the right */
  flex-shrink: 0; /* Prevent shrinking */
}

/* Ensure article meta container allows proper positioning */
.saho-article-meta {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
}

.saho-citation-wrapper,
.saho-sharing-wrapper {
  display: inline-flex;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Remove any potential list styling and bullets from article meta */
.saho-tools-wrapper::before,
.saho-citation-wrapper::before,
.saho-sharing-wrapper::before {
  content: none !important;
}

/* Override article meta bullets for button containers */
.saho-article-meta .saho-tools-wrapper span::before,
.saho-article-meta .saho-citation-wrapper span::before,
.saho-article-meta .saho-sharing-wrapper span::before,
.saho-article-meta .saho-tools-wrapper div::before,
.saho-article-meta .saho-citation-wrapper div::before,
.saho-article-meta .saho-sharing-wrapper div::before {
  content: none !important;
  display: none !important;
}

/* Ghost button styling for Cite button - Larger for better visibility */
.cite-button,
button.cite-button,
.saho-cite-btn,
button.saho-cite-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem !important; /* Larger padding */
  font-size: 0.875rem !important; /* More readable size */
  font-weight: 500;
  line-height: 1.3;
  border: 1.5px solid #990000 !important; /* Thicker border for visibility */
  border-radius: 6px !important; /* Slightly more rounded */
  background: transparent !important; /* Ghost button */
  color: #990000 !important; /* Red text */
  text-decoration: none !important;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

/* Remove bullets from button text spans */
.cite-button span::before,
.share-button span::before {
  content: none !important;
  display: none !important;
}

/* Share button with SAHO forest green - Larger for better visibility */
.share-button,
button.share-button,
.saho-share-btn,
button.saho-share-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem !important; /* Larger padding */
  font-size: 0.875rem !important; /* More readable size */
  font-weight: 500;
  line-height: 1.3;
  border: 1.5px solid #2d5016 !important; /* Thicker border for visibility */
  border-radius: 6px !important; /* Slightly more rounded */
  background: transparent !important; /* Ghost button - transparent background */
  color: #2d5016 !important; /* Forest green text */
  text-decoration: none !important;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

/* Cite button hover - fills with red - Override all styles */
.cite-button:hover,
.cite-button:focus,
button.cite-button:hover,
button.cite-button:focus,
.saho-cite-btn:hover,
.saho-cite-btn:focus,
button.saho-cite-btn:hover,
button.saho-cite-btn:focus {
  background: #990000 !important; /* Fill with SAHO red */
  color: #ffffff !important; /* White text */
  border-color: #990000 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(153, 0, 0, 0.25) !important;
  text-decoration: none !important;
}

/* Share button hover - fills with forest green - Override all styles */
.share-button:hover,
.share-button:focus,
button.share-button:hover,
button.share-button:focus,
.saho-share-btn:hover,
.saho-share-btn:focus,
button.saho-share-btn:hover,
button.saho-share-btn:focus {
  background: #2d5016 !important; /* Fill with forest green */
  color: #ffffff !important; /* White text */
  border-color: #2d5016 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(45, 80, 22, 0.25) !important;
  text-decoration: none !important;
}

.cite-button:hover::before,
.share-button:hover::before {
  left: 100%;
}

.cite-button svg,
.share-button svg {
  transition: transform 0.2s ease;
  flex-shrink: 0;
  width: 15px !important; /* Larger icon size for better visibility */
  height: 15px !important;
}

.cite-button:hover svg,
.share-button:hover svg {
  transform: scale(1.1);
}

/* Legacy button container support */
.citation-share-buttons {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
}

/* Bootstrap Modal Enhancements */
#citation-modal,
#sharing-modal {
  z-index: 1060;
}

#citation-modal .modal-dialog,
#sharing-modal .modal-dialog {
  max-width: 700px;
  margin: 1.75rem auto;
}

/* Modern Modal Content Styling */
#citation-modal .modal-content,
#sharing-modal .modal-content {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  background: #ffffff;
}

/* Modern Modal Headers - Clean and minimal */
#citation-modal .modal-header {
  background: #ffffff;
  padding: 2rem 2.5rem;
  border: none;
  border-bottom: 1px solid #e5e5e5;
  position: relative;
}

#sharing-modal .modal-header {
  background: #ffffff;
  padding: 2rem 2.5rem;
  border: none;
  border-bottom: 1px solid #e5e5e5;
  position: relative;
}

/* Add subtle accent line under header */
#citation-modal .modal-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 2.5rem;
  width: 60px;
  height: 3px;
  background: #990000;
  border-radius: 2px;
}

#sharing-modal .modal-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 2.5rem;
  width: 60px;
  height: 3px;
  background: #2d5016;
  border-radius: 2px;
}

#citation-modal .modal-title {
  color: #1a1a1a !important;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  font-family: "Open Sans", sans-serif;
  letter-spacing: -0.02em;
}

#sharing-modal .modal-title {
  color: #1a1a1a !important;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  font-family: "Open Sans", sans-serif;
  letter-spacing: -0.02em;
}

/* Visible Close Buttons - SAHO red styling */
#citation-modal .btn-close,
#sharing-modal .btn-close {
  position: absolute !important;
  top: 1.5rem !important;
  right: 1.5rem !important;
  width: 40px !important;
  height: 40px !important;
  background: #ffffff !important;
  border: 2px solid #990000 !important; /* SAHO red border */
  border-radius: 50% !important;
  color: #990000 !important; /* SAHO red X */
  font-size: 18px !important;
  font-weight: bold !important;
  line-height: 1 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  opacity: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  z-index: 10 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

#citation-modal .btn-close:hover,
#sharing-modal .btn-close:hover {
  background: #990000 !important; /* Fill with SAHO red on hover */
  color: #ffffff !important; /* White X on hover */
  transform: scale(1.1) !important;
  box-shadow: 0 4px 12px rgba(153, 0, 0, 0.25) !important;
}

/* Ensure close button has visible X symbol */
#citation-modal .btn-close::before,
#sharing-modal .btn-close::before {
  content: "×" !important; /* Explicit X symbol */
  font-size: 20px !important;
  line-height: 1 !important;
  font-weight: bold !important;
}

#citation-modal .btn-close:hover,
#citation-modal .btn-close:focus {
  background: var(--saho-primary) !important;
  border-color: var(--saho-primary) !important;
  color: var(--saho-surface) !important;
  transform: scale(1.1) rotate(90deg);
  opacity: 1;
  box-shadow: 0 4px 16px rgba(153, 0, 0, 0.25);
}

#sharing-modal .btn-close:hover,
#sharing-modal .btn-close:focus {
  background: #2d5016 !important; /* Forest green on hover */
  border-color: #2d5016 !important;
  color: var(--saho-surface) !important;
  transform: scale(1.1) rotate(90deg);
  opacity: 1;
  box-shadow: 0 4px 16px rgba(45, 80, 22, 0.25);
}

/* Clean Modal Bodies */
#citation-modal .modal-body,
#sharing-modal .modal-body {
  background: #fafafa;
  padding: 2rem 2.5rem;
  position: relative;
}

/* Citation Format Styling */
.citation-format,
.citation-text-container {
  margin-bottom: 2rem;
}

.citation-format:last-child,
.citation-text-container:last-child {
  margin-bottom: 0;
}

.citation-format-header h6,
.citation-format h4,
#citation-modal h4 {
  color: #990000 !important; /* SAHO red for readability */
  font-weight: 600;
  margin-bottom: 0.75rem;
  font-size: 1rem !important; /* Larger for better readability */
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
  padding-left: 0;
  background: transparent !important; /* Ensure no background conflicts */
}

/* Modern Citation Cards */
.citation-text,
.apa-citation,
.harvard-citation,
.oxford-citation {
  background: #ffffff !important;
  border: 1px solid #e5e5e5 !important;
  border-radius: 8px;
  padding: 1.5rem !important;
  margin-bottom: 1.5rem;
  transition: all 0.2s ease;
  position: relative;
}

.apa-citation {
  border-left: 3px solid #990000 !important;
}

.harvard-citation {
  border-left: 3px solid #b88a2e !important;
}

.oxford-citation {
  border-left: 3px solid #3a4a64 !important;
}

.citation-text:hover,
.apa-citation:hover,
.harvard-citation:hover,
.oxford-citation:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.citation-content {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--saho-text-primary);
  margin-bottom: 1.25rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: 'Georgia', serif;
}

.citation-actions {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--saho-border-light);
  display: flex;
  justify-content: flex-end;
}

/* Modern Copy Buttons - Citation Modal - Enhanced Size and Clarity */
#citation-modal .copy-individual,
#citation-modal .copy-all-citations,
#citation-modal .copy-btn {
  background: #990000 !important;
  color: #ffffff !important;
  border: none !important;
  padding: 0.875rem 1.5rem !important; /* Bigger padding for better touch targets */
  border-radius: 8px !important; /* Slightly more rounded */
  font-size: 0.95rem !important; /* Larger text for better readability */
  font-weight: 600 !important; /* Bolder text */
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px !important; /* WCAG compliant touch target */
  width: 100% !important; /* Full width for better visibility */
  box-shadow: 0 2px 8px rgba(153, 0, 0, 0.25) !important; /* Better depth */
}

/* Modern Copy Buttons - Sharing Modal */
#sharing-modal .url-copy-btn,
#sharing-modal .copy-url-btn,
#sharing-modal .copy-btn {
  background: #2d5016 !important;
  color: #ffffff !important;
  border: none !important;
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  font-size: 0.813rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

#citation-modal .copy-individual:hover,
#citation-modal .copy-all-citations:hover,
#citation-modal .copy-btn:hover {
  background: #7a0000 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(153, 0, 0, 0.2);
}

#sharing-modal .url-copy-btn:hover,
#sharing-modal .copy-url-btn:hover,
#sharing-modal .copy-btn:hover {
  background: #1a3009 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(45, 80, 22, 0.2);
}

.copy-individual:active,
.copy-all-citations:active,
.url-copy-btn:active,
.copy-url-btn:active,
.copy-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(153, 0, 0, 0.2);
}

.copied {
  background: linear-gradient(135deg, var(--saho-accent) 0%, #d4af37 100%) !important;
  color: var(--saho-text-primary) !important;
  box-shadow: 0 4px 16px rgba(184, 138, 46, 0.4);
  transform: translateY(-3px) scale(1.05);
  border-color: var(--saho-accent) !important;
}

/* Clean Modal Footer */
#citation-modal .modal-footer,
#sharing-modal .modal-footer {
  background: #ffffff;
  border-top: 1px solid #e5e5e5;
  padding: 1.5rem 2.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.modal-footer .copy-all-citations {
  padding: 1rem 2rem;
  font-size: 1rem;
}

/* Modern Sharing URL Section */
.url-copy-section {
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  position: relative;
}

.url-copy-section h6 {
  color: #3a4a64 !important;
  font-weight: 600;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.875rem;
}

.url-input-group {
  display: flex;
  gap: 0.75rem;
}

.url-input,
#page-url-input {
  flex: 1;
  padding: 0.75rem 1rem !important;
  border: 1px solid #e5e5e5 !important;
  border-radius: 6px;
  background: #fafafa !important;
  font-size: 0.875rem;
  font-family: ui-monospace, 'SF Mono', 'Monaco', monospace;
  color: #1a1a1a !important;
  transition: all 0.2s ease;
}

.url-input:focus,
#page-url-input:focus {
  border-color: #2d5016 !important;
  background: #ffffff !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.1) !important;
}

/* Modern Sharing Options Grid */
.sharing-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.share-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  text-decoration: none !important;
  color: #3a4a64 !important;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.share-option:hover,
.share-option:focus {
  background: #2d5016 !important;
  border-color: #2d5016 !important;
  color: #ffffff !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(45, 80, 22, 0.2);
  text-decoration: none !important;
}

.share-option svg {
  opacity: 0.8;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.share-option:hover svg {
  opacity: 1;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  /* Good sized buttons on mobile for better touch targets */
  .cite-button,
  .share-button {
    padding: 0.5rem 0.85rem !important;
    font-size: 0.9rem !important;
    gap: 0.4rem;
  }

  .cite-button svg,
  .share-button svg {
    width: 16px !important;
    height: 16px !important;
  }

  .citation-share-buttons {
    justify-content: center;
    gap: 0.5rem;
  }

  /* On mobile, stack meta info vertically but keep buttons inline */
  .saho-article-meta {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .saho-tools-wrapper {
    margin-left: 0 !important;
    align-self: flex-end; /* Align to right on mobile */
    margin-top: 0;
  }
}

/* Tablet Responsiveness */
@media (max-width: 1024px) and (min-width: 769px) {
  .saho-tools-wrapper {
    gap: 0.45rem;
  }
  
  .cite-button,
  .share-button {
    padding: 0.4rem 0.7rem !important;
    font-size: 0.85rem !important;
  }
  
  .cite-button svg,
  .share-button svg {
    width: 14px !important;
    height: 14px !important;
  }
}

  #citation-modal .modal-dialog,
  #sharing-modal .modal-dialog {
    max-width: 95%;
    margin: 0.75rem auto;
  }

  #citation-modal .modal-header,
  #sharing-modal .modal-header {
    padding: 1.5rem 1.75rem;
  }

  #citation-modal .modal-header .modal-title,
  #sharing-modal .modal-header .modal-title {
    font-size: 1.25rem;
  }

  #citation-modal .modal-body,
  #sharing-modal .modal-body {
    padding: 2rem 1.75rem;
  }

  .citation-text,
  .apa-citation,
  .harvard-citation,
  .oxford-citation {
    padding: 1.5rem !important;
  }

  .sharing-options {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .url-input-group {
    flex-direction: column;
    gap: 1rem;
  }

  .copy-individual,
  .copy-all-citations,
  .url-copy-btn,
  .copy-url-btn {
    width: 100%;
    justify-content: center;
    padding: 1rem 1.5rem;
  }

  .url-copy-section {
    padding: 1.5rem;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .cite-button,
  .share-button {
    flex: 1;
    justify-content: center;
    padding: 1rem;
    font-size: 0.8125rem;
  }

  .citation-share-buttons {
    flex-direction: column;
    gap: 0.75rem;
  }

  #citation-modal .modal-dialog,
  #sharing-modal .modal-dialog {
    max-width: 100%;
    margin: 0;
    height: 100vh;
    max-height: none;
  }

  #citation-modal .modal-content,
  #sharing-modal .modal-content {
    height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  #citation-modal .modal-header,
  #sharing-modal .modal-header {
    padding: 1.25rem 1.5rem;
    border-radius: 0;
  }

  #citation-modal .modal-body,
  #sharing-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
  }

  #citation-modal .modal-footer,
  #sharing-modal .modal-footer {
    padding: 1.5rem;
    border-radius: 0;
  }

  .url-copy-section {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
  }
}

/* Focus and Accessibility */
.cite-button:focus-visible,
.share-button:focus-visible {
  outline: 3px solid var(--saho-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--saho-primary-alpha-25);
}

#citation-modal *:focus-visible,
#sharing-modal *:focus-visible {
  outline: 2px solid var(--saho-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .cite-button,
  .share-button,
  .copy-individual,
  .copy-all-citations,
  .url-copy-btn,
  .copy-url-btn,
  .share-option {
    transition: none;
  }

  .cite-button::before,
  .share-button::before,
  .share-option::before {
    display: none;
  }
}

/* Print Styles */
@media print {
  .cite-button,
  .share-button {
    display: none !important;
  }

  #citation-modal,
  #sharing-modal {
    display: none !important;
  }

  .citation-text,
  .apa-citation,
  .harvard-citation,
  .oxford-citation {
    box-shadow: none;
    border: 1px solid #000;
    background: white;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .cite-button,
  .share-button {
    border-width: 3px;
    font-weight: 700;
  }

  #citation-modal .modal-header,
  #sharing-modal .modal-header {
    border: 3px solid var(--saho-primary);
  }

  .copy-individual,
  .copy-all-citations,
  .url-copy-btn,
  .copy-url-btn,
  .share-option:hover {
    border: 3px solid var(--saho-primary) !important;
    font-weight: 700;
  }

  .citation-text,
  .apa-citation,
  .harvard-citation,
  .oxford-citation {
    border-width: 2px !important;
    border-left-width: 6px !important;
  }
}

/* Dark mode support (future-proofing) */
@media (prefers-color-scheme: dark) {
  .cite-button,
  .share-button {
    background: var(--saho-secondary);
    color: var(--saho-surface);
    border-color: var(--saho-accent);
  }

  .cite-button:hover,
  .share-button:hover {
    background: var(--saho-accent);
    color: var(--saho-text-primary);
  }
}

/* CRITICAL OVERRIDE: Modern SAHO Styling - Highest Specificity */
/* Force clean, modern white design over any dark/brown/blue theme conflicts */

/* Clean White Modal Header */
#citation-modal .modal-header,
#citation-modal.modal .modal-header,
body #citation-modal .modal-header,
.modal#citation-modal .modal-header {
  background: #ffffff !important; /* Clean white background */
  color: #1a1a1a !important; /* Dark text for readability */
  border-bottom: 1px solid #e5e5e5 !important;
  border-radius: 0.375rem 0.375rem 0 0 !important;
  padding: 1.5rem 2rem !important;
}

/* Clean Light Modal Body */
#citation-modal .modal-body,
#citation-modal.modal .modal-body,
body #citation-modal .modal-body,
.modal#citation-modal .modal-body {
  background: #ffffff !important; /* Clean white background */
  color: #1a1a1a !important; /* Dark text for readability */
  padding: 2rem !important;
}

/* Modern Citation Format Sections - Clean White Cards */
#citation-modal .citation-format,
#citation-modal .citation-formatter .citation-format,
body #citation-modal .citation-format {
  background: #ffffff !important; /* Clean white background */
  border: 1px solid #e5e5e5 !important; /* Light border */
  border-radius: 0.5rem !important; /* Modern rounded corners */
  padding: 1.5rem !important;
  margin-bottom: 1.5rem !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important; /* Subtle shadow */
}

/* Citation Headers - SAHO Red, Clean Styling */
#citation-modal h4,
#citation-modal .citation-format h4,
#citation-modal .citation-format h6,
body #citation-modal h4 {
  color: #990000 !important; /* SAHO red for headers */
  background: transparent !important; /* No background */
  font-size: 1.1rem !important;
  font-weight: 600 !important;
  margin-bottom: 1rem !important;
  text-transform: none !important; /* Remove uppercase for readability */
}

/* Citation Content Areas - Clean White */
#citation-modal .citation-content,
#citation-modal .apa-citation,
#citation-modal .harvard-citation,
#citation-modal .oxford-citation,
body #citation-modal .citation-content {
  background: #f8f9fa !important; /* Very light gray for content */
  border: 1px solid #e9ecef !important;
  border-radius: 0.375rem !important;
  padding: 1rem !important;
  margin-bottom: 1rem !important;
  font-family: 'Georgia', serif !important;
  line-height: 1.6 !important;
  color: #2c3e50 !important;
}

/* Copy Buttons - Modern SAHO Red */
#citation-modal .copy-individual,
#citation-modal .copy-btn,
#citation-modal .copy-all-citations,
#citation-modal button[class*="copy"],
#citation-modal .btn-outline-secondary,
body #citation-modal .copy-individual {
  background: #990000 !important; /* SAHO red */
  color: #ffffff !important;
  border: 2px solid #990000 !important;
  border-radius: 0.375rem !important;
  padding: 0.75rem 1.5rem !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
  width: 100% !important;
  text-align: center !important;
}

#citation-modal .copy-individual:hover,
#citation-modal .copy-btn:hover,
#citation-modal .copy-all-citations:hover,
#citation-modal .btn-outline-secondary:hover,
body #citation-modal .copy-individual:hover {
  background: #7a0000 !important; /* Darker red on hover */
  border-color: #7a0000 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 8px rgba(153, 0, 0, 0.25) !important;
}

/* Close Button - Single, Visible, SAHO Red */
#citation-modal .btn-close,
#citation-modal.modal .btn-close,
body #citation-modal .btn-close {
  position: absolute !important;
  top: 1rem !important;
  right: 1rem !important;
  width: 36px !important;
  height: 36px !important;
  background: #ffffff !important;
  border: 2px solid #990000 !important;
  border-radius: 50% !important;
  color: #990000 !important;
  font-size: 16px !important;
  font-weight: bold !important;
  opacity: 1 !important;
  z-index: 999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#citation-modal .btn-close:hover,
body #citation-modal .btn-close:hover {
  background: #990000 !important;
  color: #ffffff !important;
  border-color: #990000 !important;
  transform: scale(1.05) !important;
}

/* Hide any duplicate close buttons from theme */
#citation-modal .btn-close + .btn-close,
#citation-modal .modal-header > button:not(.btn-close),
#citation-modal .modal-header .close,
.saho-citation-modal .btn-close:not(:first-of-type) {
  display: none !important;
}

/* Override any dark theme completely */
.saho-citation-modal,
.saho-citation-modal .modal-header,
.saho-citation-modal .modal-body,
.saho-citation-modal .citation-format {
  background: #ffffff !important;
  color: #1a1a1a !important;
}

/* COMPLETE OVERRIDE OF CONFLICTING THEME STYLES */
/* Target and override the brown/blue gradient styles from modern-modals.css */

/* Kill any brown/saddle brown gradients completely */
.saho-citation-modal .modal-header,
.saho-citation-modal .modal-body,
.saho-citation-modal .citation-format,
.saho-citation-modal .citation-text,
.saho-citation-modal .copy-btn,
#citation-modal .modal-content.saho-citation-modal,
#citation-modal .modal-content.saho-citation-modal .modal-header,
#citation-modal .modal-content.saho-citation-modal .modal-body {
  background: #ffffff !important; /* Force white over any gradients */
  background-image: none !important; /* Kill gradients */
  border-color: #e5e5e5 !important;
  color: #1a1a1a !important;
}

/* Override brown button gradients with clean SAHO red */
.saho-citation-modal .copy-btn,
.saho-citation-modal .copy-individual,
.saho-citation-modal .copy-all-citations {
  background: #990000 !important; /* SAHO red, not brown */
  background-image: none !important; /* Kill gradients */
  color: #ffffff !important;
}

/* Force citation format background to be white, not blue/brown */
.citation-format {
  background: #ffffff !important;
  background-image: none !important;
  border: 1px solid #e5e5e5 !important;
  color: #1a1a1a !important;
}

/* ========================================================================
   SHARING MODAL - MODERN SAHO STYLING
   ======================================================================== */

/* Clean White Sharing Modal Header */
#sharing-modal .modal-header,
#sharing-modal.modal .modal-header,
body #sharing-modal .modal-header,
.modal#sharing-modal .modal-header {
  background: #ffffff !important; /* Clean white background */
  color: #1a1a1a !important; /* Dark text for readability */
  border-bottom: 1px solid #e5e5e5 !important;
  border-radius: 0.375rem 0.375rem 0 0 !important;
  padding: 1.5rem 2rem !important;
}

/* Clean White Sharing Modal Body */
#sharing-modal .modal-body,
#sharing-modal.modal .modal-body,
body #sharing-modal .modal-body,
.modal#sharing-modal .modal-body {
  background: #ffffff !important; /* Clean white background */
  color: #1a1a1a !important; /* Dark text for readability */
  padding: 2rem !important;
}

/* URL Copy Section - Clean White Card */
#sharing-modal .url-copy-section,
#sharing-modal .sharing-content .url-copy-section,
body #sharing-modal .url-copy-section {
  background: #f8f9fa !important; /* Light gray background */
  border: 1px solid #e5e5e5 !important;
  border-radius: 0.5rem !important;
  padding: 1.5rem !important;
  margin-bottom: 1.5rem !important;
}

#sharing-modal .url-copy-section h6,
body #sharing-modal .url-copy-section h6 {
  color: #2d5016 !important; /* SAHO forest green for sharing headers */
  font-weight: 600 !important;
  margin-bottom: 1rem !important;
  font-size: 1rem !important;
}

/* URL Input Field - Clean Styling */
#sharing-modal .url-input,
#sharing-modal #page-url-input,
body #sharing-modal .url-input {
  background: #ffffff !important;
  border: 1px solid #e5e5e5 !important;
  border-radius: 0.375rem !important;
  padding: 0.75rem 1rem !important;
  font-size: 0.9rem !important;
  color: #495057 !important;
  font-family: 'SF Mono', 'Monaco', monospace !important;
}

/* Copy URL Button - SAHO Forest Green */
#sharing-modal .url-copy-btn,
#sharing-modal .copy-url-btn,
#sharing-modal button[class*="copy"],
body #sharing-modal .url-copy-btn {
  background: #2d5016 !important; /* SAHO forest green */
  color: #ffffff !important;
  border: 2px solid #2d5016 !important;
  border-radius: 0.375rem !important;
  padding: 0.75rem 1.5rem !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
  white-space: nowrap !important;
}

#sharing-modal .url-copy-btn:hover,
#sharing-modal .copy-url-btn:hover,
body #sharing-modal .url-copy-btn:hover {
  background: #1a3009 !important; /* Darker forest green on hover */
  border-color: #1a3009 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 8px rgba(45, 80, 22, 0.25) !important;
}

/* Sharing Options Grid - Clean Cards */
#sharing-modal .sharing-options,
body #sharing-modal .sharing-options {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 1rem !important;
  margin-top: 1.5rem !important;
}

/* Social Share Buttons - Clean White Cards with SAHO Accents */
#sharing-modal .share-option,
#sharing-modal .sharing-options a,
body #sharing-modal .share-option {
  background: #ffffff !important; /* Clean white background */
  border: 1px solid #e5e5e5 !important;
  border-radius: 0.5rem !important;
  padding: 1rem 1.25rem !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
  text-decoration: none !important;
  color: #495057 !important;
  font-weight: 500 !important;
  font-size: 0.9rem !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

#sharing-modal .share-option:hover,
#sharing-modal .sharing-options a:hover,
body #sharing-modal .share-option:hover {
  background: #2d5016 !important; /* SAHO forest green on hover */
  border-color: #2d5016 !important;
  color: #ffffff !important;
  text-decoration: none !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 12px rgba(45, 80, 22, 0.2) !important;
}

#sharing-modal .share-option svg,
#sharing-modal .sharing-options a svg,
body #sharing-modal .share-option svg {
  width: 20px !important;
  height: 20px !important;
  flex-shrink: 0 !important;
  fill: currentColor !important;
}

/* Close Button - Single, Visible, SAHO Forest Green */
#sharing-modal .btn-close,
#sharing-modal.modal .btn-close,
body #sharing-modal .btn-close {
  position: absolute !important;
  top: 1rem !important;
  right: 1rem !important;
  width: 36px !important;
  height: 36px !important;
  background: #ffffff !important;
  border: 2px solid #2d5016 !important; /* Forest green border */
  border-radius: 50% !important;
  color: #2d5016 !important; /* Forest green X */
  font-size: 16px !important;
  font-weight: bold !important;
  opacity: 1 !important;
  z-index: 999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#sharing-modal .btn-close:hover,
body #sharing-modal .btn-close:hover {
  background: #2d5016 !important; /* Fill with forest green on hover */
  color: #ffffff !important;
  border-color: #2d5016 !important;
  transform: scale(1.05) !important;
}

/* Hide any duplicate close buttons from theme */
#sharing-modal .btn-close + .btn-close,
#sharing-modal .modal-header > button:not(.btn-close),
#sharing-modal .modal-header .close,
.saho-sharing-modal .btn-close:not(:first-of-type) {
  display: none !important;
}

/* Override any dark theme completely for sharing modal */
.saho-sharing-modal,
.saho-sharing-modal .modal-header,
.saho-sharing-modal .modal-body,
.saho-sharing-modal .url-copy-section,
.saho-sharing-modal .sharing-options {
  background: #ffffff !important;
  background-image: none !important;
  color: #1a1a1a !important;
}

/* Mobile Responsive for Sharing Modal */
@media (max-width: 768px) {
  #sharing-modal .sharing-options {
    grid-template-columns: 1fr !important;
  }
  
  #sharing-modal .url-input-group {
    flex-direction: column !important;
    gap: 1rem !important;
  }
  
  #sharing-modal .url-copy-btn {
    width: 100% !important;
  }
}

/* Bootstrap Modal Backdrop Override - Modern neutral theme */
.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.5) !important; /* Neutral black with 50% opacity */
  backdrop-filter: blur(8px) !important;
}

.modal-backdrop.fade {
  opacity: 0 !important;
}

.modal-backdrop.show {
  opacity: 1 !important;
}

/* Force override any Bootstrap defaults */
body.modal-open .modal-backdrop {
  background-color: rgba(0, 0, 0, 0.5) !important;
}

/* Modal animations and transitions */
.modal.fade .modal-dialog {
  transform: scale(0.95) translateY(-20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Add entrance animation */
@keyframes modalSlideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal.show .modal-content {
  animation: modalSlideIn 0.3s ease-out;
}