/* Rating Display Styles - Google-like Badge */
.rating-display {
  display: inline-flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-decoration: none;
  color: #333;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  min-width: 280px;
  max-width: 320px;
  position: relative;
  overflow: hidden;
}

/* Custom Style */
.rating-style-custom {
  background-color: #ffffff;
  color: #333;
}

.rating-style-custom.no-animations {
  transition: none;
}

.rating-style-custom.no-animations * {
  transition: none !important;
  animation: none !important;
}

/* Top colored bar */
.rating-display::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4285f4 0%, #34a853 25%, #fbbc05 50%, #ea4335 75%, #4285f4 100%);
  z-index: 1;
}

/* Close Button */
.rating-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  font-weight: bold;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.rating-close-btn:hover {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
  transform: scale(1.1);
}

.rating-close-btn:active {
  transform: scale(0.95);
}

.no-animations .rating-close-btn:hover {
  transform: none;
}

/* Business Name */
.rating-business-name {
  font-weight: 600;
  font-size: 14px;
  margin: 12px 16px 8px 16px;
  text-align: center;
  color: #333;
}

/* Main Title - Hidden for Google-like design */
.rating-main-title {
  display: none;
}

/* Sources Container */
.rating-sources-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  padding: 8px 0;
}

/* Source Row - Google-like horizontal layout */
.rating-source-row {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  transition: all 0.3s ease;
  padding: 0;
}

.rating-source-info {
  display: flex;
  align-items: center;
  gap: 8px;
  direction: rtl;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 0;
  text-decoration: none;
  color: inherit;
  width: 100%;
  justify-content: space-between;
  transition: all 0.3s ease;
  position: relative;
}

.rating-source-info:hover {
  background: rgba(79, 70, 229, 0.05);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-decoration: none;
  color: inherit;
}

.no-animations .rating-source-info:hover {
  transform: none;
  box-shadow: none;
}

/* Source info layout */
.rating-source-info {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  justify-items: start;
}

/* Source Logo/Icon */
.rating-source-logo {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  border-radius: 4px;
}

.rating-source-logo.google {
  background: linear-gradient(45deg, #4285f4, #34a853, #fbbc05, #ea4335);
  color: white;
  font-family: "Product Sans", sans-serif;
}

.rating-source-logo.biz {
  background: #4f46e5;
  color: white;
  font-size: 12px;
}

/* Source Label */
.rating-source-label {
  font-weight: 600;
  font-size: 14px;
  color: #333;
  text-align: right;
  direction: rtl;
}

/* Stars container */
.rating-stars-container {
  display: flex;
  align-items: center;
  gap: 6px;
  direction: ltr;
}

/* Stars */
.rating-stars {
  display: flex;
  gap: 1px;
  font-size: 16px;
  line-height: 1;
  direction: ltr;
}

.star {
  display: inline-block;
  transition: transform 0.2s;
}

.rating-style-custom .star-full {
  color: #ff9800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.rating-style-custom .star-half {
  color: #ff9800;
  position: relative;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.rating-style-custom .star-half::before {
  content: "★";
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: #ff9800;
}

.rating-style-custom .star-empty {
  color: #e0e0e0;
}

.rating-stars:hover .star {
  transform: scale(1.1);
}

.rating-style-custom.no-animations .rating-stars:hover .star {
  transform: none;
}

/* Rating Score */
.rating-score {
  font-weight: 700;
  font-size: 16px;
  color: #333;
  direction: ltr;
  margin: 0 4px;
}

/* Rating Count and Details */
.rating-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  direction: rtl;
}

.rating-count-display {
  font-size: 12px;
  color: #666;
  font-weight: 400;
  direction: rtl;
  margin-top: 2px;
}

/* Separator line between sources */
.rating-source-row:not(:last-child) .rating-source-info::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
}

/* Floating Badge */
#floating-rating-badge {
  position: fixed;
  z-index: 9999;
  transition: all 0.3s ease;
}

.floating-badge-bottom-right {
  bottom: 20px;
  right: 20px;
}

.floating-badge-bottom-left {
  bottom: 20px;
  left: 20px;
}

.floating-badge-top-right {
  top: 20px;
  right: 20px;
}

.floating-badge-top-left {
  top: 20px;
  left: 20px;
}

#floating-rating-badge:hover {
  transform: scale(1.05);
}

#floating-rating-badge.no-animations:hover {
  transform: none;
}

/* RTL Support */
body.rtl .rating-display {
  direction: rtl;
}

body.rtl .rating-stars {
  direction: ltr;
}

body.rtl .rating-source-info {
  direction: rtl;
}

body.rtl .rating-source-label {
  text-align: right;
}

body.rtl .rating-close-btn {
  right: auto;
  left: 8px;
}

body.rtl .floating-badge-bottom-right {
  bottom: 20px;
  left: 20px;
  right: auto;
}

body.rtl .floating-badge-bottom-left {
  bottom: 20px;
  right: 20px;
  left: auto;
}

body.rtl .floating-badge-top-right {
  top: 20px;
  left: 20px;
  right: auto;
}

body.rtl .floating-badge-top-left {
  top: 20px;
  right: 20px;
  left: auto;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  #floating-rating-badge {
    bottom: 10px;
    right: 10px;
    left: auto;
    top: auto;
  }

  body.rtl #floating-rating-badge {
    bottom: 10px;
    left: 10px;
    right: auto;
    top: auto;
  }

  .rating-display {
    padding: 12px 16px;
    min-width: 250px;
  }

  .rating-close-btn {
    width: 20px;
    height: 20px;
    font-size: 14px;
    top: 6px;
    right: 6px;
  }

  body.rtl .rating-close-btn {
    right: auto;
    left: 6px;
  }

  .rating-stars {
    font-size: 14px;
  }

  .rating-main-title {
    font-size: 16px;
  }

  .rating-source-label {
    font-size: 12px;
    min-width: 60px;
  }

  .rating-score {
    font-size: 14px;
  }

  .rating-count-display {
    font-size: 11px;
  }
}

/* Animation for floating badge */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#floating-rating-badge {
  animation: fadeInUp 0.5s ease-out;
}

#floating-rating-badge.no-animations {
  animation: none;
}

/* Accessibility */
.rating-display:focus-within {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

.rating-close-btn:focus {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  #floating-rating-badge {
    display: none;
  }
}

/* Loading state */
.rating-display.loading {
  opacity: 0.6;
  pointer-events: none;
}

.rating-display.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-top: 2px solid #4f46e5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Star animation on load */
.rating-stars .star {
  animation: starFadeIn 0.5s ease-out forwards;
  opacity: 0;
}

.rating-stars .star:nth-child(1) {
  animation-delay: 0.1s;
}
.rating-stars .star:nth-child(2) {
  animation-delay: 0.2s;
}
.rating-stars .star:nth-child(3) {
  animation-delay: 0.3s;
}
.rating-stars .star:nth-child(4) {
  animation-delay: 0.4s;
}
.rating-stars .star:nth-child(5) {
  animation-delay: 0.5s;
}

@keyframes starFadeIn {
  to {
    opacity: 1;
  }
}

.no-animations .rating-stars .star {
  animation: none;
  opacity: 1;
}

/* Pulse effect for floating badge */
@keyframes pulse {
  0% {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.2);
  }
  100% {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }
}

#floating-rating-badge .rating-display {
  animation: pulse 3s ease-in-out infinite;
}

#floating-rating-badge:hover .rating-display,
#floating-rating-badge .rating-display.no-animations {
  animation: none;
}

/* MyGMB Branding Colors */
.mygmb-accent {
  color: #4f46e5;
}

.mygmb-gradient {
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
}

/* Enhanced styling for better visual appeal */
.rating-display {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Hide on mobile option */
.hide-on-mobile {
  display: block;
}

@media (max-width: 768px) {
  .hide-on-mobile {
    display: none !important;
  }
}

/* Ensure proper RTL text flow */
body.rtl .rating-source-info {
  direction: rtl;
  text-align: center;
}

body.rtl .rating-score,
body.rtl .rating-count-display {
  direction: ltr;
}

/* Enhanced Google styling */
.rating-source-row:has(.rating-source-label:contains("גוגל")) .rating-source-info,
.rating-source-row:first-child .rating-source-info {
  background: rgba(66, 133, 244, 0.05);
  border-color: rgba(66, 133, 244, 0.2);
}

.rating-source-row:has(.rating-source-label:contains("גוגל")) .rating-source-label,
.rating-source-row:first-child .rating-source-label {
  color: #4285f4;
}

/* Enhanced Biz Make Biz styling */
.rating-source-row:has(.rating-source-label:contains("Biz")) .rating-source-info,
.rating-source-row:last-child .rating-source-info {
  background: rgba(79, 70, 229, 0.05);
  border-color: rgba(79, 70, 229, 0.2);
}

.rating-source-row:has(.rating-source-label:contains("Biz")) .rating-source-label,
.rating-source-row:last-child .rating-source-label {
  color: #4f46e5;
}

/* Hover effects for links */
a.rating-source-info:hover {
  background: rgba(79, 70, 229, 0.15) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Special styling for single source */
.rating-sources-container:has(.rating-source-row:only-child) .rating-source-info {
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.3);
}

/* Close button hover animation */
@keyframes closeButtonPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.rating-close-btn:hover {
  animation: closeButtonPulse 0.3s ease-in-out;
}

.no-animations .rating-close-btn:hover {
  animation: none;
}
