/* ==========================================================================
   Sistema de comentarios — tema oscuro
   Paleta alineada con style.css (--color-principal: #ff6262, fondo #121212)
   ========================================================================== */

.cmt-wrap {
    --cmt-superficie: #17191c;
    --cmt-superficie-2: #1d2024;
    --cmt-borde: rgba(255, 255, 255, 0.07);
    --cmt-borde-fuerte: rgba(255, 255, 255, 0.14);
    --cmt-texto: #e9eaec;
    --cmt-texto-suave: #9aa0a6;
    --cmt-acento: var(--color-principal, #ff6262);
    --cmt-radio: 14px;

    margin: 3.5rem 0 2rem;
    color: var(--cmt-texto);
    scroll-margin-top: 90px;
}

/* --- Cabecera ------------------------------------------------------------ */

.cmt-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--cmt-borde);
    margin-bottom: 1.25rem;
}

.cmt-titulo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
}

.cmt-titulo svg {
    color: var(--cmt-acento);
}

.cmt-total {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--cmt-texto-suave);
    background: var(--cmt-superficie-2);
    border: 1px solid var(--cmt-borde);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    line-height: 1.5;
}

.cmt-orden {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--cmt-superficie);
    border: 1px solid var(--cmt-borde);
    border-radius: 999px;
}

.cmt-orden-btn {
    background: transparent;
    border: 0;
    color: var(--cmt-texto-suave);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.38rem 0.95rem;
    border-radius: 999px;
    cursor: pointer;
    transition: color 150ms ease, background-color 150ms ease;
}

.cmt-orden-btn:hover {
    color: #fff;
}

.cmt-orden-btn.es-activo {
    background: var(--cmt-superficie-2);
    color: #fff;
    box-shadow: inset 0 0 0 1px var(--cmt-borde-fuerte);
}

/* --- Botón de carga inicial ---------------------------------------------
   El hilo no toca el servidor hasta que se pulsa este botón: mientras no
   esté cargado se esconden el formulario y el selector de orden.
   ----------------------------------------------------------------------- */

.cmt-wrap:not(.es-cargado) .cmt-orden,
.cmt-wrap:not(.es-cargado) .cmt-form,
.cmt-wrap:not(.es-cargado) .cmt-login {
    display: none;
}

.cmt-wrap.es-cargado .cmt-iniciar {
    display: none;
}

.cmt-iniciar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    background: linear-gradient(135deg, rgba(255, 98, 98, 0.09), rgba(255, 255, 255, 0.025));
    border: 1px solid var(--cmt-borde-fuerte);
    border-radius: var(--cmt-radio);
    color: var(--cmt-texto);
    font-size: 0.92rem;
    font-weight: 600;
    padding: 1.05rem 1rem;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, transform 120ms ease;
}

.cmt-iniciar svg {
    color: var(--cmt-acento);
}

.cmt-iniciar:hover {
    border-color: rgba(255, 98, 98, 0.45);
    background: linear-gradient(135deg, rgba(255, 98, 98, 0.14), rgba(255, 255, 255, 0.04));
}

.cmt-iniciar:active {
    transform: scale(0.995);
}

/* --- Avatar generado ---------------------------------------------------- */

.cmt-avatar {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    user-select: none;
    background: linear-gradient(140deg,
            hsl(var(--cmt-hue, 350) 62% 52%),
            hsl(calc(var(--cmt-hue, 350) + 40) 55% 38%));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.cmt-item--respuesta > .cmt-avatar {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
}

/* --- Formulario --------------------------------------------------------- */

.cmt-form {
    display: flex;
    gap: 0.85rem;
    margin-bottom: 1.75rem;
}

.cmt-form-caja {
    flex: 1;
    min-width: 0;
    background: var(--cmt-superficie);
    border: 1px solid var(--cmt-borde);
    border-radius: var(--cmt-radio);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.cmt-form-caja:focus-within {
    border-color: rgba(255, 98, 98, 0.5);
    box-shadow: 0 0 0 3px rgba(255, 98, 98, 0.12);
}

.cmt-input {
    display: block;
    width: 100%;
    min-height: 52px;
    max-height: 260px;
    resize: none;
    overflow-y: auto;
    background: transparent;
    border: 0;
    outline: none;
    color: var(--cmt-texto);
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 0.9rem 1rem 0.35rem;
}

.cmt-input::placeholder {
    color: #6f7378;
}

.cmt-form-pie {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem 0.65rem 0.9rem;
    flex-wrap: wrap;
}

.cmt-form-derecha {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.cmt-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--cmt-texto-suave);
    background: var(--cmt-superficie-2);
    border: 1px solid var(--cmt-borde);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    user-select: none;
    transition: all 150ms ease;
}

.cmt-chip:hover {
    color: #fff;
    border-color: var(--cmt-borde-fuerte);
}

.cmt-chip input {
    appearance: none;
    -webkit-appearance: none;
    width: 0;
    height: 0;
    margin: 0;
    position: absolute;
    opacity: 0;
}

.cmt-chip:has(input:checked) {
    color: #ffd166;
    border-color: rgba(255, 209, 102, 0.45);
    background: rgba(255, 209, 102, 0.1);
}

.cmt-contador {
    font-size: 0.75rem;
    color: #6f7378;
    font-variant-numeric: tabular-nums;
}

.cmt-contador.es-limite {
    color: var(--cmt-acento);
}

.cmt-enviar {
    background: var(--cmt-acento);
    color: #1a1113;
    border: 0;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.5rem 1.15rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: filter 150ms ease, opacity 150ms ease, transform 150ms ease;
}

.cmt-enviar:hover:not(:disabled) {
    filter: brightness(1.1);
    color: #1a1113;
}

.cmt-enviar:active:not(:disabled) {
    transform: scale(0.97);
}

.cmt-enviar:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cmt-btn-ghost {
    background: transparent;
    color: var(--cmt-texto);
    border: 1px solid var(--cmt-borde-fuerte);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1.1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background-color 150ms ease;
}

.cmt-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

/* --- Invitación a iniciar sesión ---------------------------------------- */

.cmt-login {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    background: linear-gradient(135deg, rgba(255, 98, 98, 0.07), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--cmt-borde);
    border-radius: var(--cmt-radio);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.75rem;
}

.cmt-login svg {
    color: var(--cmt-acento);
    flex-shrink: 0;
}

.cmt-login p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--cmt-texto);
}

.cmt-login-btns {
    display: flex;
    gap: 0.6rem;
    margin-left: auto;
}

/* --- Avisos ------------------------------------------------------------- */

.cmt-aviso {
    border-radius: 10px;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.87rem;
    border: 1px solid transparent;
}

.cmt-aviso.es-error {
    background: rgba(255, 98, 98, 0.12);
    border-color: rgba(255, 98, 98, 0.35);
    color: #ff9b9b;
}

.cmt-aviso.es-ok {
    background: rgba(80, 200, 120, 0.12);
    border-color: rgba(80, 200, 120, 0.32);
    color: #86e0a5;
}

/* --- Comentario --------------------------------------------------------- */

.cmt-lista {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.cmt-item {
    display: flex;
    gap: 0.85rem;
    animation: cmt-aparecer 260ms ease both;
}

.cmt-item.es-nuevo > .cmt-body {
    box-shadow: 0 0 0 1px rgba(255, 98, 98, 0.35);
    border-radius: 12px;
}

.cmt-item.es-saliendo {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 220ms ease, transform 220ms ease;
}

@keyframes cmt-aparecer {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.cmt-body {
    flex: 1;
    min-width: 0;
}

.cmt-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
    line-height: 1.3;
}

.cmt-autor {
    font-size: 0.92rem;
    font-weight: 700;
    color: #fff;
}

.cmt-tag {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.4rem;
    border-radius: 5px;
    background: rgba(255, 98, 98, 0.16);
    color: #ff8f8f;
    border: 1px solid rgba(255, 98, 98, 0.3);
}

.cmt-tag--yo {
    background: rgba(255, 255, 255, 0.07);
    color: var(--cmt-texto-suave);
    border-color: var(--cmt-borde);
}

.cmt-sep {
    color: #4d5155;
}

.cmt-fecha {
    font-size: 0.78rem;
    color: var(--cmt-texto-suave);
}

.cmt-texto {
    position: relative;
    font-size: 0.94rem;
    line-height: 1.65;
    color: #d5d7da;
    overflow-wrap: break-word;
    word-break: break-word;
}

.cmt-texto p {
    margin: 0;
}

/* Spoiler: se difumina hasta que el usuario lo revela */
.cmt-spoiler {
    cursor: pointer;
}

.cmt-spoiler p {
    filter: blur(6px);
    opacity: 0.55;
    user-select: none;
    transition: filter 220ms ease, opacity 220ms ease;
}

.cmt-spoiler-aviso {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ffd166;
    margin-bottom: 0.3rem;
}

.cmt-spoiler.es-visible p {
    filter: none;
    opacity: 1;
    user-select: auto;
}

.cmt-spoiler.es-visible {
    cursor: auto;
}

.cmt-spoiler.es-visible .cmt-spoiler-aviso {
    display: none;
}

/* --- Acciones ----------------------------------------------------------- */

.cmt-acciones {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.45rem;
}

.cmt-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: 0;
    color: var(--cmt-texto-suave);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
}

.cmt-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.cmt-like.es-activo {
    color: var(--cmt-acento);
}

.cmt-like.es-activo svg {
    animation: cmt-latido 320ms ease;
}

@keyframes cmt-latido {
    0% { transform: scale(1); }
    45% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.cmt-likes-num {
    font-variant-numeric: tabular-nums;
}

/* Menú de más opciones */
.cmt-mas {
    position: relative;
    margin-left: auto;
}

.cmt-mas-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 150px;
    background: #22262b;
    border: 1px solid var(--cmt-borde-fuerte);
    border-radius: 10px;
    padding: 4px;
    z-index: 30;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.cmt-mas.es-abierto .cmt-mas-menu {
    display: block;
}

.cmt-mas-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: var(--cmt-texto);
    font-size: 0.83rem;
    padding: 0.5rem 0.65rem;
    border-radius: 7px;
    cursor: pointer;
}

.cmt-mas-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

.cmt-eliminar:hover {
    color: #ff8f8f;
}

/* --- Respuestas --------------------------------------------------------- */

.cmt-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    background: transparent;
    border: 0;
    color: #7cb0ff;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 140ms ease;
}

.cmt-toggle:hover {
    background: rgba(124, 176, 255, 0.12);
}

.cmt-toggle[hidden] {
    display: none;
}

.cmt-toggle-flecha {
    transition: transform 180ms ease;
}

.cmt-toggle.es-abierto .cmt-toggle-flecha {
    transform: rotate(180deg);
}

.cmt-hijos-caja[hidden] {
    display: none;
}

.cmt-hijos {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    margin-top: 0.85rem;
    padding-left: 1rem;
    border-left: 2px solid var(--cmt-borde);
}

.cmt-hijos:empty {
    display: none;
}

.cmt-mas-resp {
    margin: 0.65rem 0 0 1rem;
    color: #7cb0ff;
}

.cmt-mas-resp:hover {
    background: rgba(124, 176, 255, 0.12);
    color: #9dc4ff;
}

.cmt-mas-resp[hidden] {
    display: none;
}

.cmt-form--respuesta {
    margin: 1rem 0 0;
    padding-left: 1rem;
    border-left: 2px solid var(--cmt-borde);
}

.cmt-form--respuesta .cmt-avatar {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
}

/* --- Esqueleto, vacío y cargar más -------------------------------------- */

.cmt-esqueleto {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.cmt-esqueleto[hidden] {
    display: none;
}

.cmt-esqueleto-item {
    display: flex;
    gap: 0.85rem;
}

.cmt-esqueleto-avatar {
    flex: 0 0 42px;
    height: 42px;
    border-radius: 50%;
}

.cmt-esqueleto-lineas {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 4px;
}

.cmt-esqueleto-lineas span {
    display: block;
    height: 11px;
    border-radius: 6px;
}

.cmt-esqueleto-avatar,
.cmt-esqueleto-lineas span {
    background: linear-gradient(90deg, #1c1f23 25%, #262a30 50%, #1c1f23 75%);
    background-size: 400px 100%;
    animation: cmt-brillo 1.3s linear infinite;
}

@keyframes cmt-brillo {
    from { background-position: -200px 0; }
    to { background-position: 200px 0; }
}

.cmt-vacio {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--cmt-texto-suave);
    background: var(--cmt-superficie);
    border: 1px dashed var(--cmt-borde-fuerte);
    border-radius: var(--cmt-radio);
}

.cmt-vacio svg {
    color: #3d4147;
    margin-bottom: 0.6rem;
}

.cmt-vacio p {
    margin: 0;
    font-size: 0.92rem;
}

.cmt-mas-cargar {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    background: var(--cmt-superficie);
    border: 1px solid var(--cmt-borde-fuerte);
    color: var(--cmt-texto);
    font-size: 0.87rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.cmt-mas-cargar:hover {
    background: var(--cmt-superficie-2);
}

.cmt-mas-cargar:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* --- Modal de reporte --------------------------------------------------- */

.cmt-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    animation: cmt-fundido 160ms ease both;
}

.cmt-modal[hidden] {
    display: none;
}

@keyframes cmt-fundido {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cmt-modal-caja {
    width: 100%;
    max-width: 420px;
    background: #1b1e22;
    border: 1px solid var(--cmt-borde-fuerte);
    border-radius: 16px;
    padding: 1.4rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.cmt-modal-caja h3 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.cmt-modal-texto {
    margin: 0 0 1rem;
    font-size: 0.86rem;
    color: var(--cmt-texto-suave);
}

.cmt-select {
    width: 100%;
    background: #14171a;
    color: var(--cmt-texto);
    border: 1px solid var(--cmt-borde-fuerte);
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    font-size: 0.88rem;
    outline: none;
}

.cmt-select:focus {
    border-color: rgba(255, 98, 98, 0.5);
}

.cmt-modal-btns {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.1rem;
}

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 576px) {
    .cmt-wrap {
        margin-top: 2.5rem;
    }

    .cmt-titulo {
        font-size: 1.1rem;
    }

    .cmt-avatar {
        flex-basis: 36px;
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .cmt-login-btns {
        margin-left: 0;
        width: 100%;
    }

    .cmt-hijos,
    .cmt-form--respuesta {
        padding-left: 0.7rem;
    }

    .cmt-acciones {
        gap: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cmt-item,
    .cmt-like.es-activo svg,
    .cmt-esqueleto-avatar,
    .cmt-esqueleto-lineas span,
    .cmt-modal {
        animation: none;
    }
}
