/* Container */
.custom-reviews-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 15px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Error Message */
.custom-reviews-error {
  padding: 15px;
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  margin-bottom: 20px;
}

/* No Reviews Message */
.no-reviews {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 1.1em;
}

/* Summary Section */
.reviews-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 5px;
  padding-bottom: 0;
  padding-left: 0;
  padding-right: 0;
  border-bottom: 1px solid #eee;
}

.reviews-summary .app-icon img,
.reviews-summary .app-icon .item-icon {
  width: auto;
  max-width: 150px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 8px;
}

.reviews-summary .app-icon .no-icon {
  display: none;
}

.reviews-summary h3,
.reviews-summary .reviews-title {
  margin: 0 0 8px;
  font-size: 1.5em;
  color: #333;
  font-weight: bold;
}

.review-stats {
  width: 100%;
  padding: 0;
  margin-bottom: 0;
}

.review-count {
  text-align: center;
  margin-bottom: 8px;
  font-size: 1em;
  color: #666;
}

.average-ratings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

.rating-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rating-label {
  font-size: 0.9em;
  color: #666;
}

.rating-display {
  display: flex;
  align-items: center;
}

.rating-stars {
  color: #ffb900;
  margin-right: 5px;
  font-size: 1.1em;
}

.rating-number {
  font-weight: bold;
  color: #333;
}

/* Filters */
.reviews-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin: 15px 5px 20px 5px;
  padding: 15px 20px;
  background: #f5f5f5;
  border-radius: 6px;
}

.filter-group {
  display: flex;
  align-items: center;
}

.filter-group label {
  margin-right: 8px;
  font-weight: bold;
  font-size: 0.9em;
}

.filter-group select {
  padding: 5px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
}

/* Review List */
.review-item {
  padding: 20px 10px;
  border-bottom: 1px solid #eee;
  margin-bottom: 20px;
}

.review-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 15px;
}

.reviewer-avatar {
  margin-right: 15px;
}

.reviewer-avatar img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  color: #fff;
  font-weight: bold;
}

.reviewer-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.reviewer-name {
  font-weight: normal;
  font-size: 0.9em;
  color: #999;
}

.review-date {
  font-size: 0.85em;
  color: #999;
  margin-bottom: 4px;
}

.reviewer-meta {
  font-size: 0.85em;
  color: #666;
  background: #f0f0f0;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 6px;
  margin-top: 4px;
}

.reviewer-meta-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.review-ratings {
  background: #fbfbfb;
  padding: 15px 10px;
  border-radius: 6px;
  margin-bottom: 15px;
}

.overall-rating {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  padding: 12px;
  background: #fff;
  border-radius: 6px;
  border: 2px solid #ffb900;
}

.overall-rating .label {
  font-weight: bold;
  margin-right: 10px;
}

.overall-rating .stars {
  color: #ffb900;
  font-size: 1.2em;
  margin-right: 10px;
}

.overall-rating .stars .star {
  display: inline-block;
  position: relative;
}

.overall-rating .stars .star.full {
  color: #ffb900 !important;
}

.overall-rating .stars .star.half {
  color: #ddd !important;
}

.overall-rating .stars .star.half::before {
  content: "★";
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: #ffb900 !important;
}

.overall-rating .stars .star.empty {
  color: #ddd !important;
}

.detailed-ratings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.item-rating {
  display: flex;
  align-items: center;
  font-size: 0.9em;
}

.item-rating .label {
  margin-right: auto;
  color: #666;
}

.item-rating .stars {
  color: #ffb900;
  margin-right: 5px;
}

.item-rating-block {
  margin-bottom: 8px;
}

.item-rating-block:last-child {
  margin-bottom: 0;
}

.item-rating-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-rating-header .label {
  color: #666;
  font-weight: normal;
  font-size: 0.9em;
  min-width: 120px;
}

.item-rating-header .stars {
  color: #ffb900;
  font-size: 1em;
}

.item-rating-header .stars .star {
  display: inline-block;
  position: relative;
}

.item-rating-header .stars .star.full {
  color: #ffb900 !important;
}

.item-rating-header .stars .star.half {
  color: #ddd !important;
}

.item-rating-header .stars .star.half::before {
  content: "★";
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: #ffb900 !important;
}

.item-rating-header .stars .star.empty {
  color: #ddd !important;
}

.item-rating-header .number {
  font-weight: normal;
  color: #666;
  font-size: 0.85em;
}

.item-review-text {
  display: none;
}

.review-texts-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #eee;
  position: relative;
}

.review-texts-section.collapsed {
  max-height: 280px;
  overflow: hidden;
}

.review-texts-section.collapsed::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.9) 50%,
    rgba(255, 255, 255, 1) 100%
  );
  pointer-events: none;
}

.review-texts-section.expanded {
  max-height: none;
}

.review-texts-section.expanded::after {
  display: none;
}

.review-texts-section h5 {
  margin: 0 0 10px 0;
  font-size: 0.9em;
  color: #333;
}

.review-text-item {
  margin-bottom: 12px;
  padding: 10px;
  background: #f9f9f9;
  border-left: 3px solid #ffb900;
}

.review-text-item:last-child {
  margin-bottom: 0;
}

.review-text-item-label {
  font-weight: bold;
  color: #666;
  margin-bottom: 4px;
  font-size: 0.8em;
}

.review-text-item-content {
  line-height: 1.5;
  color: #555;
  font-size: 0.85em;
}

.review-expand-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #007cba;
  font-size: 0.9em;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.review-expand-btn:hover {
  background: #f5f5f5;
  border-color: #007cba;
}

.review-expand-btn.hidden {
  display: none;
}

.review-text {
  line-height: 1.6;
  color: #444;
}

.review-text h5 {
  margin: 0 0 10px 0;
  font-size: 1em;
  color: #666;
}

/* Force star colors */
.star {
  display: inline-block;
  position: relative;
}

.star.full {
  color: #ffb900 !important;
}

.star.half {
  color: #ddd !important;
  position: relative;
}

.star.half::before {
  content: "★";
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: #ffb900 !important;
}

.star.empty {
  color: #ddd !important;
}

/* Form */
.custom-review-form-container {
  margin-top: 40px;
  padding: 30px 15px;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #eee;
}

.custom-review-form-container h3 {
  margin-top: 0;
  margin-bottom: 20px;
  text-align: center;
}

.form-section {
  margin-bottom: 30px;
  padding: 20px;
  background: #fff;
  border-radius: 6px;
}

.form-section h4 {
  margin-top: 0;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #ff4455;
  color: #333;
}

.form-section h5 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #555;
  font-size: 1.1em;
}

.rating-block {
  background: #fafafa;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 1px solid #eee;
  transition: all 0.3s ease;
}

.rating-block:last-child {
  margin-bottom: 0;
}

.overall-rating-display {
  padding: 20px;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  text-align: center;
}

.overall-rating-display .overall-stars {
  display: block;
  font-size: 2em;
  margin-bottom: 10px;
}

.overall-rating-display .overall-stars .star {
  display: inline-block;
  position: relative;
}

.overall-rating-display .overall-stars .star.full {
  color: #ffb900;
}

.overall-rating-display .overall-stars .star.half {
  color: #ddd;
}

.overall-rating-display .overall-stars .star.half::before {
  content: "★";
  position: absolute;
  left: 0;
  width: 50%;
  overflow: hidden;
  color: #ffb900;
}

.overall-rating-display .overall-stars .star.empty {
  color: #ddd;
}

.overall-rating-display .overall-number {
  font-size: 2em;
  font-weight: bold;
  color: #333;
}

.overall-rating-display .overall-note {
  margin-top: 10px;
  margin-bottom: 0;
  font-size: 0.85em;
  color: #666;
}

.form-group {
  margin-bottom: 20px;
}

.radio-group {
  display: flex;
  gap: 20px;
}

.radio-group label {
  display: flex;
  align-items: center;
  font-weight: normal;
  cursor: pointer;
}

.radio-group input[type="radio"] {
  margin-right: 5px;
  width: auto;
}

.period-inputs {
  display: flex;
  gap: 15px;
  align-items: center;
}

.period-start,
.period-end {
  flex: 1;
}

.period-separator {
  font-size: 1.2em;
  color: #666;
}

.form-row {
  display: flex;
  gap: 20px;
}

.form-group.half {
  flex: 1;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #333;
}

.required {
  color: red;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1em;
  box-shadow: none; /* Reset shadow */
  box-sizing: border-box;
}

.date-selectors {
  display: flex;
  gap: 10px;
}

.date-selectors select {
  flex: 1;
}

.sub-label {
  display: block;
  font-size: 0.85em;
  color: #666;
  margin-bottom: 4px;
}

/* Override theme's potential red border for required/invalid fields */
.custom-review-form-container input:required,
.custom-review-form-container input:invalid,
.custom-review-form-container input:valid {
  border: 1px solid #ddd; /* Force default border color */
  background-color: #fff;
}

.custom-review-form-container input:focus,
.custom-review-form-container select:focus,
.custom-review-form-container textarea:focus {
  border-color: #ff4455;
  outline: none;
}

.star-rating-input .stars {
  display: flex;
  gap: 5px;
  cursor: pointer;
}

.star-rating-input .star {
  font-size: 1.5em;
  color: #ddd;
  transition: color 0.2s;
}

.star-rating-input .star.active,
.star-rating-input .star:hover,
.star-rating-input .star:hover ~ .star {
  color: #ffb900;
}

/* Hover effect logic is tricky with CSS only for "previous siblings", JS handles it better */
/* But we can use flex-direction: row-reverse to use ~ selector for hover, but that reverses order. */
/* We will rely on JS for the active class. */

.detailed-ratings-input {
  background: #fff;
  padding: 20px;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 1px solid #eee;
}

.detailed-ratings-input h4 {
  margin-top: 0;
  margin-bottom: 15px;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

.rating-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.rating-row label {
  margin-bottom: 0;
  font-weight: normal;
}

.btn-submit {
  display: block;
  width: 100%;
  padding: 12px;
  background: #ff4455;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1.1em;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-submit:hover {
  background: #dd2233;
}

.review-submit-link {
  text-align: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.btn-submit-review {
  display: inline-block;
  padding: 10px 25px;
  background: #333;
  color: #fff;
  text-decoration: none;
  border-radius: 25px;
  font-weight: bold;
  transition: background 0.2s;
}

.btn-submit-review:hover {
  background: #555;
}

.required {
  color: #d9534f;
  margin-left: 3px;
}

/* Review Carousel - Horizontal Scroll */
.custom-review-carousel {
  margin: 30px 0;
  width: 100%;
  overflow: hidden; /* Prevent parent overflow */
}

.review-carousel-wrapper {
  position: relative;
  width: 100%;
}

.review-carousel-items {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  padding: 10px 5px 20px 5px;
  -webkit-overflow-scrolling: touch;
  /* Androidスマホでのスクロール改善 */
  scrollbar-width: thin;
  width: 100%;
  box-sizing: border-box;
}

.review-carousel-items::-webkit-scrollbar {
  height: 8px;
}

.review-carousel-items::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.review-carousel-items::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 10px;
}

.review-carousel-items::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

.review-carousel-card {
  flex: 0 0 280px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 250px;
  box-sizing: border-box;
}

.review-carousel-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.carousel-card-header {
  margin-bottom: 15px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.carousel-reviewer-avatar {
  flex-shrink: 0;
}

.carousel-reviewer-avatar img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
}

.carousel-avatar-placeholder {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  color: #fff;
  font-weight: bold;
}

.carousel-reviewer-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.carousel-reviewer-name {
  font-size: 0.9em;
  color: #333;
  font-weight: 600;
}

.carousel-reviewer-meta {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.meta-badge {
  display: inline-block;
  padding: 3px 8px;
  background: #f0f0f0;
  border-radius: 4px;
  font-size: 0.75em;
  color: #666;
}

.carousel-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.carousel-stars {
  color: #ffb900;
  font-size: 1em;
}

.carousel-rating-number {
  font-weight: bold;
  color: #333;
  font-size: 1em;
}

.carousel-card-content {
  flex: 1;
  margin-bottom: 15px;
}

.carousel-review-excerpt {
  font-size: 0.9em;
  line-height: 1.6;
  color: #555;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.carousel-card-footer {
  margin-top: auto;
}

.carousel-btn-detail {
  width: 100%;
  padding: 10px;
  background: #fff;
  border: 1px solid #ff4455;
  border-radius: 4px;
  color: #ff4455;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.carousel-btn-detail:hover {
  background: #ff4455;
  color: #fff;
}

.carousel-more-button-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.carousel-btn-more {
  min-width: 200px;
  padding: 15px 30px;
  background: #ff4455;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 2px 8px rgba(255, 68, 85, 0.2);
}

.carousel-btn-more:hover {
  background: #dd2233;
}

/* Review Modal */
.review-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  /* モバイルでのタップ遅延を防止 */
  touch-action: manipulation;
}

.review-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.review-modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  max-width: 800px;
  max-height: 90vh;
  width: 90%;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.review-modal-close {
  position: sticky;
  top: 10px;
  left: calc(100% - 50px);
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  border-radius: 50%;
  font-size: 28px;
  line-height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 10002;
  color: #fff;
  font-weight: normal;
  padding: 0;
  margin: 10px 10px 0 auto;
  text-align: center;
  box-sizing: border-box;
}

.review-modal-close:hover {
  background: rgba(0, 0, 0, 0.5);
}

.review-modal-body {
  padding: 20px 30px 30px;
}

.review-modal-body .review-item {
  border-bottom: none;
  margin-bottom: 0;
}

/* Responsive */
@media (max-width: 600px) {
  .custom-reviews-container {
    padding: 15px 5px;
  }
  
  .review-modal {
    padding: 20px 0;
  }

  .custom-review-form-container {
    padding: 20px 5px;
  }

  .review-item {
    padding: 15px 5px;
  }

  .reviews-filters {
    padding: 12px 10px;
  }

  .reviews-summary {
    flex-direction: column;
    text-align: center;
  }

  .average-ratings {
    grid-template-columns: 1fr;
  }

  .review-header {
    flex-direction: row;
    align-items: flex-start;
  }

  .reviewer-avatar {
    margin-right: 10px;
    flex-shrink: 0;
  }

  .reviewer-avatar img,
  .reviewer-avatar .avatar-placeholder {
    width: 40px;
    height: 40px;
  }

  .avatar-placeholder {
    font-size: 1em;
  }

  .reviewer-meta-container {
    margin-top: 8px;
  }

  .reviewer-meta {
    font-size: 0.8em;
    padding: 2px 6px;
    margin-right: 4px;
    margin-top: 3px;
  }

  .detailed-ratings {
    grid-template-columns: 1fr;
  }

  .item-rating-header .label {
    min-width: 100px;
    font-size: 0.85em;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  /* Carousel responsive */
  .custom-review-carousel {
    margin: 20px 0;
  }
  
  .review-carousel-items {
    padding: 10px 10px 20px 10px;
  }
  
  .review-carousel-card {
    flex: 0 0 260px;
    padding: 15px;
    min-height: 220px;
  }
  
  .carousel-card-header {
    gap: 10px;
  }
  
  .carousel-reviewer-avatar img,
  .carousel-avatar-placeholder {
    width: 40px;
    height: 40px;
    font-size: 1em;
  }
  
  .carousel-reviewer-name {
    font-size: 0.85em;
  }
  
  .meta-badge {
    font-size: 0.7em;
    padding: 2px 6px;
  }

  .review-modal-content {
    width: 95%;
    max-height: 85vh;
    margin: auto;
  }
  
  .review-modal-close {
    top: 8px;
    left: calc(100% - 44px);
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    max-width: 36px;
    max-height: 36px;
    font-size: 24px;
    line-height: 36px;
    margin: 8px 8px 0 auto;
    background: rgba(0, 0, 0, 0.3);
  }
  
  .review-modal-close:hover {
    background: rgba(0, 0, 0, 0.5);
  }

  .review-modal-body {
    padding: 15px;
  }

  .carousel-btn-more {
    min-width: auto;
    width: 100%;
  }
}
