/*
 * ╔══════════════════════════════════════════════════════════════════╗
 * ║  MM NOTIFICATIONS  —  mm-notifications.css                      ║
 * ║  Sistema de notificaciones unificado para todos los paneles     ║
 * ║  Admin · Panel Profesional · Panel Ciudadano · Front            ║
 * ╚══════════════════════════════════════════════════════════════════╝
 *
 * Índice:
 *  1. Variables locales (compatibles con ambos contextos CSS)
 *  2. Contenedor de toasts
 *  3. Toast base
 *  4. Variantes (success, error, warning, info)
 *  5. Animaciones
 *  6. Badge campana (navbar)
 *  7. Dropdown de notificaciones
 *  8. Responsive
 */

/* ════════════════════════════════════════════════════════════
   1. VARIABLES LOCALES
   ════════════════════════════════════════════════════════════ */
:root {
    --mmn-success-bg:      #ecfdf5;
    --mmn-success-border:  #6ee7b7;
    --mmn-success-accent:  #059669;
    --mmn-success-icon:    #10b981;
    --mmn-success-text:    #065f46;

    --mmn-error-bg:        #fef2f2;
    --mmn-error-border:    #fca5a5;
    --mmn-error-accent:    #dc2626;
    --mmn-error-icon:      #ef4444;
    --mmn-error-text:      #7f1d1d;

    --mmn-warning-bg:      #fff7ed;
    --mmn-warning-border:  #fdba74;
    --mmn-warning-accent:  #ea580c;
    --mmn-warning-icon:    #f97316;
    --mmn-warning-text:    #7c2d12;

    --mmn-info-bg:         #eff6ff;
    --mmn-info-border:     #93c5fd;
    --mmn-info-accent:     #2563eb;
    --mmn-info-icon:       #3b82f6;
    --mmn-info-text:       #1e3a8a;

    --mmn-shadow:          0 4px 24px rgba(0,0,0,0.10), 0 1px 6px rgba(0,0,0,0.06);
    --mmn-shadow-hover:    0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
    --mmn-radius:          12px;
    --mmn-width:           340px;
    --mmn-z:               9999;
    --mmn-font:            inherit;
}

/* ════════════════════════════════════════════════════════════
   2. CONTENEDOR DE TOASTS
   ════════════════════════════════════════════════════════════ */
#mm-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--mmn-z);
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
    width: var(--mmn-width);
}

/* ════════════════════════════════════════════════════════════
   3. TOAST BASE
   ════════════════════════════════════════════════════════════ */
.mm-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--mmn-radius);
    border: 1px solid transparent;
    border-left-width: 4px;
    box-shadow: var(--mmn-shadow);
    background: #fff;
    font-family: var(--mmn-font);
    position: relative;
    overflow: hidden;
    cursor: default;
    transition: box-shadow 0.2s ease, transform 0.2s ease;

    /* Animación entrada */
    animation: mmn-slide-in 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.mm-toast:hover {
    box-shadow: var(--mmn-shadow-hover);
    transform: translateY(-2px);
}

.mm-toast.mm-toast--leaving {
    animation: mmn-slide-out 0.28s ease-in forwards;
}

/* Icono */
.mm-toast__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    margin-top: 1px;
}

/* Contenido */
.mm-toast__body {
    flex: 1;
    min-width: 0;
}

.mm-toast__title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 3px 0;
    letter-spacing: -0.01em;
}

.mm-toast__message {
    font-size: 12px;
    line-height: 1.5;
    margin: 0;
    opacity: 0.85;
}

/* Botón cerrar */
.mm-toast__close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: 0.45;
    font-size: 16px;
    line-height: 1;
    color: inherit;
    transition: opacity 0.15s;
    margin-top: -1px;
}

.mm-toast__close:hover {
    opacity: 0.9;
}

/* Barra de progreso */
.mm-toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 0 var(--mmn-radius);
    animation: mmn-progress linear forwards;
    transform-origin: left;
}

/* ════════════════════════════════════════════════════════════
   4. VARIANTES
   ════════════════════════════════════════════════════════════ */

/* SUCCESS */
.mm-toast--success {
    background: var(--mmn-success-bg);
    border-color: var(--mmn-success-border);
    border-left-color: var(--mmn-success-accent);
    color: var(--mmn-success-text);
}
.mm-toast--success .mm-toast__icon {
    background: rgba(16,185,129,0.12);
    color: var(--mmn-success-icon);
}
.mm-toast--success .mm-toast__progress {
    background: var(--mmn-success-accent);
}

/* ERROR */
.mm-toast--error {
    background: var(--mmn-error-bg);
    border-color: var(--mmn-error-border);
    border-left-color: var(--mmn-error-accent);
    color: var(--mmn-error-text);
}
.mm-toast--error .mm-toast__icon {
    background: rgba(239,68,68,0.12);
    color: var(--mmn-error-icon);
}
.mm-toast--error .mm-toast__progress {
    background: var(--mmn-error-accent);
}

/* WARNING */
.mm-toast--warning {
    background: var(--mmn-warning-bg);
    border-color: var(--mmn-warning-border);
    border-left-color: var(--mmn-warning-accent);
    color: var(--mmn-warning-text);
}
.mm-toast--warning .mm-toast__icon {
    background: rgba(249,115,22,0.12);
    color: var(--mmn-warning-icon);
}
.mm-toast--warning .mm-toast__progress {
    background: var(--mmn-warning-accent);
}

/* INFO */
.mm-toast--info {
    background: var(--mmn-info-bg);
    border-color: var(--mmn-info-border);
    border-left-color: var(--mmn-info-accent);
    color: var(--mmn-info-text);
}
.mm-toast--info .mm-toast__icon {
    background: rgba(59,130,246,0.12);
    color: var(--mmn-info-icon);
}
.mm-toast--info .mm-toast__progress {
    background: var(--mmn-info-accent);
}

/* ════════════════════════════════════════════════════════════
   5. ANIMACIONES
   ════════════════════════════════════════════════════════════ */
@keyframes mmn-slide-in {
    from {
        opacity: 0;
        transform: translateX(48px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes mmn-slide-out {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 120px;
        margin-bottom: 0;
    }
    to {
        opacity: 0;
        transform: translateX(48px) scale(0.95);
        max-height: 0;
        margin-bottom: -10px;
        padding-top: 0;
        padding-bottom: 0;
    }
}

@keyframes mmn-progress {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ════════════════════════════════════════════════════════════
   6. BADGE CAMPANA (navbar)
   ════════════════════════════════════════════════════════════ */
.mm-notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s;
    color: inherit;
}

.mm-notif-bell:hover {
    background: rgba(255,255,255,0.12);
    color: inherit;
    text-decoration: none;
}

.mm-notif-bell__icon {
    font-size: 18px;
    line-height: 1;
}

.mm-notif-bell__badge {
    position: absolute;
    top: 2px;
    right: 4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    border-radius: 999px;
    border: 2px solid transparent;
    display: none;
    box-shadow: 0 1px 4px rgba(239,68,68,0.4);
    animation: mmn-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mm-notif-bell__badge.mm-notif-bell__badge--visible {
    display: block;
}

@keyframes mmn-badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ════════════════════════════════════════════════════════════
   7. DROPDOWN DE NOTIFICACIONES
   ════════════════════════════════════════════════════════════ */
.mm-notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.14), 0 2px 10px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.07);
    z-index: var(--mmn-z);
    overflow: hidden;
    display: none;
    transform-origin: top right;
    animation: mmn-dropdown-in 0.2s ease-out;
}

.mm-notif-dropdown.mm-notif-dropdown--open {
    display: block;
}

@keyframes mmn-dropdown-in {
    from { opacity: 0; transform: scale(0.95) translateY(-6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.mm-notif-dropdown__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.mm-notif-dropdown__title {
    font-size: 13px;
    font-weight: 700;
    color: #1a202c;
    margin: 0;
}

.mm-notif-dropdown__mark-all {
    font-size: 11px;
    color: #3b82f6;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s;
}

.mm-notif-dropdown__mark-all:hover {
    opacity: 0.7;
}

.mm-notif-dropdown__list {
    max-height: 360px;
    overflow-y: auto;
    padding: 6px 0;
}

.mm-notif-dropdown__list::-webkit-scrollbar {
    width: 4px;
}

.mm-notif-dropdown__list::-webkit-scrollbar-track {
    background: transparent;
}

.mm-notif-dropdown__list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

.mm-notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.12s;
    text-decoration: none;
    color: inherit;
}

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

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

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

.mm-notif-item__dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b82f6;
    margin-top: 5px;
    display: none;
}

.mm-notif-item--unread .mm-notif-item__dot {
    display: block;
}

.mm-notif-item__icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.mm-notif-item__icon--success { background: rgba(16,185,129,0.12); color: #059669; }
.mm-notif-item__icon--error   { background: rgba(239,68,68,0.12);  color: #dc2626; }
.mm-notif-item__icon--warning { background: rgba(249,115,22,0.12); color: #ea580c; }
.mm-notif-item__icon--info    { background: rgba(59,130,246,0.12); color: #2563eb; }

.mm-notif-item__body {
    flex: 1;
    min-width: 0;
}

.mm-notif-item__title {
    font-size: 12.5px;
    font-weight: 600;
    color: #1a202c;
    margin: 0 0 2px 0;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mm-notif-item__text {
    font-size: 11.5px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mm-notif-item__time {
    font-size: 10.5px;
    color: #94a3b8;
    margin: 3px 0 0 0;
}

.mm-notif-dropdown__empty {
    padding: 32px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.mm-notif-dropdown__empty i {
    display: block;
    font-size: 28px;
    margin-bottom: 8px;
    opacity: 0.4;
}

.mm-notif-dropdown__footer {
    border-top: 1px solid rgba(0,0,0,0.06);
    padding: 10px 16px;
    text-align: center;
}

.mm-notif-dropdown__footer a {
    font-size: 12px;
    color: #3b82f6;
    font-weight: 600;
    text-decoration: none;
}

.mm-notif-dropdown__footer a:hover {
    text-decoration: underline;
}

/* Wrapper con posicionamiento relativo para el dropdown */
.mm-notif-wrapper {
    position: relative;
}

/* ════════════════════════════════════════════════════════════
   8. BANNER DE PERMISO PUSH
   ════════════════════════════════════════════════════════════ */
#mm-push-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: calc(var(--mmn-z) - 1);
    background: #1e293b;
    color: #f1f5f9;
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    max-width: 520px;
    width: calc(100% - 32px);
    animation: mmn-slide-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    font-size: 13px;
}

.mm-push-banner__text {
    flex: 1;
    line-height: 1.4;
}

.mm-push-banner__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.mm-push-banner__btn {
    border: none;
    border-radius: 7px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.mm-push-banner__btn:hover { opacity: 0.85; }

.mm-push-banner__btn--allow {
    background: var(--brand, #C9A24A);
    color: #fff;
}

.mm-push-banner__btn--dismiss {
    background: rgba(255,255,255,0.1);
    color: #cbd5e1;
}

/* ════════════════════════════════════════════════════════════
   9. DARK MODE (body:not(.sb-light))
   ════════════════════════════════════════════════════════════ */
body:not(.sb-light) .mm-notif-dropdown {
    background: #1c2038;
    border-color: rgba(255,255,255,.08);
    box-shadow: 0 8px 40px rgba(0,0,0,.45), 0 2px 10px rgba(0,0,0,.3);
}
body:not(.sb-light) .mm-notif-dropdown__header {
    border-bottom-color: rgba(255,255,255,.07);
}
body:not(.sb-light) .mm-notif-dropdown__title {
    color: rgba(224,229,255,.92);
}
body:not(.sb-light) .mm-notif-item {
    color: rgba(224,229,255,.75);
}
body:not(.sb-light) .mm-notif-item:hover {
    background: rgba(255,255,255,.05);
    color: rgba(224,229,255,.92);
}
body:not(.sb-light) .mm-notif-item--unread {
    background: rgba(201,162,74,.1);
}
body:not(.sb-light) .mm-notif-item--unread:hover {
    background: rgba(201,162,74,.17);
}
body:not(.sb-light) .mm-notif-item__title {
    color: rgba(224,229,255,.92);
}
body:not(.sb-light) .mm-notif-item__text {
    color: rgba(180,190,230,.6);
}
body:not(.sb-light) .mm-notif-item__time {
    color: rgba(180,190,230,.38);
}
body:not(.sb-light) .mm-notif-dropdown__empty {
    color: rgba(180,190,230,.45);
}
body:not(.sb-light) .mm-notif-dropdown__footer {
    border-top-color: rgba(255,255,255,.07);
}
body:not(.sb-light) .mm-notif-dropdown__list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12);
}
/* Badge border adapts to dark topbar */
body:not(.sb-light) .mm-notif-bell__badge {
    border-color: #0e1021;
}

/* ════════════════════════════════════════════════════════════
   DARK MODE — Toasts
   ════════════════════════════════════════════════════════════ */
body:not(.sb-light) .mm-toast {
    background: #1c2038;
    box-shadow: 0 4px 24px rgba(0,0,0,.45), 0 1px 6px rgba(0,0,0,.3);
}
body:not(.sb-light) .mm-toast__title {
    color: rgba(224,229,255,.92);
}
body:not(.sb-light) .mm-toast__message {
    color: rgba(180,190,230,.72);
}
body:not(.sb-light) .mm-toast__close {
    color: rgba(180,190,230,.6);
}

/* SUCCESS dark */
body:not(.sb-light) .mm-toast--success {
    background: #0d2318;
    border-color: rgba(16,185,129,.25);
    border-left-color: #10b981;
    color: rgba(224,229,255,.92);
}
body:not(.sb-light) .mm-toast--success .mm-toast__icon {
    background: rgba(16,185,129,.18);
    color: #34d399;
}
body:not(.sb-light) .mm-toast--success .mm-toast__message {
    color: rgba(167,243,208,.75);
}

/* ERROR dark */
body:not(.sb-light) .mm-toast--error {
    background: #220d0d;
    border-color: rgba(239,68,68,.25);
    border-left-color: #ef4444;
    color: rgba(224,229,255,.92);
}
body:not(.sb-light) .mm-toast--error .mm-toast__icon {
    background: rgba(239,68,68,.18);
    color: #f87171;
}
body:not(.sb-light) .mm-toast--error .mm-toast__message {
    color: rgba(252,165,165,.75);
}

/* WARNING dark */
body:not(.sb-light) .mm-toast--warning {
    background: #1f1608;
    border-color: rgba(249,115,22,.25);
    border-left-color: #f97316;
    color: rgba(224,229,255,.92);
}
body:not(.sb-light) .mm-toast--warning .mm-toast__icon {
    background: rgba(249,115,22,.18);
    color: #fb923c;
}
body:not(.sb-light) .mm-toast--warning .mm-toast__message {
    color: rgba(253,186,116,.75);
}

/* INFO dark */
body:not(.sb-light) .mm-toast--info {
    background: #0d1628;
    border-color: rgba(59,130,246,.25);
    border-left-color: #3b82f6;
    color: rgba(224,229,255,.92);
}
body:not(.sb-light) .mm-toast--info .mm-toast__icon {
    background: rgba(59,130,246,.18);
    color: #60a5fa;
}
body:not(.sb-light) .mm-toast--info .mm-toast__message {
    color: rgba(147,197,253,.75);
}

/* ════════════════════════════════════════════════════════════
   10. RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    #mm-toast-container {
        right: 12px;
        left: 12px;
        bottom: 16px;
        width: auto;
    }

    .mm-notif-dropdown {
        width: 300px;
        right: -8px;
    }
}
