/* =========================================================
   COMMENTS - CSS OPTIMIZADO (Bootstrap 3 friendly)
   - Composer moderno
   - Tabs segmentados
   - Encuesta visual + MAYÚSCULAS
   - Resultados encuesta: separación + % compacto
   - Tiempo del comentario abajo derecha (flujo normal)
   - Respuestas chat (flecha izquierda) + degradado (normal/validada)
   - Botón borrar overlay (comentario y respuestas)
========================================================= */


/* =========================
   Layout general
========================= */
.comments{
  width: 100%;
  margin: 14px auto;
}

.comentarios{
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  flex-direction: row;
  align-items: baseline;
  word-break: break-word;
}

@media (max-width: 620px){
  .comentarios{ flex-direction: column; gap: 12px; }
  .comentario{ width: 100% !important; }
}


/* =========================
   Composer (escribir comentario)
========================= */
.comentar{
  display: flex;
  flex-direction: column;
  position: relative;
  justify-content: space-between;

  border: 1px solid #e9e9e9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,.06);
  overflow: hidden;
}

.comentar #comentario{
  width: 100%;
  height: 110px;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  outline: none;

  padding: 14px 14px 12px;
  font-size: 15px;
  line-height: 1.35;
  color: #676767;
  resize: none;
}

.comentar #comentario::placeholder{ color: #9a9a9a; }
.comentar #comentario:focus::placeholder{ opacity: .5; }

.comment-footer{
  height: auto;
  padding: 10px 12px;
  gap: 10px;

  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.comment-footer > div{
  display: flex;
  gap: 10px;
  align-items: center;
}

.comentar .contador{
  color: #666;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f6f6f6;
}

.contador.maxcaracteres{ color: red; }

/* Botones generales */
button.btn{
  outline: none !important;
  border-radius: 999px !important;
  height: 38px;
  padding: 0 14px;

  font-weight: 700;
  font-size: 13px;
  letter-spacing: .2px;
}

.btn.btn-success{
  box-shadow: 0 8px 18px rgba(92,184,92,.25);
}


/* =========================
   Encuesta (inputs crear encuesta)
========================= */
.encuesta{
  padding: 0 15px;
  display: none;
  position: relative;
}

.encuesta input{
  margin: 7px 0;
  width: 90%;
  font-size: 15px;
}

.addOption{
  position: absolute;
  bottom: 2px;
  left: 90%;
  cursor: pointer;
  opacity: .6;
  font-size: 20px;
}
.addOption:hover, .addOption:active{ opacity: 1; }


/* =========================
   Tabs segmentados
========================= */
.nav.nav-pills.nav-navegacion{
  display: flex;
  gap: 10px;
  background: #f4f4f4;
  padding: 6px;
  border-radius: 14px;
}

.nav.nav-pills.nav-navegacion > li{
  float: none;
  flex: 1;
}

.nav.nav-pills.nav-navegacion > li > a{
  text-align: center;
  border-radius: 12px;
  margin: 0 !important;
  border: 0 !important;
  background: transparent;
  font-weight: 700;
}

.nav.nav-pills.nav-navegacion > li.active > a,
.nav.nav-pills.nav-navegacion > li.active > a:hover,
.nav.nav-pills.nav-navegacion > li.active > a:focus{
  background: #1aa64a;
  color: #fff;
}


/* =========================
   Card de comentario
========================= */
.comentario{
  position: relative;
  width: 49%;
  margin-bottom: 16px;

  border-radius: 16px;
  background: #fff;
  box-shadow: 10px 12px 58px 10px rgba(0,0,0,.08);
  overflow: hidden;
}

/* Texto del comentario */
.comentario > p{
  padding: 12px 14px 30px;
  font-size: 15px;
  line-height: 1.35;
  margin: 0;
}


/* =========================
   Botón borrar overlay (comentario y respuestas)
   HTML requerido:
   <button class="comment-action modcomment" data-id=".."><img ...></button>
========================= */
.comment-action.modcomment{
  position: absolute;
  top: 10px;
  right: 10px;

  border: 0;
  width: 34px;
  height: 34px;
  border-radius: 999px;

  background: rgba(0,0,0,.04);
  box-shadow: none;

  display: flex;
  align-items: center;
  justify-content: center;

  opacity: .9;
  cursor: pointer;
}

.comment-action.modcomment:hover{
  opacity: 1;
  background: rgba(0,0,0,.08);
}

.comment-action.modcomment img{
  width: 16px;
  height: 16px;
  display: block;
  opacity: .75;
}


/* =========================
   Encuesta (votación + resultados)
========================= */
.separator{
  position: relative;
  text-align: center;
  margin-top: 0;
  padding: 0 14px;
}

.separator hr{
  border: 0;
  border-top: 1px solid #f0f0f0;
  margin: 0;
  padding: 0;
}

span.vota{
  position: relative;
  top: -14px;

  padding: 6px 10px;
  border: 0;
  font-size: 14px;

  background: #fff;
  color: #777;
  font-weight: bold;

  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
}

/* Botones votar (antes de votar) */
.votar{
  padding: 0 15px;
}

.votar button{
    background: #fff;
    width: 100%;
    display: block;
    margin: 6px 0;

    padding: 10px 12px;
    font-weight: 700;
    border: 2px solid transparent !important;
    background: linear-gradient(#fff, #fff) padding-box, /* Fondo interior (ajusta el color) */ linear-gradient(to right, #41df00, #4a90e2) border-box;

}

.votar button:hover, .votar button:focus{ background: #f2fff6; }

.votar > ul, .votar > ul > li{
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Resultados votados: separación + % compacto */
.votar ul li.opt-voted{
  position: relative;
  height: 40px;
  margin: 4px 0;
  font-size: 12px;
}

.opt-voted .barra{
  position: absolute;
  left: 0;
  top: 0;
  height: 40px;
  display: block;

  /* base gris “premium” */
  background: linear-gradient(90deg, #eeeeee 0%, #f7f7f7 100%);
  border-radius: 14px;

  z-index: 1;
}

/* Si el backend pinta inline background, no lo rompemos */
.opt-voted .barra[style*="background"]{
  border-radius: 14px;
}

.opt-voted .opt{
  z-index: 2;
  position: absolute;
  left: 10px;
  right: 10px;
  top: 0;

  line-height: 40px;
  color: #111 !important;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  font-size: 12.5px;
}

/* % compacto (sin “círculos”) */
.opt-voted .opt strong{
  display: inline-block;
  padding: 2px 7px;
  margin-right: 8px;

  border-radius: 999px;
  background: rgba(255,255,255,.85);

  font-weight: 900;
  min-width: 0;
  line-height: 1.2;
}

/* MAYÚSCULAS SIEMPRE (antes y después de votar) */
.votar button,
.opt,
.opt-voted .opt{
  text-transform: uppercase;
  letter-spacing: .35px;
}

@media (max-width: 620px){
  .votar ul li.opt-voted{ height: 38px; margin: 10px 0; }
  .opt-voted .barra{ height: 38px; border-radius: 13px; }
  .opt-voted .opt{ line-height: 38px; font-size: 12px; }
}


/* =========================
   Tiempo del comentario (abajo derecha)
   En flujo normal => debajo de encuesta si existe
========================= */
.time{
  padding: 8px 14px 10px;
  text-align: right;
  display: block;
  color: #848484;
  font-size: 12px;
}

.time .ptime{
  display: inline-block;
  font-size: 12px;
  background: #f5f5f5;
  color: #666;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}


/* =========================
   Caja de responder
========================= */
.respuesta-box{
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #f0f0f0;
}

.respuesta{
  position: relative;
}

.respuesta input{
  font-size: 15px;
  height: 40px;
  border-radius: 12px;
}

.txt-respuesta{ padding-right: 40px; }

.btn-responder{
  background: transparent;
  border: none;
  cursor: pointer;

  position: absolute;
  top: 0;
  right: 0;

  width: 40px;
  height: 40px !important;
  border-radius: 12px;
}

.txt-respuesta:active + .btn-responder,
.txt-respuesta:focus + .btn-responder,
.btn-responder:hover,
.btn-responder:focus{
  color: #66afe9 !important;
}


/* =========================
   Respuestas (chat bubble izquierda)
========================= */
.crespuesta{
  position: relative;
  padding: 12px 44px 10px 14px;
  margin: 5px 0;
  margin-left: 12px;

  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.06);

  /* degradado suave */
  background: linear-gradient(135deg, #fffdf2 0%, #ffffff 70%);
}

/* Flecha izquierda (normal) */
.crespuesta::after{
  content: "";
  position: absolute;
  left: -6px;
  top: 18px;
  width: 12px;
  height: 12px;

  background: #fffdf2; /* coincide con el inicio del degradado */
  border-left: 1px solid rgba(0,0,0,.06);
  border-bottom: 1px solid rgba(0,0,0,.06);

  transform: rotate(45deg);
  z-index: 2;
}

/* Texto respuesta */
.crespuesta > p{
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  color: #111;

  display: flex;
  align-items: center;
  gap: 8px;
}

.crespuesta > p img{
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: inline-block;
}

.crespuesta .time-respuesta{
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  color: rgba(0,0,0,.55);
}

/* Validada: verde suave + flecha del mismo color */
.crespuesta.validada{
  background: #ecfff4;
  border-color: rgba(26,166,74,.18);
}

.crespuesta.validada::after{
  background: #ecfff4;
}

/* Botón borrar dentro de respuesta (más pequeño) */
.crespuesta .comment-action.modcomment{
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
}
.crespuesta .comment-action.modcomment img{
  width: 14px;
  height: 14px;
}

/* Quitar cualquier barra verde antigua */
.crespuesta.validada::before{
  display: none !important;
}

@media (max-width: 620px){
  .respuesta-box{ padding-left: 8px; padding-right: 8px; }
  .crespuesta{ margin-left: 8px; margin-right: 4px; }
}


/* =========================
   Enlaces “ver más”
========================= */
a.ver-mas{
  font-size: 12px;
  margin: 5px 0 0 0;
  color: #999;
}

.ver-mas.nohay{
  cursor: not-allowed;
  text-decoration: none;
}


/* =========================
   Otros
========================= */
.nuevo{ display: none; }
.modcomment{ cursor: pointer; }
.btn.btn-votar img{ width: 19px; }


/* =========================
   MOBILE - Composer en UNA SOLA FILA
========================= */
@media (max-width: 620px){

  .comment-footer{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 10px 12px;
    flex-wrap: nowrap;              /* 🔑 una sola fila */
  }

  /* Todos los botones compactos */
  .comment-footer .btn{
    height: 34px;
    padding: 0 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* AÑADIR ENCUESTA más discreto */
  .comment-footer .btn-primary{
    font-weight: 700;
    padding: 0 12px;
  }

  /* LIMPIAR aún más compacto */
  .comment-footer .btn-default{
    padding: 0 10px;
  }

  /* PUBLICAR ligeramente protagonista */
  .comment-footer .btn-success{
    padding: 0 14px;
  }

  /* Contador como pill pequeño */
  .comment-footer .contador{
    font-size: 11px;
    padding: 4px 8px;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* =========================================================
   Entrada y panel lateral de comentarios
   Desktop: ventana flotante a la derecha
   Mobile: modal a pantalla completa
========================================================= */
.comments-entry{
  clear: both;
  margin: 32px 0 30px;
  padding: 0;
}

.comments-launcher{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 264px;
  min-height: 54px;
  padding: 0 26px;
  border: 1px solid #b9b9b9;
  background: #fff;
  color: #8f8f8f;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .7px;
  text-transform: uppercase;
  box-shadow: none;
  border-radius: 0;
  transition: border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.comments-launcher:hover,
.comments-launcher:focus{
  color: #222;
  border-color: #777;
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
  transform: translateY(-1px);
  outline: none;
}

.comments-launcher__loading{ display: none; }
.comments-launcher.is-loading .comments-launcher__idle{ display: none; }
.comments-launcher.is-loading .comments-launcher__loading{ display: inline-flex; gap: 8px; align-items: center; }

.comments-panel-backdrop{
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: rgba(0,0,0,.42);
  opacity: 0;
  visibility: hidden;
  transition: opacity .24s ease, visibility .24s ease;
}

.comments-panel{
  position: fixed;
  top: 0;
  right: 0;
  z-index: 9998;
  width: 500px;
  max-width: 92vw;
  height: 100vh;
  background: #fff;
  color: #222;
  box-shadow: -22px 0 60px rgba(0,0,0,.20);
  transform: translateX(105%);
  transition: transform .28s ease;
  display: flex;
  flex-direction: column;
}

body.comments-panel-open{ overflow: hidden; }
body.comments-panel-open .comments-panel-backdrop{
  opacity: 1;
  visibility: visible;
}
body.comments-panel-open .comments-panel{ transform: translateX(0); }

.comments-panel__header{
  flex: 0 0 auto;
  min-height: 72px;
  padding: 16px 58px 14px 18px;
  border-bottom: 1px solid #eeeeee;
  background: #ffffff;
  position: relative;
}

.comments-panel__title{
  font-size: 21px;
  line-height: 1.1;
  font-weight: 900;
  color: #111;
}

.comments-panel__subtitle{
  margin-top: 4px;
  color: #858585;
  font-size: 13px;
  font-weight: 700;
}

.comments-panel__close{
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 16px;
  z-index: 10005;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: #111;
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0,0,0,.24);
  opacity: 1;
  visibility: visible;
  -webkit-appearance: none;
  appearance: none;
}

.comments-panel__close-x{
  display: block;
  font-size: 34px;
  line-height: 44px;
  font-weight: 300;
  color: #fff !important;
  transform: translateY(-1px);
}

.comments-panel__close:hover,
.comments-panel__close:focus{
  background: #000;
  color: #fff !important;
  outline: none;
}
.comments-panel__loading{
  padding: 18px;
  text-align: center;
  color: #21923e;
  font-weight: 800;
}

.comments-panel__body{
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.comments-panel .comments{
  margin: 0;
}

.comments-panel .comments > .row,
.comments-panel .comments > .row > [class*="col-"]{
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

.comments-panel .comentarios{
  display: block;
}

.comments-panel .comentario{
  width: 100% !important;
}

@media (max-width: 767px){
  .comments-entry{
    margin: 26px 0 26px;
  }

  .comments-launcher{
    min-width: 0;
    width: auto;
    max-width: 100%;
    min-height: 52px;
    padding: 0 22px;
    font-size: 14px;
  }

  .comments-panel-backdrop{
    background: rgba(0,0,0,.55);
  }

  .comments-panel{
    width: 100vw;
    max-width: none;
    height: 100dvh;
    left: 0;
    right: 0;
    transform: translateY(105%);
    box-shadow: none;
  }

  body.comments-panel-open .comments-panel{ transform: translateY(0); }

  .comments-panel__header{
    min-height: 66px;
    padding: 14px 58px 12px 15px;
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .comments-panel__title{
    font-size: 19px;
  }

  .comments-panel__body{
    padding: 13px 12px 18px;
  }

  .comments-panel__header{
    padding-right: 76px;
  }

  .comments-panel__close{
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    right: 12px;
    width: 48px;
    height: 48px;
  }
}


/* =========================
   Selector de emojis
   - Picker global para evitar cortes por overflow
   - Botón del comentario principal en la misma fila de PUBLICAR
========================= */
.emoji-toolbar{
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  background: transparent;
}

.emoji-toolbar--comment{
  margin-right: 2px;
}

.emoji-trigger{
  border: 1px solid #e7e7e7;
  background: #f8f8f8;
  color: #333;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  -webkit-appearance: none;
  appearance: none;
}

.emoji-trigger:hover,
.emoji-trigger:focus{
  background: #fff;
  border-color: #d2d2d2;
  outline: none;
}

.emoji-picker{
  display: none;
  position: fixed;
  z-index: 100060;
  left: 0;
  top: 0;
  width: 316px;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  padding: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 14px;
  box-shadow: 0 14px 35px rgba(0,0,0,.22);
}

.emoji-picker.is-open{
  display: grid;
}

.emoji-option{
  border: 0;
  background: #f7f7f7;
  width: 100%;
  height: 42px;
  min-width: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 23px;
  line-height: 1;
  text-align: center;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  appearance: none;
}

.emoji-option span{
  display: block;
  line-height: 1;
  transform: translateY(1px);
  pointer-events: none;
}

.emoji-option:hover,
.emoji-option:focus{
  background: #eeeeee;
  outline: none;
}

.respuesta .emoji-trigger--reply{
  position: absolute;
  left: 4px;
  top: 2px;
  z-index: 2;
  width: 40px;
  height: 40px;
  box-shadow: none;
  background: transparent;
  border-color: transparent;
}

.respuesta .emoji-trigger--reply:hover,
.respuesta .emoji-trigger--reply:focus{
  background: #f1f1f1;
  border-color: #e5e5e5;
}

.respuesta input,
.txt-respuesta{
  padding-left: 50px !important;
  padding-right: 42px !important;
}

@media (max-width: 620px){
  .emoji-toolbar--comment{
    margin-right: 0;
  }

  .emoji-trigger{
    width: 38px;
    height: 38px;
    font-size: 19px;
  }

  .respuesta .emoji-trigger--reply{
    width: 38px;
    height: 38px;
  }

  .respuesta input,
  .txt-respuesta{
    padding-left: 48px !important;
  }
}

@media (max-width: 420px){
  .emoji-picker{
    width: calc(100vw - 24px);
    padding: 8px;
    gap: 6px;
  }

  .emoji-option{
    height: 40px;
    font-size: 22px;
  }
}
