/* ============================================================
   Notifications In-App — badge, drawer, toast (Premium UI)
   ============================================================ */

/* ---- Badge sur la cloche ---- */
.notif-bell-wrapper {
    position: relative;
}

.notif-badge {
    position: absolute;
    top: 0px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border-radius: 10px;
    pointer-events: none;
    box-shadow: 0 0 0 2px #fff; 
}

/* ---- Drawer dropdown ---- */
.notif-drawer {
    width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 !important;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    animation: dropdownFade 0.2s ease-out forwards;
    background: #ffffff;
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    top: 100% !important;
    margin-top: 10px;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile responsiveness fixing the cutoff issue */
@media (max-width: 575.98px) {
    .notif-drawer {
        width: calc(100vw - 20px) !important;
        max-width: 100vw !important;
        right: -10px !important; 
    }
}

/* Header */
.notif-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.notif-drawer-header h6 {
    margin: 0;
    font-weight: 700;
    font-size: 15px;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notif-drawer-header h6 i {
    color: #6366f1;
    font-size: 18px;
}

.notif-drawer-mark-all {
    font-size: 12px;
    font-weight: 500;
    color: #6366f1;
    cursor: pointer;
    background: #eef2ff;
    border: none;
    padding: 6px 12px;
    border-radius: 16px;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.notif-drawer-mark-all:hover {
    background: #e0e7ff;
    color: #4f46e5;
    text-decoration: none;
}

/* Item */
.notif-item {
    display: flex;
    align-items: flex-start;
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
}

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

.notif-item:hover {
    background: #f9fafb;
    color: inherit;
    text-decoration: none;
}

.notif-item.unread {
    background: #f0f9ff;
}

.notif-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 32px;
    background: #3b82f6;
    border-radius: 0 4px 4px 0;
}

.notif-item.unread:hover {
    background: #e0f2fe;
}

/* Icon */
.notif-item-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.notif-item-icon.action_required { background: linear-gradient(135deg, #ef4444, #dc2626); }
.notif-item-icon.warning          { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.notif-item-icon.info             { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.notif-item-icon.success          { background: linear-gradient(135deg, #10b981, #059669); }

/* Body */
.notif-item-body {
    flex: 1;
    min-width: 0;
}

.notif-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.notif-item-message {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.notif-item-time {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.notif-item-time i {
    font-size: 12px;
}

/* Empty State */
.notif-drawer-empty {
    padding: 48px 20px;
    text-align: center;
    color: #9ca3af;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.notif-drawer-empty i {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    color: #e5e7eb;
}

.notif-drawer-empty span {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
}

/* ---- Toast (coin bas-droit) ---- */
#notif-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    pointer-events: none;
}

@media (max-width: 575.98px) {
    #notif-toast-container {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }
}

.notif-toast {
    display: flex;
    align-items: flex-start;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15), 0 4px 15px -5px rgba(0, 0, 0, 0.05);
    min-width: 320px;
    max-width: 400px;
    padding: 16px;
    pointer-events: all;
    animation: notif-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid #3b82f6;
    position: relative;
    overflow: hidden;
}

@media (max-width: 575.98px) {
    .notif-toast {
        min-width: unset;
        width: 100%;
        max-width: 100%;
    }
}

.notif-toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(90deg, rgba(59,130,246,0.1), transparent);
    pointer-events: none;
}

.notif-toast.action_required { border-left-color: #ef4444; }
.notif-toast.action_required::before { background: linear-gradient(90deg, rgba(239,68,68,0.1), transparent); }

.notif-toast.warning { border-left-color: #f59e0b; }
.notif-toast.warning::before { background: linear-gradient(90deg, rgba(245,158,11,0.1), transparent); }

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

.notif-toast.success { border-left-color: #10b981; }
.notif-toast.success::before { background: linear-gradient(90deg, rgba(16,185,129,0.1), transparent); }

.notif-toast-icon {
    flex-shrink: 0;
    font-size: 24px;
    margin-right: 16px;
    margin-top: -2px;
}

.notif-toast.action_required .notif-toast-icon { color: #ef4444; }
.notif-toast.warning          .notif-toast-icon { color: #f59e0b; }
.notif-toast.info             .notif-toast-icon { color: #3b82f6; }
.notif-toast.success          .notif-toast-icon { color: #10b981; }

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

.notif-toast-title {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

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

.notif-toast-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.notif-toast-btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: filter 0.2s, background 0.2s;
}

.notif-toast-btn:hover {
    filter: brightness(1.1);
    text-decoration: none;
}

.notif-toast.action_required .notif-toast-btn { background: #ef4444; color: #fff; }
.notif-toast.warning          .notif-toast-btn { background: #f59e0b; color: #fff; }
.notif-toast.info             .notif-toast-btn { background: #3b82f6; color: #fff; }
.notif-toast.success          .notif-toast-btn { background: #10b981; color: #fff; }

.notif-toast-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    flex-shrink: 0;
    align-self: flex-start;
    line-height: 1;
    transition: color 0.2s;
}

.notif-toast-close:hover {
    color: #4b5563;
}

@keyframes notif-slide-in {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

@keyframes notif-slide-out {
    from { transform: translateX(0);   opacity: 1; }
    to   { transform: translateX(120%); opacity: 0; }
}

.notif-toast.removing {
    animation: notif-slide-out 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ================================================================
   Floating notification widget (bottom-right, replaces task widget)
   ================================================================ */

.notif-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    overflow: hidden;
    font-size: 13px;
    transition: box-shadow .2s;
}

.notif-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
    color: #fff;
    cursor: pointer;
    user-select: none;
}

.notif-widget-header > span {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notif-widget-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
}

.notif-widget-minimize-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.75);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: color .15s;
    pointer-events: none; /* header click handles toggle */
}

.notif-widget-body {
    max-height: 340px;
    overflow-y: auto;
}

.notif-widget.minimized .notif-widget-body {
    display: none;
}

.notif-widget-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background .15s;
}

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

.notif-widget-item:hover {
    background: #f8f9fa;
}

.notif-widget-item-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    margin-top: 2px;
}

.notif-widget-item.action_required .notif-widget-item-icon { background: #fdecea; color: #e74c3c; }
.notif-widget-item.warning         .notif-widget-item-icon { background: #fff8e1; color: #f39c12; }
.notif-widget-item.info            .notif-widget-item-icon { background: #e3f2fd; color: #2196f3; }
.notif-widget-item.success         .notif-widget-item-icon { background: #e8f5e9; color: #27ae60; }

.notif-widget-item-content {
    flex: 1;
    min-width: 0;
}

.notif-widget-item-title {
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12.5px;
}

.notif-widget-item-message {
    color: #7f8c8d;
    font-size: 12px;
    margin-top: 2px;
    line-height: 1.4;
}

.notif-widget-item-time {
    color: #b2bec3;
    font-size: 11px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.notif-widget-item-actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.notif-widget-btn-go {
    font-size: 11px;
    padding: 3px 8px;
    background: #4b6cb7;
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
    display: inline-block;
}

.notif-widget-btn-go:hover {
    color: #fff;
    opacity: .85;
    text-decoration: none;
}

.notif-widget-btn-read {
    font-size: 11px;
    padding: 3px 8px;
    background: #ecf0f1;
    color: #7f8c8d;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.notif-widget-btn-read:hover {
    background: #dfe6e9;
    color: #636e72;
}

@media (max-width: 575.98px) {
    .notif-widget {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 16px;
    }
}
