/* Fase 14: campana, notificaciones, preferencias, plantillas y log de envíos. */

/* ---------------------------------------------------------- campana navbar */
.campana {
    position: relative;
}

.campana__boton {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.campana__boton:hover {
    background: rgba(255, 255, 255, 0.12);
}

.campana__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.campana__panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 200;
    display: none;
    width: 360px;
    max-height: 480px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
    background: var(--color-surface, #fff);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.campana.is-open .campana__panel {
    display: flex;
}

.campana__cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.campana__accion {
    border: none;
    background: none;
    color: var(--color-primary, #349084);
    font-size: 13px;
    cursor: pointer;
}

.campana__lista {
    flex: 1;
    overflow-y: auto;
}

.campana__item {
    display: flex;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-bottom: 1px solid var(--color-border, #f0f0f0);
    background: none;
    text-align: left;
    cursor: pointer;
}

.campana__item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.campana__punto {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    margin-top: 6px;
    border-radius: 50%;
    background: transparent;
}

.campana__item--no-leida .campana__punto {
    background: var(--color-primary, #349084);
}

.campana__item--no-leida strong {
    font-weight: 700;
}

.campana__texto {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.campana__texto strong {
    font-size: 14px;
    font-weight: 500;
}

.campana__texto small,
.campana__texto time {
    overflow: hidden;
    color: var(--color-text-muted, #6b7280);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.campana__pie {
    display: block;
    padding: 12px;
    border-top: 1px solid var(--color-border, #e5e7eb);
    color: var(--color-primary, #349084);
    font-size: 14px;
    text-align: center;
    text-decoration: none;
}

.campana__vacio {
    padding: 32px 16px;
    color: var(--color-text-muted, #6b7280);
    font-size: 14px;
    text-align: center;
}

.campana__skeleton {
    height: 56px;
    border-bottom: 1px solid var(--color-border, #f0f0f0);
    background: linear-gradient(90deg, #f3f4f6 25%, #e9eaec 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: campana-brillo 1.2s infinite;
}

@keyframes campana-brillo {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* -------------------------------------------------- página Mis notificaciones */
.notif-barra {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4, 16px);
    gap: var(--space-3, 12px);
    flex-wrap: wrap;
}

.notif-filtro {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.notif-item {
    margin-bottom: 10px;
    padding: 16px;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s;
}

.notif-item:hover {
    transform: translateX(2px);
}

.notif-item--no-leida {
    border-left-color: var(--color-primary, #349084);
}

.notif-item--no-leida h3 {
    font-weight: 700;
}

.notif-item__cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.notif-item__cabecera h3 {
    margin: 0;
    font-size: 15px;
}

.notif-item__cuerpo {
    margin: 6px 0 0;
    color: var(--color-text-muted, #6b7280);
    font-size: 14px;
}

.notif-item__fecha {
    display: block;
    margin-top: 8px;
    color: var(--color-text-muted, #9ca3af);
    font-size: 12px;
}

.notif-item--skeleton {
    height: 84px;
    background: linear-gradient(90deg, #f3f4f6 25%, #e9eaec 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: campana-brillo 1.2s infinite;
    cursor: default;
}

.notif-paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: var(--space-4, 16px);
    gap: var(--space-3, 12px);
    font-size: 14px;
}

/* ------------------------------------------------------------- preferencias */
.prefs-card {
    padding: var(--space-5, 20px);
}

.prefs-intro {
    margin: 0 0 16px;
    color: var(--color-text-muted, #6b7280);
    font-size: 14px;
}

.prefs-tabla {
    display: flex;
    flex-direction: column;
}

.prefs-candado {
    font-size: 12px;
    line-height: 1;
    /* El candado acompaña al texto; el motivo real se explica en .prefs-aviso. */
    opacity: 0.7;
}

.prefs-fila {
    display: grid;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    grid-template-columns: 1fr 120px 150px;
    gap: 12px;
}

.prefs-fila--cabecera {
    color: var(--color-text-muted, #6b7280);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
}

.prefs-fila--cabecera span:not(:first-child),
.prefs-fila span:not(.prefs-categoria) {
    text-align: center;
}

.prefs-categoria {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.prefs-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.prefs-check[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
}

.prefs-aviso {
    margin: 0;
    padding: 8px 0 12px;
    color: var(--color-text-muted, #6b7280);
    font-size: 12px;
}

.prefs-acciones {
    margin-top: 20px;
}

/* --------------------------------------------------------------- plantillas */
.plantillas-layout {
    display: grid;
    align-items: start;
    grid-template-columns: 280px 1fr;
    gap: var(--space-4, 16px);
}

.plantillas-lista {
    max-height: 70vh;
    padding: 8px;
    overflow-y: auto;
}

.plantillas-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    background: none;
    gap: 8px;
    text-align: left;
    cursor: pointer;
}

.plantillas-item:hover,
.plantillas-item.is-activa {
    background: rgba(52, 144, 132, 0.1);
}

.plantillas-item__nombre {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plantillas-item__meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.estado-punto {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.estado-punto--activa { background: #16a34a; }
.estado-punto--inactiva { background: #d1d5db; }

.plantillas-editor {
    padding: var(--space-5, 20px);
}

.plantillas-editor__cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.plantillas-editor__cabecera h2 {
    margin: 0;
    font-size: 18px;
}

.plantillas-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.plantillas-ayuda {
    margin: 4px 0 16px;
    color: var(--color-text-muted, #6b7280);
    font-size: 13px;
}

.plantillas-cuerpo {
    display: grid;
    margin-top: 16px;
    grid-template-columns: 1fr 240px;
    gap: 16px;
}

.plantillas-textarea {
    width: 100%;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}

.plantillas-variables h3 {
    margin: 0 0 8px;
    font-size: 13px;
    text-transform: uppercase;
}

.plantillas-variables ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.plantillas-variables li {
    margin-bottom: 8px;
}

.plantillas-variables code {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(52, 144, 132, 0.12);
    font-size: 12px;
    cursor: pointer;
}

.plantillas-variables small {
    display: block;
    color: var(--color-text-muted, #6b7280);
    font-size: 11px;
}

.plantillas-acciones {
    display: flex;
    margin-top: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.plantillas-preview {
    margin-top: 20px;
}

.plantillas-preview__asunto {
    font-size: 14px;
}

.plantillas-preview__marco {
    width: 100%;
    height: 480px;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 8px;
    background: #f4f4f5;
}

/* ------------------------------------------------------------ log de envíos */
.log-filtros {
    display: flex;
    margin-bottom: var(--space-4, 16px);
    padding: var(--space-4, 16px);
    gap: 10px;
    flex-wrap: wrap;
}

.log-filtros .input-field {
    max-width: 220px;
}

.tabla-scroll {
    overflow-x: auto;
}

.log-tabla {
    min-width: 900px;
}

.log-acciones {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.btn-icono {
    border: none;
    background: none;
    font-size: 16px;
    cursor: pointer;
}

.estado-chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.estado-chip--enviado { background: #dcfce7; color: #166534; }
.estado-chip--pendiente { background: #fef3c7; color: #92400e; }
.estado-chip--enviando { background: #dbeafe; color: #1e40af; }
.estado-chip--fallido { background: #fee2e2; color: #991b1b; }
.estado-chip--cancelado { background: #f3f4f6; color: #4b5563; }

.log-fila--skeleton td {
    height: 44px;
    background: linear-gradient(90deg, #f3f4f6 25%, #e9eaec 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: campana-brillo 1.2s infinite;
}

.tabla-vacia {
    padding: 32px;
    color: var(--color-text-muted, #6b7280);
    text-align: center;
}

/* Categorías (badges) */
.badge--formacion { background: #dbeafe; color: #1e40af; }
.badge--calificaciones { background: #f3e8ff; color: #6b21a8; }
.badge--social { background: #dcfce7; color: #166534; }
.badge--recordatorios { background: #fef3c7; color: #92400e; }
.badge--resumen { background: #e0e7ff; color: #3730a3; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 768px) {
    /* El desplegable de la campana pasa a ocupar la pantalla: a 360px de ancho
       se saldría del viewport. */
    .campana__panel {
        position: fixed;
        top: 56px;
        right: 0;
        left: 0;
        width: 100%;
        max-height: calc(100vh - 56px);
        border-radius: 0;
    }

    .plantillas-layout,
    .plantillas-cuerpo {
        grid-template-columns: 1fr;
    }

    .plantillas-lista {
        max-height: 240px;
    }

    .log-filtros .input-field,
    .log-filtros .btn {
        max-width: none;
        width: 100%;
    }

    .prefs-fila {
        grid-template-columns: 1fr 70px 70px;
    }

    .notif-barra {
        flex-direction: column;
        align-items: stretch;
    }
}
