/**
 * CPM Notifications - Estilos para el sistema de notificaciones
 * Adaptado del sistema CHE, compatible con Bootstrap 5
 */

/* ========================================
   CONTENEDOR DEL BOTÓN DE NOTIFICACIONES
   ======================================== */
.cpm-notification-wrapper {
    position: relative;
    display: inline-block;
}

/* ========================================
   BOTÓN DE NOTIFICACIONES EN EL HEADER
   ======================================== */
#cpm-notification-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    font-size: 14px;
}

#cpm-notification-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

#cpm-notification-btn .dashicons,
#cpm-notification-btn .cpm-notification-icon {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.cpm-notification-text {
    font-weight: 500;
}

/* ========================================
   BADGE ROJO CON CONTADOR
   ======================================== */
.cpm-notification-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #dc3545;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.4);
    animation: cpm-badge-pulse 2s infinite;
}

/* Animación de pulso para llamar la atención */
@keyframes cpm-badge-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(220, 53, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

/* Badge cuando no hay notificaciones */
.cpm-notification-badge[style*="display: none"],
.cpm-notification-badge[style*="display:none"] {
    animation: none;
}

/* ========================================
   DROPDOWN DE NOTIFICACIONES
   ======================================== */
#cpm-notification-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 360px;
    max-width: 420px;
    max-height: 480px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    overflow: hidden;
    flex-direction: column;
}

#cpm-notification-dropdown.is-open,
.cpm-notification-dropdown.is-open {
    display: flex;
}

/* ========================================
   HEADER DEL DROPDOWN
   ======================================== */
.cpm-notification-header,
.cpm-notification-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #df0b0b86 0%, #df0b0b86 100%);
    color: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    gap: 12px;
}

.cpm-notification-header h3,
.cpm-notification-header h4,
.cpm-notification-dropdown-header h3,
.cpm-notification-dropdown-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    flex: 1;
}

#cpm-mark-all-read,
.cpm-mark-all-read {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

#cpm-mark-all-read:hover,
.cpm-mark-all-read:hover {
    background: rgba(255,255,255,0.3);
}

/* ========================================
   LISTA DE NOTIFICACIONES
   ======================================== */
#cpm-notification-list,
.cpm-notification-list {
    flex: 1;
    overflow-y: auto;
    max-height: 320px;
}

.cpm-notification-loading {
    padding: 40px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

/* ========================================
   ITEM DE NOTIFICACIÓN
   ======================================== */
.cpm-notification-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 28px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.cpm-notification-item:hover {
    background: #f8f9fa;
}

.cpm-notification-item:last-child {
    border-bottom: none;
}

.cpm-notification-item.unread {
    background: #e8f4fd;
    border-left: 3px solid #4a90a4;
}

.cpm-notification-item.unread:hover {
    background: #d9ecf7;
}

.cpm-notification-item .notification-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    border-radius: 50%;
    font-size: 18px;
}

.cpm-notification-item.tipo-solicitud .notification-icon {
    background: #fff3cd;
}

.cpm-notification-item.tipo-aprobado .notification-icon {
    background: #d4edda;
}

.cpm-notification-item.tipo-rechazado .notification-icon {
    background: #f8d7da;
}

/* Partes de trabajo */
.cpm-notification-item.tipo-parte_pendiente .notification-icon {
    background: #cce5ff;
}

.cpm-notification-item.tipo-parte_validado .notification-icon {
    background: #d4edda;
}

.cpm-notification-item.tipo-parte_rechazado .notification-icon {
    background: #f8d7da;
}

/* Usuarios */
.cpm-notification-item.tipo-super_admin_created .notification-icon {
    background: #ffeaa7;
}

.cpm-notification-item .notification-content {
    flex: 1;
    min-width: 0;
}

.cpm-notification-item .notification-title {
    font-weight: 600;
    color: #212529;
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.3;
}

.cpm-notification-item .notification-message {
    color: #6c757d;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 6px;
}

.cpm-notification-item .notification-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #adb5bd;
}

.cpm-notification-item .notification-date {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   ESTADO VACÍO
   ======================================== */
.cpm-notification-empty {
    padding: 40px 24px;
    text-align: center;
    color: #6c757d;
}

.cpm-notification-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.cpm-notification-empty p {
    margin: 0;
    font-size: 14px;
}

/* ========================================
   BANNER DE PERMISOS
   ======================================== */
.cpm-permission-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 12px 12px;
    margin: 0;
    border-radius: 0;
    margin-bottom: 0;
}

.cpm-permission-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
}

.cpm-permission-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.cpm-permission-text strong {
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
    font-weight: 600;
}

.cpm-permission-text p {
    margin: 0;
    font-size: 11px;
    opacity: 0.95;
    line-height: 1.3;
}

.cpm-permission-hint {
    font-size: 10px !important;
    opacity: 0.9 !important;
    margin-top: 8px !important;
}

.cpm-request-permission-btn {
    background: #fff;
    color: #667eea;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
}

.cpm-request-permission-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* ========================================
   FOOTER DEL DROPDOWN
   ======================================== */
.cpm-notification-footer,
.cpm-notification-dropdown-footer {
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.cpm-go-to-section {
    width: 100%;
    padding: 10px 16px;
    background: #e9ecef;
    color: #495057;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.cpm-go-to-section:hover {
    background: #dee2e6;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

#cpm-notifications-container {
    position: fixed;
    top: 80px; /* Bajado de 20px a 80px para móviles */
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    /* Safe areas para móviles con notch */
    padding-top: env(safe-area-inset-top, 0);
    padding-right: env(safe-area-inset-right, 0);
}

.cpm-toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid #3498db;
    transition: transform 0.2s ease;
    position: relative;
}

.cpm-toast:hover {
    transform: scale(1.02);
}

.cpm-toast-icon {
    flex-shrink: 0;
    font-size: 24px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpm-toast-content {
    flex: 1;
    min-width: 0;
}

.cpm-toast-title {
    font-weight: 600;
    color: #212529;
    font-size: 14px;
    margin-bottom: 4px;
}

.cpm-toast-message {
    color: #6c757d;
    font-size: 13px;
    line-height: 1.4;
}

.cpm-toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #adb5bd;
    font-size: 18px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    border-radius: 4px;
    transition: all 0.2s;
}

.cpm-toast-close:hover {
    background: #f0f0f0;
    color: #495057;
}

.cpm-toast.tipo-parte_pendiente,
.cpm-toast.tipo-parte_validado,
.cpm-toast.tipo-parte_rechazado,
.cpm-toast.tipo-parte_nuevo {
    border-left-color: #9b59b6;
}

.cpm-toast.tipo-vacacion_pendiente,
.cpm-toast.tipo-vacacion_aprobada,
.cpm-toast.tipo-vacacion_rechazada,
.cpm-toast.tipo-vacacion_solicitud,
.cpm-toast.tipo-solicitud,
.cpm-toast.tipo-aprobado,
.cpm-toast.tipo-rechazado {
    border-left-color: #27ae60;
}

.cpm-toast.tipo-super_admin_created {
    border-left-color: #f39c12;
}

/* ========================================
   RESPONSIVE PARA EL DROPDOWN
   ======================================== */
@media (max-width: 768px) {
    #cpm-notification-btn {
        padding: 8px 12px;
    }
    
    .cpm-notification-text {
        display: none;
    }
    
    #cpm-notification-btn .dashicons,
    #cpm-notification-btn .cpm-notification-icon {
        font-size: 20px;
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    #cpm-notification-dropdown,
    .cpm-notification-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: 100%;
        max-width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        margin-top: 0;
    }
    
    .cpm-notification-dropdown-header,
    .cpm-notification-header {
        padding: 20px;
    }
    
    #cpm-notification-list,
    .cpm-notification-list {
        max-height: calc(70vh - 140px);
    }
    
    .cpm-notification-item {
        padding: 16px 20px;
    }
    
    #cpm-notifications-container {
        /* En móvil centrar pero más abajo */
        top: 100px; /* Más abajo para que no se corten */
        right: 10px;
        left: 10px;
        transform: none;
        max-width: calc(100% - 20px);
        width: auto;
    }
}
