/* Persian News Website Styles */

/* Persian Font */
body {
  font-family: "Vazirmatn", "Tahoma", sans-serif;
  line-height: 1.8;
}

/* Loading Skeleton Styles */
.news-item-skeleton {
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Priority loading for above-the-fold images */
.news-thumbnail {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
}

/* News Detail Page Improvements */
.news-detail-page .card {
  border: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.news-detail-page .card-title {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.3;
  color: #2c3e50;
}

/* All text in news detail page (except titles) use Space Grotesk regular */
.news-detail-page {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 400;
}

.news-detail-page .bg-light {
  background-color: #f8f9fa !important;
  border: 1px solid #e9ecef;
}

.news-detail-page .btn-primary {
  background-color: #007bff;
  border-color: #007bff;
  font-weight: 500;
}

.news-detail-page .btn-outline-secondary {
  border-color: #6c757d;
  color: #6c757d;
  font-weight: 500;
}

.news-detail-page .btn-outline-secondary:hover {
  background-color: #6c757d;
  border-color: #6c757d;
}

/* Related News Cards */
.related-news .card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid #e9ecef;
}

.related-news .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.related-news .card-title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
}

/* Most Viewed News */
.most-viewed-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f3f4;
}

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

.most-viewed-item h6 {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
}

/* Clean Typography */
.news-detail-page h1,
.news-detail-page h2,
.news-detail-page h3,
.news-detail-page h4,
.news-detail-page h5,
.news-detail-page h6 {
  color: #2c3e50;
  font-weight: 600;
}

.news-detail-page .text-muted {
  color: #6c757d !important;
}

/* Navbar background color customization */
.navbar,
.navbar-light,
.navbar-light.bg-light {
  background-color: #fff8e7 !important;
}

/* Header background color customization */
header,
.bg-primary {
  background: linear-gradient(
    90deg,
    rgba(15, 112, 150, 1) 0%,
    rgba(25, 46, 140, 1) 86%,
    rgba(237, 221, 83, 1) 100%
  ) !important;
}

/* Header text color customization */
header h1,
header .h3,
header .navbar-brand {
  color: white !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Header logo styling */
header .logo-image {
  max-height: 96px !important;
  width: auto !important;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) !important;
  transition: transform 0.3s ease !important;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.1);
  padding: 6px;
  flex-shrink: 0; /* Prevent logo from shrinking */
}

header .logo-image:hover {
  transform: scale(1.05) !important;
}

/* Header text styling */
header h1 {
  margin-bottom: 0 !important;
  margin-left: 1rem; /* Add space between logo and text */
}

/* Header text container */
.header-text-container {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Header title styling */
.header-title {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Header subtitle styling */
.header-subtitle {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 400;
  margin-top: 0.25rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-subtitle i {
  color: #ffc200;
  font-size: 0.8rem;
}

/* Header flex container */
header .d-flex.align-items-center {
  gap: 1rem;
}

/* Mobile responsive header */
@media (max-width: 768px) {
  header .logo-image {
    max-height: 72px !important;
    padding: 3px;
    margin-right: 0.75rem !important;
  }

  header .d-flex {
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: wrap;
  }

  .header-text-container {
    flex: 1;
    min-width: 0; /* Allow text to shrink */
  }

  .header-title {
    font-size: 1.1rem !important;
    white-space: normal !important;
    line-height: 1.3;
    margin-bottom: 0.25rem !important;
  }

  .header-subtitle {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    white-space: normal;
    line-height: 1.2;
  }

  /* Button container adjustments */
  .col-12.col-md-6.mt-3.mt-md-0 {
    margin-top: 1rem !important;
  }

  .d-flex.justify-content-start.justify-content-md-end {
    justify-content: flex-start !important;
  }
}

/* Extra small screens */
@media (max-width: 576px) {
  .header-title {
    font-size: 1rem !important;
  }

  .header-subtitle {
    font-size: 0.7rem;
  }

  header .logo-image {
    max-height: 60px !important;
    margin-right: 0.5rem !important;
  }
}

/* Header button background color customization */
header .btn,
header .btn-outline-light,
header .btn-outline-primary {
  background-color: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  color: white !important;
  backdrop-filter: blur(10px);
}

header .btn:hover,
header .btn-outline-light:hover,
header .btn-outline-primary:hover {
  background-color: rgba(255, 255, 255, 0.3) !important;
  border-color: rgba(255, 255, 255, 0.7) !important;
  color: white !important;
}

/* Most Viewed News section background color */
.most-viewed-card .card-header,
.bg-gradient-primary {
  background: #db7093 !important;
  background-color: #db7093 !important;
}

/* Advertisements background color */
.card-header.bg-warning,
.bg-warning {
  background-color: #db7093 !important;
  color: white !important;
}

/* Most Viewed News items background color */
.most-viewed-item {
  background-color: #fff8e7 !important;
  padding: 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

/* RTL Support */
.rtl {
  direction: rtl;
  text-align: right;
}

/* Header Styles */
header {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Navigation Styles */
.navbar {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Card Styles */
.card {
  border: none;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.card-title a {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  color: #1d2733;
  text-decoration: none;
  transition: color 0.3s ease;
}

.card-title a:hover {
  color: #007bff;
}

/* News Grid - Responsive Layout */
#newsGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  #newsGrid {
    grid-template-columns: 1fr;
  }
}

.news-item {
  animation: fadeInUp 0.6s ease;
  width: 100%;
}

/* Prevent duplicate card display */
.news-item[data-news-id] {
  display: block !important;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Category Badges */
.badge {
  font-size: 0.75rem;
  padding: 0.5em 0.75em;
  border-radius: 20px;
  border: none !important;
  background-color: transparent !important;
  color: #333333 !important;
}

/* Button Styles */
.btn {
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

/* Search Bar */
.form-control {
  border-radius: 25px;
  border: 2px solid #e9ecef;
  transition: all 0.3s ease;
}

.form-control:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Footer */
footer {
  margin-top: auto;
}

/* Dark Mode Styles */
.dark-mode {
  background-color: #1a1a1a;
  color: #ffffff;
}

.dark-mode .card {
  background-color: #2d2d2d;
  color: #ffffff;
}

.dark-mode .navbar-light {
  background-color: #2d2d2d !important;
  border-color: #404040;
}

.dark-mode .form-control {
  background-color: #2d2d2d;
  border-color: #404040;
  color: #ffffff;
}

.dark-mode .btn-outline-primary {
  border-color: #007bff;
  color: #007bff;
}

.dark-mode .btn-outline-primary:hover {
  background-color: #007bff;
  border-color: #007bff;
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .card-title {
    font-size: 1.1rem;
  }

  .btn {
    font-size: 0.875rem;
  }

  .navbar-nav {
    text-align: center;
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Alert Styles */
.alert {
  border-radius: 10px;
  border: none;
}

.alert-info {
  background-color: #e7f3ff;
  color: #004085;
}

.alert-warning {
  background-color: #fff3cd;
  color: #856404;
}

/* Advertisement Spaces */
.bg-light {
  background-color: #f8f9fa !important;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
}

/* Advertisement Images */
.ads-section {
  display: block;
  width: 100%;
}

.ads-section img {
  width: 400px;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 8px;
  transition: transform 0.3s ease;
  display: block;
}

.ads-section img:hover {
  transform: scale(1.02);
}

/* Single Column Layout Optimization */
.news-item {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.news-item:hover {
  transform: translateY(-2px);
}

.news-item .card {
  border-left: 4px solid transparent;
  transition: border-left-color 0.3s ease;
}

.news-item:hover .card {
  border-left-color: #007bff;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15) !important;
}

/* News Link Hover Effects */
.news-link {
  position: relative;
  overflow: hidden;
}

.news-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #007bff;
  transition: width 0.3s ease;
}

.news-link:hover::after {
  width: 100%;
}

/* Footer Links */
footer a {
  color: #6c757d;
  text-decoration: none;
  transition: color 0.3s ease;
}

footer a:hover {
  color: #ffffff;
}

/* Compact News Card Styles */
.news-item .card {
  border-radius: 8px;
  border: 1px solid #e9ecef;
  transition: all 0.2s ease;
}

.news-item .card-body {
  padding: 1rem;
  background-color: #fff8e7 !important;
}

.news-item .card-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.25rem; /* 20px */
  font-weight: 600;
  color: #1d2733;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.news-item .card-text {
  margin-bottom: 0;
}

/* Original Source Button */
.news-item .btn-outline-primary {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

/* Category Badge */
.news-item .badge {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  border: none !important;
  background-color: transparent !important;
  color: #333333 !important;
}

/* Views Counter */
.news-item .text-muted {
  font-size: 0.75rem;
}

/* Meta Information */
.news-item .card-text small {
  font-size: 0.75rem;
  line-height: 1.3;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .news-item .card-body {
    padding: 0.75rem;
  }

  .news-item .card-title {
    font-size: 1.125rem; /* 18px for mobile */
  }

  .news-item .btn-outline-primary {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
  }

  /* Ensure meta row wraps nicely on mobile */
  .news-item .d-flex.flex-wrap {
    gap: 0.5rem;
  }

  .news-item .d-flex.flex-wrap > * {
    margin-bottom: 0.25rem;
  }
}

/* Print Styles */
@media print {
  .navbar,
  footer,
  .btn,
  .card-header {
    display: none !important;
  }

  .card {
    border: 1px solid #ddd !important;
    box-shadow: none !important;
  }
}

/* Most Viewed News Section Styling */
.bg-gradient-primary {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.most-viewed-card {
  border: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.most-viewed-card .card-header {
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.most-viewed-item {
  transition: all 0.2s ease;
  padding: 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.most-viewed-item:hover {
  background-color: #f5f0e8;
  transform: translateX(2px);
}

.most-viewed-item a {
  font-family: "Space Grotesk", sans-serif;
  color: #1d2733 !important;
  font-weight: 400;
}

.most-viewed-item a:hover {
  color: #007bff !important;
}

/* Pagination and Loading States */
#loadMoreBtn {
  transition: all 0.3s ease;
  min-width: 150px;
}

#loadMoreBtn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#loadMoreBtn .spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

/* Loading animation for news items */
.news-item.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Smooth fade-in animation for new items */
.news-item {
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pagination info styling */
.pagination-info {
  font-size: 0.9rem;
  color: #6c757d;
  margin-top: 0.5rem;
}

/* Related News Styling */
.related-news .card {
  transition: all 0.3s ease;
  border: 1px solid #e9ecef;
}

.related-news .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.related-news .card-title a {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  color: #1d2733;
}

.related-news .card-title a:hover {
  color: #007bff;
}

/* News Detail Page Category Badges */
.news-detail-page .badge,
.related-news .badge {
  font-size: 0.75rem;
  background-color: #6495ed !important; /* Cornflower blue background */
  color: #ffffff !important; /* White text for better contrast */
  border: 1px solid #4a7bc8 !important; /* Matching darker blue border */
}

/* Thumbnail Styling */
.news-thumbnail {
  width: 150px;
  height: 70px;
  object-fit: cover;
  transition: transform 0.2s ease;
  border-radius: 8px;
}

.news-thumbnail:hover {
  transform: scale(1.02);
}

.news-thumbnail-placeholder {
  width: 150px;
  height: 70px;
  background-color: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
}

.news-detail-thumbnail {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.news-detail-thumbnail-small {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.news-detail-thumbnail-small:hover {
  transform: scale(1.02);
}

/* News detail title and image container */
.news-detail-header {
  align-items: flex-start;
}

.news-detail-title {
  padding-right: 1rem;
}

.news-detail-title h1 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  color: #1d2733;
}

.news-detail-image {
  text-align: center;
}

.related-thumbnail {
  width: 150px;
  height: 70px;
  object-fit: cover;
  transition: transform 0.2s ease;
  border-radius: 8px;
}

.related-thumbnail:hover {
  transform: scale(1.05);
}

/* Responsive thumbnail adjustments */
@media (max-width: 768px) {
  .news-thumbnail {
    width: 120px;
    height: 60px;
  }

  .news-thumbnail-placeholder {
    width: 120px;
    height: 60px;
  }

  .related-thumbnail {
    width: 120px;
    height: 60px;
  }

  .news-detail-thumbnail {
    max-height: 200px;
  }

  .news-detail-thumbnail-small {
    max-height: 150px;
    margin-top: 1rem;
  }

  /* Stack title and image vertically on mobile */
  .news-detail-thumbnail-small {
    margin-top: 1rem;
  }

  /* Mobile sidebar styling - now handled by Bootstrap classes */
  .d-lg-none .ads-section {
    margin-top: 0;
  }

  /* Responsive advertisement images on mobile */
  .ads-section {
    display: block !important;
    width: 100% !important;
  }

  .ads-section img {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    object-fit: contain !important;
    display: block !important;
    visibility: visible !important;
  }

  /* Ensure GIF animations work on mobile */
  .ads-section img[src*=".gif"] {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    object-fit: contain !important;
    display: block !important;
    visibility: visible !important;
  }

  /* Override Bootstrap img-fluid on mobile for ads */
  .ads-section .img-fluid {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    display: block !important;
    visibility: visible !important;
  }

  /* Show mobile inline ads */
  .mobile-ad {
    display: block !important;
    margin: 20px 0;
    text-align: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
  }

  .mobile-ad img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
  }

  .mobile-ad .ad-label {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
}

/* Hide mobile ads on desktop */
@media (min-width: 769px) {
  .mobile-ad {
    display: none !important;
  }
}

/* ===== 3D Feature Cards in Footer ===== */
.feature-cards-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Tablet: 2 columns */
@media (min-width: 768px) {
  .feature-cards-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop: 4 columns */
@media (min-width: 992px) {
  .feature-cards-container {
    grid-template-columns: repeat(4, 1fr);
  }
}

.feature-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 14px;
  color: #f5f7fa;
  padding: 12px 16px;
  min-height: 70px;
  background: #333;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.4), 0 18px 36px rgba(0, 0, 0, 0.25), 
              inset 0 1px 2px rgba(255, 255, 255, 0.14);
  transform: translateY(30px);
  opacity: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
  will-change: transform, opacity;
}

/* Light reflection on top */
.feature-card::before {
  content: "";
  position: absolute;
  inset: 0 0 58% 0;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent);
  pointer-events: none;
}

/* Shadow reflection at bottom */
.feature-card::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  filter: blur(10px);
  transform: scaleX(1.08);
}

/* Card colors with gradients for depth */
.feature-card-updates {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
}

.feature-card-translation {
  background: linear-gradient(180deg, #f59e0b, #d97706);
}

.feature-card-sources {
  background: linear-gradient(180deg, #10b981, #059669);
}

.feature-card-simple {
  background: linear-gradient(180deg, #6366f1, #4f46e5);
}

/* Card content */
.feature-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feature-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
}

.feature-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
}

/* Hover effect (desktop) */
@media (pointer: fine) {
  .feature-card:hover {
    box-shadow: 0 10px 14px rgba(0, 0, 0, 0.45), 0 22px 44px rgba(0, 0, 0, 0.28),
                inset 0 1px 2px rgba(255, 255, 255, 0.18);
    transform: translateY(0);
    opacity: 1;
  }
}

/* Entry animation */
.feature-card.show {
  opacity: 1;
  transform: translateY(0);
}

/* 3D Tilt effect for precise pointers */
@media (pointer: fine) {
  .feature-card {
    transform-style: preserve-3d;
  }
  
  .feature-card:hover {
    transform: translateY(0) rotateX(0) rotateY(0);
  }
}

/* Highlighted number style for update frequency */
.update-count-highlight {
  font-size: 1.2em;
  font-weight: 700;
  color: #0d6efd;
  display: inline-block;
}

.feature-title .update-count-highlight {
  font-size: 1.3em;
}
