/**
 * MenuMicro Portal - CSS do Sistema de Avaliações
 * Arquivo: assets/css/rating.css
 * Descrição: Estilos completos para o sistema de ratings e comentários
 * Compatibilidade: CSS3 / Flexbox / Grid / Responsive Design
 * Versão: 1.0.1 - CORRIGIDA
 */

/* ============================================================================
   RESET E VARIÁVEIS CSS
   ============================================================================ */

:root {
  --rating-primary: #f59e0b;
  --rating-primary-dark: #d97706;
  --rating-secondary: #3b82f6;
  --rating-success: #10b981;
  --rating-danger: #ef4444;
  --rating-warning: #f59e0b;
  --rating-info: #06b6d4;

  --rating-star-color: #fbbf24;
  --rating-star-empty: #d1d5db;
  --rating-star-hover: #f59e0b;

  --rating-text-dark: #1f2937;
  --rating-text-medium: #6b7280;
  --rating-text-light: #9ca3af;

  --rating-bg-light: #f8fafc;
  --rating-bg-white: #ffffff;
  --rating-border: #e5e7eb;
  --rating-border-focus: #3b82f6;

  --rating-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --rating-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --rating-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --rating-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  --rating-radius-sm: 6px;
  --rating-radius: 8px;
  --rating-radius-lg: 12px;
  --rating-radius-xl: 16px;
  --rating-radius-full: 9999px;

  --rating-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --rating-transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   COMPONENTES DE ESTRELAS - VERSÃO CORRIGIDA
   ============================================================================ */

/* Container das estrelas de exibição */
.rating-display {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-family: inherit;
}

.rating-display .stars-container {
  display: inline-flex;
  gap: 0.1rem;
  line-height: 1;
}

.rating-display .rating-text {
  margin-left: 0.5rem;
  color: var(--rating-text-medium);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Estrelas interativas para formulários - VERSÃO CORRIGIDA */
.interactive-stars {
  margin-bottom: 1rem;
}

.interactive-stars label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--rating-text-dark);
  font-size: 1rem;
}

.star-rating-input {
  display: flex;
  gap: 0.2rem;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  user-select: none;
  position: relative;
}

.star-input {
  cursor: pointer !important;
  color: var(--rating-star-empty) !important;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
  line-height: 1;
  display: inline-block;
  position: relative;
  font-size: inherit !important;
  z-index: 1;
}

/* Estados das estrelas - VERSÃO CORRIGIDA */
.star-input.active {
  color: var(--rating-star-color) !important;
}

.star-input.preview {
  color: var(--rating-star-hover) !important;
  transform: scale(1.05) !important;
}

/* Hover behavior corrigido */
.star-rating-input:not(:hover) .star-input.active {
  color: var(--rating-star-color) !important;
}

.star-rating-input:hover .star-input {
  color: var(--rating-star-empty) !important;
  transform: scale(1) !important;
}

.star-rating-input:hover .star-input.preview {
  color: var(--rating-star-hover) !important;
  transform: scale(1.05) !important;
}

/* Estados de erro para o container de estrelas */
.star-rating-input.error {
  animation: shake 0.5s ease-in-out;
}

.star-rating-input.error .star-input {
  color: var(--rating-danger) !important;
}

/* Label atual da avaliação */
.current-rating-label {
  display: none;
  font-size: 0.9rem;
  color: var(--rating-primary);
  font-weight: 600;
  margin-top: 0.5rem;
  text-align: center;
}

/* Erro de rating */
.rating-error {
  color: var(--rating-danger);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  display: none;
  text-align: center;
  animation: fadeInUp 0.3s ease-out;
}

.rating-error.show {
  display: block;
}

/* Labels das estrelas */
.rating-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--rating-text-light);
  margin-bottom: 1rem;
  user-select: none;
}

/* Animação para estrelas ativas */
.star-input.active {
  animation: starActivate 0.3s ease-out;
}

@keyframes starActivate {
  0% {
    transform: scale(1);
    color: var(--rating-star-empty);
  }
  50% {
    transform: scale(1.2);
    color: var(--rating-star-hover);
  }
  100% {
    transform: scale(1);
    color: var(--rating-star-color);
  }
}
/* ============================================================================
   FORMULÁRIO DE AVALIAÇÃO
   ============================================================================ */

.rating-form-container {
  background: var(--rating-bg-light);
  padding: 2rem;
  border-radius: var(--rating-radius-xl);
  margin: 2rem 0;
  border: 1px solid var(--rating-border);
  box-shadow: var(--rating-shadow);
  transition: var(--rating-transition);
  position: relative;
  overflow: hidden;
}

.rating-form-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--rating-primary),
    var(--rating-secondary)
  );
  border-radius: var(--rating-radius-xl) var(--rating-radius-xl) 0 0;
}

.rating-form-container:hover {
  box-shadow: var(--rating-shadow-lg);
  transform: translateY(-2px);
}

.rating-form-container h3 {
  color: var(--rating-primary);
  margin-bottom: 0.5rem;
  font-family: "Poppins", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rating-form-container p {
  color: var(--rating-text-medium);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Campos do formulário */
.user-info-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.field-group {
  position: relative;
}

.field-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--rating-text-dark);
  font-size: 0.95rem;
}

.field-group input,
.field-group textarea {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid var(--rating-border);
  border-radius: var(--rating-radius);
  font-size: 1rem;
  transition: var(--rating-transition);
  font-family: inherit;
  background: var(--rating-bg-white);
}

.field-group input:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--rating-border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.field-group input:hover,
.field-group textarea:hover {
  border-color: var(--rating-text-medium);
}

.field-group input.error,
.field-group textarea.error {
  border-color: var(--rating-danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Campo de comentário específico */
.comment-field {
  margin-bottom: 1rem;
}

.comment-field textarea {
  resize: vertical;
  min-height: 100px;
  max-height: 300px;
}

.char-counter {
  text-align: right;
  font-size: 0.8rem;
  color: var(--rating-text-light);
  margin-top: 0.3rem;
  transition: var(--rating-transition-fast);
}

.char-counter.warning {
  color: var(--rating-warning);
}

.char-counter.danger {
  color: var(--rating-danger);
  font-weight: 600;
}

/* Mensagens de erro dos campos */
.field-error {
  color: var(--rating-danger);
  font-size: 0.9rem;
  margin-top: 0.3rem;
  display: none;
  animation: fadeInUp 0.3s ease-out;
}

.field-error.show {
  display: block;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Ações do formulário */
.form-actions {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.submit-btn {
  background: var(--rating-primary);
  color: white;
  padding: 0.8rem 2rem;
  border: none;
  border-radius: var(--rating-radius-full);
  font-weight: 600;
  cursor: pointer;
  transition: var(--rating-transition);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--rating-shadow);
  position: relative;
  overflow: hidden;
}

.submit-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.submit-btn:hover {
  background: var(--rating-primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--rating-shadow-lg);
}

.submit-btn:hover::before {
  left: 100%;
}

.submit-btn:active {
  transform: translateY(0);
  box-shadow: var(--rating-shadow);
}

.submit-btn:disabled {
  background: var(--rating-text-light);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.loading-spinner {
  display: none;
  align-items: center;
  gap: 0.5rem;
  color: var(--rating-primary);
  font-size: 0.9rem;
}

.loading-spinner i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Nota de privacidade */
.privacy-note {
  background: #eff6ff;
  border-left: 4px solid var(--rating-info);
  padding: 1rem;
  border-radius: var(--rating-radius);
  margin-top: 1.5rem;
  font-size: 0.9rem;
}

.privacy-note div {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: #1e40af;
  line-height: 1.5;
}

/* ============================================================================
   SEÇÃO DE COMENTÁRIOS
   ============================================================================ */

.comments-section {
  margin: 2rem 0;
}

.comments-section h3 {
  color: var(--rating-primary);
  margin-bottom: 1.5rem;
  font-family: "Poppins", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.empty-comments {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--rating-text-light);
  background: var(--rating-bg-light);
  border-radius: var(--rating-radius-lg);
  border: 2px dashed var(--rating-border);
  transition: var(--rating-transition);
}

.empty-comments:hover {
  border-color: var(--rating-text-medium);
  background: var(--rating-bg-white);
}

.empty-comments i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
  display: block;
}

.empty-comments p {
  font-size: 1.1rem;
  margin: 0;
}

/* Lista de comentários */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comment-item {
  background: var(--rating-bg-white);
  border: 1px solid var(--rating-border);
  padding: 1.5rem;
  border-radius: var(--rating-radius-lg);
  transition: var(--rating-transition);
  position: relative;
  overflow: hidden;
}

.comment-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--rating-primary);
  transform: scaleY(0);
  transition: var(--rating-transition);
  transform-origin: top;
}

.comment-item:hover {
  box-shadow: var(--rating-shadow-lg);
  transform: translateY(-2px);
}

.comment-item:hover::before {
  transform: scaleY(1);
}

/* Cabeçalho do comentário */
.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.comment-author strong {
  color: var(--rating-primary);
  font-size: 1rem;
  font-weight: 600;
}

.comment-author time {
  color: var(--rating-text-light);
  font-size: 0.9rem;
}

.comment-rating {
  color: var(--rating-star-color);
  font-size: 1rem;
  letter-spacing: 0.1rem;
  white-space: nowrap;
}

/* Conteúdo do comentário */
.comment-content {
  color: var(--rating-text-dark);
  line-height: 1.7;
  margin-bottom: 1rem;
  font-size: 1rem;
  word-wrap: break-word;
}

/* Ações do comentário */
.comment-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #f3f4f6;
  flex-wrap: wrap;
}

.helpful-btn {
  background: none;
  border: 1px solid var(--rating-border);
  color: var(--rating-text-medium);
  padding: 0.4rem 0.8rem;
  border-radius: var(--rating-radius-full);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--rating-transition);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: inherit;
}

.helpful-btn:hover {
  background: #f3f4f6;
  border-color: var(--rating-text-medium);
  color: var(--rating-text-dark);
  transform: translateY(-1px);
}

.helpful-btn.voted {
  background: #dbeafe;
  border-color: var(--rating-secondary);
  color: #1e40af;
  cursor: default;
}

.helpful-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Botão carregar mais */
.load-more-comments {
  text-align: center;
  margin-top: 2rem;
}

.load-more-btn {
  background: var(--rating-primary);
  color: white;
  padding: 0.8rem 2rem;
  border: none;
  border-radius: var(--rating-radius-full);
  font-weight: 600;
  cursor: pointer;
  transition: var(--rating-transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.load-more-btn:hover {
  background: var(--rating-primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--rating-shadow-lg);
}
/* ============================================================================
   WIDGETS E ESTATÍSTICAS
   ============================================================================ */

.section-stats-widget {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left: 4px solid var(--rating-info);
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: var(--rating-radius-lg);
  box-shadow: var(--rating-shadow);
  transition: var(--rating-transition);
}

.section-stats-widget:hover {
  box-shadow: var(--rating-shadow-lg);
  transform: translateY(-2px);
}

.section-stats-widget h4 {
  color: #1e40af;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-item {
  text-align: center;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--rating-radius);
  transition: var(--rating-transition);
}

.stat-item:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: scale(1.05);
}

.stat-item > div:first-child {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 0.2rem;
}

.stat-item > div:last-child {
  font-size: 0.9rem;
  color: #64748b;
}

/* Widget de top artigos */
.top-rated-widget {
  background: var(--rating-bg-white);
  border: 1px solid var(--rating-border);
  padding: 1.5rem;
  border-radius: var(--rating-radius-lg);
  margin: 1rem 0;
  box-shadow: var(--rating-shadow);
}

.top-rated-widget h4 {
  color: var(--rating-primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.top-articles-list {
  display: flex;
  flex-direction: column;
}

.top-article-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid #f3f4f6;
  transition: var(--rating-transition);
}

.top-article-item:hover {
  background: var(--rating-bg-light);
  padding-left: 0.5rem;
  margin-left: -0.5rem;
  margin-right: -0.5rem;
  border-radius: var(--rating-radius);
}

.top-article-item:last-child {
  border-bottom: none;
}

.top-article-item .rank {
  background: var(--rating-primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.top-article-item .article-info {
  flex: 1;
  min-width: 0;
}

.top-article-item .article-info a {
  color: var(--rating-text-dark);
  text-decoration: none;
  font-weight: 600;
  transition: var(--rating-transition);
}

.top-article-item .article-info a:hover {
  color: var(--rating-primary);
}

/* ============================================================================
   MENSAGENS DE FEEDBACK
   ============================================================================ */

.form-message {
  margin-top: 1rem;
  border-radius: var(--rating-radius);
  padding: 1rem;
  display: none;
  animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.success-message {
  background: #d1fae5 !important;
  color: #065f46 !important;
  border: 1px solid #a7f3d0 !important;
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
}

.error-message {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border: 1px solid #fecaca !important;
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
}

.success-message i {
  color: #10b981;
}

.error-message i {
  color: #ef4444;
}

/* ============================================================================
   RESPONSIVIDADE
   ============================================================================ */

@media (max-width: 768px) {
  .rating-form-container {
    padding: 1.5rem;
    margin: 1.5rem 0;
  }

  .rating-form-container h3 {
    font-size: 1.2rem;
  }

  .user-info-fields {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }

  .star-rating-input {
    font-size: 1.6rem;
    justify-content: center;
  }

  .comment-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .comment-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .form-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .submit-btn {
    width: 100%;
    justify-content: center;
  }

  .top-article-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    text-align: left;
  }

  .top-article-item .rank {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .rating-form-container {
    padding: 1rem;
    margin: 1rem 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .star-rating-input {
    font-size: 1.4rem;
  }

  .rating-labels {
    font-size: 0.7rem;
  }
}

/* ============================================================================
   MODO ESCURO (OPCIONAL)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --rating-text-dark: #f9fafb;
    --rating-text-medium: #d1d5db;
    --rating-text-light: #9ca3af;
    --rating-bg-light: #1f2937;
    --rating-bg-white: #111827;
    --rating-border: #374151;
    --rating-border-focus: #60a5fa;
  }

  .rating-form-container {
    background: var(--rating-bg-white);
    border-color: var(--rating-border);
  }

  .comment-item {
    background: var(--rating-bg-white);
    border-color: var(--rating-border);
  }

  .field-group input,
  .field-group textarea {
    background: var(--rating-bg-light);
    border-color: var(--rating-border);
    color: var(--rating-text-dark);
  }

  .privacy-note {
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
  }

  .section-stats-widget {
    background: linear-gradient(
      135deg,
      rgba(59, 130, 246, 0.1) 0%,
      rgba(59, 130, 246, 0.05) 100%
    );
  }
}

/* ============================================================================
   ANIMAÇÕES E EFEITOS
   ============================================================================ */

.rating-form-container,
.comment-item,
.section-stats-widget {
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Efeito de digitação no textarea */
.field-group textarea:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1),
    0 0 20px rgba(59, 130, 246, 0.1);
}

/* Pulse effect para estrelas ativas */
.star-input.active {
  animation: starPulse 0.3s ease-out;
}

@keyframes starPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  .rating-form-container,
  .comment-actions,
  .load-more-comments {
    display: none !important;
  }

  .comment-item {
    box-shadow: none !important;
    border: 1px solid #000 !important;
    break-inside: avoid;
  }

  .stars-container {
    color: #000 !important;
  }
}

/* ============================================================================
   CORREÇÕES FINAIS E OVERRIDES
   ============================================================================ */

/* Garantir que as estrelas funcionem corretamente */
.star-rating-input .star-input {
  position: relative !important;
  z-index: 1 !important;
}

/* Remover qualquer conflito de hover antigo */
.star-rating-input .star-input:nth-child(n) {
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Garantir estados corretos */
.star-rating-input:not(:hover) .star-input.active {
  color: var(--rating-star-color) !important;
  transform: scale(1) !important;
}

/* Reset completo de hover para evitar conflitos */
.star-rating-input:hover .star-input:not(.preview) {
  color: var(--rating-star-empty) !important;
  transform: scale(1) !important;
}

/* Estados finais das estrelas */
.star-input.preview {
  color: var(--rating-star-hover) !important;
  transform: scale(1.05) !important;
}

.star-input.active:not(.preview) {
  color: var(--rating-star-color) !important;
}

/* Animação suave para transições */
.star-input {
  transition: color 0.15s ease, transform 0.15s ease !important;
}

/* Override final para garantir funcionamento */
.star-rating-input {
  isolation: isolate;
}

.star-rating-input .star-input {
  will-change: color, transform;
}
