/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow standard
 * cascading order, meaning styles declared later in document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 *
 * Note: mobile.css and batch_uploads.css are loaded separately via stylesheet_link_tag
 * in layouts/application.html.erb due to Propshaft @import limitations in development.
 */

/* Custom styles that complement Bootstrap */

/* Issue Detail Page */
.issue-detail {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  margin: 2rem 0;
  overflow: hidden;
}

.issue-header {
  padding: 2rem;
  border-bottom: 1px solid #dee2e6;
}

.main-image {
  width: 100%;
  max-width: 800px;
  height: auto;
}

.ocr-content {
  padding: 2rem;
  border-top: 1px solid #dee2e6;
}

.ocr-text {
  background-color: #f8f9fa;
  padding: 1.5rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  line-height: 1.8;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.status-badge.pending {
  background-color: #ffc107;
  color: #212529;
}

.status-badge.processing {
  background-color: #17a2b8;
  color: white;
}

.status-badge.completed {
  background-color: #28a745;
  color: white;
}

.status-badge.failed {
  background-color: #dc3545;
  color: white;
}

/* Custom enhancements for cards */
.issue-card, .result-card {
  transition: transform 0.2s ease;
}

.issue-card:hover, .result-card:hover {
  transform: translateY(-2px);
}

/* Grid layouts using Bootstrap classes */
.issues-grid, .results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.search-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .search-grid {
    grid-template-columns: 1fr;
  }

  .issues-grid, .results-grid {
    grid-template-columns: 1fr;
  }
}

/* Features and Help Pages */
.feature-icon-circle {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.feature-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.anchor-section {
  scroll-margin-top: 80px; /* Account for sticky navbar */
  padding-top: 2rem;
}

.help-nav-pills {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.help-nav-pills .nav-link {
  white-space: nowrap;
}

/* Phrase Highlighting */
.phrase-highlight {
  background-color: #e3f2fd;
  border-bottom: 2px dotted #2196f3;
  padding: 0 2px;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.phrase-highlight:hover {
  background-color: #bbdefb;
}

.phrase-highlight-active {
  background-color: #90caf9;
  border-bottom-color: #1976d2;
}

.phrase-popover-content {
  min-width: 200px;
}

.phrase-popover-content h6 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.phrase-popover-content p {
  font-size: 0.8rem;
}

.phrase-popover-content .btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

/* Search Autocomplete */
.search-autocomplete-wrapper {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 0.25rem 0.25rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: none;
  margin-top: -1px;
}

.autocomplete-results.show {
  display: block;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.15s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
  background-color: #f8f9fa;
}

.autocomplete-item strong {
  color: #0d6efd;
  font-weight: 600;
}

/* Publication Hero Section */
.publication-hero-wrapper {
  position: relative;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  margin-top: -2rem;
  margin-bottom: 1rem;
}

.publication-hero {
  position: relative;
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  min-height: 250px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.publication-hero.with-image {
  min-height: 300px;
}

/* Hero Background Image */
.hero-background-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 1;
}

/* Dark overlay for text readability */
.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.5) 0%, rgba(10, 88, 202, 0.35) 100%);
  z-index: 2;
}

/* Subtle fade overlay when image is present - preserves image colors */
.publication-hero.with-image .hero-overlay {
  background: rgba(0, 0, 0, 0.4);
}

/* Hero Content */
.hero-content {
  position: relative;
  z-index: 3;
  color: white;
  padding: 3rem 0;
  width: 100%;
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-description {
  font-size: 1.25rem;
  color: rgba(255, 255, 255, 0.95);
  margin-top: 0.75rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.hero-creator {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 0.5rem;
}

.hero-logo {
  max-height: 80px;
  max-width: 140px;
  border-radius: 8px;
  background: white;
  padding: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Curved Bottom Separator - Gentle Elliptical Curve */
.curved-separator {
  position: relative;
  height: 80px;
  background: #ecf0f1;
  margin-top: -80px;
  clip-path: ellipse(60% 100% at 50% 100%);
  z-index: 4;
}

/* Fallback for browsers without clip-path */
@supports not (clip-path: ellipse(60% 100% at 50% 100%)) {
  .curved-separator {
    border-radius: 50% 50% 0 0 / 80px 80px 0 0;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .publication-hero {
    min-height: 100px;
  }

  .publication-hero.with-image {
    min-height: 200px;
  }

  .hero-content {
    padding: 2rem 0;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-description {
    font-size: 1rem;
  }

  .hero-logo {
    max-height: 60px;
    max-width: 100px;
  }

  .curved-separator {
    height: 50px;
    margin-top: -50px;
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 991px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .publication-hero.with-image {
    min-height: 250px;
  }
}

/* Large screens */
@media (min-width: 1400px) {
  .publication-hero.with-image {
    min-height: 400px;
  }

  .curved-separator {
    height: 100px;
    margin-top: -100px;
  }
}

/* Utility Classes */

/* Icon Sizes */
.icon-xs {
  font-size: 0.75rem;
}

.icon-sm {
  font-size: 1.5rem;
}

.icon-md {
  font-size: 2rem;
}

.icon-lg {
  font-size: 3rem;
}

.icon-xl {
  font-size: 4rem;
}

/* Avatar/Circle Sizes */
.avatar-xs {
  width: 32px;
  height: 32px;
}

.avatar-sm {
  width: 40px;
  height: 40px;
}

.avatar-md {
  width: 48px;
  height: 48px;
}

.avatar-lg {
  width: 60px;
  height: 60px;
}

/* Z-Index Layers */
.z-sticky {
  z-index: 1000;
}

.z-dropdown {
  z-index: 1010;
}

.z-modal {
  z-index: 1050;
}

.z-modal-backdrop {
  z-index: 1060;
}

.z-toast {
  z-index: 9999;
}

/* Scrollable Panels */
.scrollable-xs {
  max-height: 200px;
  overflow-y: auto;
}

.scrollable-sm {
  max-height: 300px;
  overflow-y: auto;
}

.scrollable-md {
  max-height: 400px;
  overflow-y: auto;
}

/* Sticky Positioning */
.sticky-below-nav {
  position: sticky;
  top: 72px;
}

/* Toast Container */
.toast-container-fixed {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  max-width: 350px;
}

/* Text Sizes */
.text-xs {
  font-size: 0.625rem;
}

.text-2xs {
  font-size: 0.75rem;
}

.text-sm {
  font-size: 0.875rem;
}

/* Search Highlight */
.search-highlight {
  background-color: #ffeb3b;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 500;
}

/* White Space */
.whitespace-pre-wrap {
  white-space: pre-wrap;
}

/* Font Styles */
.font-italic {
  font-style: italic;
}

/* Line Height */
.line-height-relaxed {
  line-height: 1.8;
}

/* Hover Lift Effect */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Navbar Brand Styles */
.navbar-brand-text {
  font-size: 1.5rem;
}

.navbar-brand-publication {
  font-size: 1.5rem;
  line-height: 1.2;
}

/* Decade Timeline Dropdown Buttons */
#decade-buttons .btn-group {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  transition: box-shadow 0.2s ease;
}

#decade-buttons .btn-group:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#decade-buttons .dropdown-menu {
  min-width: 220px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  padding: 0.5rem 0;
  text-align: left;
}

#decade-buttons .dropdown-item {
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: background-color 0.15s ease;
  color: #212529;
}

#decade-buttons .dropdown-item i {
  flex-shrink: 0;
  width: 20px;
  color: #6c757d;
}

#decade-buttons .dropdown-item > span:first-of-type {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#decade-buttons .dropdown-item .badge {
  flex-shrink: 0;
}

#decade-buttons .dropdown-item:hover {
  background-color: #e9ecef;
  color: #212529;
}

#decade-buttons .dropdown-item.active {
  background-color: #0d6efd;
  color: white;
}

#decade-buttons .dropdown-item.active i {
  color: white;
}

#decade-buttons .dropdown-item.active .badge {
  background-color: rgba(255, 255, 255, 0.9) !important;
  color: #0d6efd !important;
}

#decade-buttons .dropdown-divider {
  margin: 0.5rem 0;
  border-color: #dee2e6;
}

/* Ensure button text doesn't wrap awkwardly */
#decade-buttons .btn-lg {
  white-space: nowrap;
}

/* Mobile responsiveness for dropdowns */
@media (max-width: 768px) {
  #decade-buttons .btn-lg {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
  }
  
  #decade-buttons .dropdown-menu {
    font-size: 0.9rem;
    min-width: 200px;
  }
}
