/* ============================================
   🔔 SISTEMA DE NOTIFICACIONES - WIDGET CAMPANA
   ============================================ */

/* Widget base */
.notif-widget {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 9999;
}

/* Modo flotante (cuando no hay nav) */
.notif-widget-floating {
    position: fixed;
    top: 16px;
    right: 80px;
    z-index: 99999;
}

/* Botón campana */
.notif-bell-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #64748b;
    position: relative;
    padding: 10px 14px;
    border-radius: 10px;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notif-bell-btn:hover {
    background: rgba(0, 120, 212, 0.08);
    color: #0078d4;
    transform: scale(1.05);
}

.notif-bell-btn:active {
    transform: scale(0.95);
}

/* Badge de conteo */
.notif-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    border: 2px solid white;
    font-family: -apple-system, system-ui, sans-serif;
}

/* Campana activa cuando hay notificaciones */
.notif-bell-active {
    color: #0078d4 !important;
}

.notif-bell-active i {
    animation: notifBellSwing 2s ease-in-out infinite;
    transform-origin: top center;
}

@keyframes notifBellSwing {
    0%, 100% { transform: rotate(0deg); }
    5% { transform: rotate(15deg); }
    10% { transform: rotate(-12deg); }
    15% { transform: rotate(9deg); }
    20% { transform: rotate(-6deg); }
    25% { transform: rotate(0deg); }
}

@keyframes notifPulseAnim {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

.notif-badge-pulse {
    animation: notifPulseAnim 0.6s ease-in-out 3;
}

/* Dropdown */
.notif-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 400px;
    max-width: 95vw;
    background: white;
    border-radius: 16px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.12),
        0 4px 16px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.04);
    z-index: 100000;
    overflow: hidden;
    transform-origin: top right;
}

/* Flecha del dropdown */
.notif-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 18px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.04);
    z-index: 1;
}

/* Header del dropdown */
.notif-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 14px;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

.notif-dropdown-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notif-dropdown-header h4 i {
    color: #0078d4;
    font-size: 14px;
}

.notif-mark-all-btn {
    background: none;
    border: none;
    color: #0078d4;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.notif-mark-all-btn:hover {
    background: rgba(0, 120, 212, 0.1);
}

/* Lista de notificaciones */
.notif-list {
    max-height: 420px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.notif-list::-webkit-scrollbar {
    width: 5px;
}

.notif-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Item de notificación */
.notif-item {
    display: flex;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    align-items: flex-start;
}

.notif-item:hover {
    background: #f8fafc;
}

.notif-item:last-child {
    border-bottom: none;
}

/* No leída */
.notif-item.notif-no-leida {
    background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
    border-left: 3px solid #3b82f6;
}

.notif-item.notif-no-leida:hover {
    background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 100%);
}

/* Ícono tipo */
.notif-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 2px;
}

.notif-tipo-pendiente {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #b45309;
}

.notif-tipo-aprobada {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #047857;
}

.notif-tipo-modificar {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #b91c1c;
}

.notif-tipo-info {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1d4ed8;
}

.notif-tipo-ot {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}

.notif-tipo-facturacion {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
}

.notif-tipo-producto {
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: #5b21b6;
}

/* Contenido */
.notif-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.notif-titulo {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 3px;
    line-height: 1.4;
}

.notif-mensaje {
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.notif-tiempo {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notif-tiempo i {
    font-size: 10px;
}

.notif-ref {
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    color: #64748b;
    font-size: 10px;
}

/* Punto azul no leída */
.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b82f6;
    flex-shrink: 0;
    margin-top: 8px;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.5);
}

/* Empty state */
.notif-empty {
    text-align: center;
    padding: 50px 20px;
    color: #94a3b8;
}

.notif-empty i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.4;
}

.notif-empty p {
    font-size: 14px;
    margin: 0;
    font-weight: 500;
}

/* Footer */
.notif-dropdown-footer {
    padding: 10px 20px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
    text-align: center;
}

.notif-dropdown-footer small {
    color: #94a3b8;
    font-size: 11px;
}

/* ============================================
   TOAST DE NOTIFICACIÓN (para mostrar en pantalla)
   ============================================ */
.notif-toast {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 999999;
    background: white;
    border-radius: 14px;
    box-shadow: 
        0 16px 48px rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.06);
    padding: 16px 20px;
    max-width: 380px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: notifToastIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    border-left: 4px solid #3b82f6;
    cursor: pointer;
    transition: all 0.3s ease;
}

.notif-toast:hover {
    transform: translateX(-4px);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.08);
}

.notif-toast.toast-aprobada {
    border-left-color: #10b981;
}

.notif-toast.toast-modificar {
    border-left-color: #f59e0b;
}

.notif-toast.toast-pendiente {
    border-left-color: #f97316;
}

.notif-toast.toast-nueva {
    border-left-color: #3b82f6;
}

.notif-toast.toast-editada {
    border-left-color: #8b5cf6;
}

.notif-toast.toast-eliminada {
    border-left-color: #ef4444;
}

/* OTs */
.notif-toast.toast-ot {
    border-left-color: #f59e0b;
}

.notif-toast.toast-ot-edit {
    border-left-color: #d97706;
}

/* Facturación */
.notif-toast.toast-facturacion {
    border-left-color: #10b981;
}

/* Productos */
.notif-toast.toast-producto {
    border-left-color: #8b5cf6;
}

.notif-toast.toast-producto-edit {
    border-left-color: #7c3aed;
}

@keyframes notifToastIn {
    from {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes notifToastOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }
}

.notif-toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.notif-toast-content {
    flex: 1;
}

.notif-toast-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.notif-toast-msg {
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
}

.notif-toast-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    padding: 2px;
    margin: -4px -4px 0 0;
    line-height: 1;
    transition: color 0.2s;
}

.notif-toast-close:hover {
    color: #64748b;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .notif-dropdown {
        width: calc(100vw - 20px);
        right: -60px;
        top: calc(100% + 12px);
    }
    
    .notif-widget-floating {
        top: 12px;
        right: 60px;
    }
    
    .notif-toast {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* ============================================
   DARK MODE - Notificaciones
   ============================================ */
body.dark-mode .notif-dropdown {
    background: #1e293b;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
}
body.dark-mode .notif-dropdown::before {
    background: #1e293b;
}
body.dark-mode .notif-dropdown-header {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
body.dark-mode .notif-item {
    border-color: #334155;
    color: #cbd5e1;
}
body.dark-mode .notif-item:hover {
    background: #334155;
}
body.dark-mode .notif-item-unread {
    background: rgba(59,130,246,0.08);
}
body.dark-mode .notif-toast {
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
