/**
 * EpicSchool Modern Alert & Notification System
 * 
 * Replaces standard native browser alerts & confirms with sleek, brand-aligned custom dialogs.
 * Supports light and dark modes, brand colors (Epic Sky Blue #5AB9F3, Epic Lime Green #9DDA1A),
 * smooth entrance/exit animations, keyboard accessibility, and toast notifications.
 */

/* ── Modal Backdrop ── */
.epic-alert-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s ease;
}

.epic-alert-backdrop.epic-alert-visible {
    opacity: 1;
    visibility: visible;
}

/* ── Modal Dialog Box ── */
.epic-alert-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    background-color: #ffffff;
    border-radius: 1.25rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 1.75rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transform: scale(0.93) translateY(8px);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    font-family: inherit;
    color: #0f172a;
}

.epic-alert-visible .epic-alert-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Dark mode dialog */
.dark .epic-alert-dialog {
    background-color: #0f172a;
    border-color: rgba(51, 65, 85, 0.8);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

/* ── Close Button (Top Right) ── */
.epic-alert-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.625rem;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s ease;
}

.epic-alert-close:hover {
    background-color: #f1f5f9;
    color: #334155;
}

.dark .epic-alert-close:hover {
    background-color: #1e293b;
    color: #e2e8f0;
}

.epic-alert-close span {
    font-size: 1.125rem !important;
}

/* ── Icon Wrap & Glowing Rings ── */
.epic-alert-icon-wrap {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.125rem;
    position: relative;
    animation: epicAlertPulse 2s infinite ease-in-out;
}

.epic-alert-icon-wrap .material-symbols-outlined {
    font-size: 1.875rem !important;
}

/* Error / Danger */
.epic-alert-type-error .epic-alert-icon-wrap {
    background-color: #fff1f2;
    color: #e11d48;
    border: 1.5px solid #fecdd3;
    box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.12);
}
.dark .epic-alert-type-error .epic-alert-icon-wrap {
    background-color: rgba(225, 29, 72, 0.15);
    color: #fb7185;
    border-color: rgba(225, 29, 72, 0.35);
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.15);
}

/* Warning */
.epic-alert-type-warning .epic-alert-icon-wrap {
    background-color: #fffbeb;
    color: #d97706;
    border: 1.5px solid #fde68a;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12);
}
.dark .epic-alert-type-warning .epic-alert-icon-wrap {
    background-color: rgba(217, 119, 6, 0.15);
    color: #fbbf24;
    border-color: rgba(217, 119, 6, 0.35);
    box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.15);
}

/* Success */
.epic-alert-type-success .epic-alert-icon-wrap {
    background-color: #f5fbe8;
    color: #4f7709;
    border: 1.5px solid #d7f19e;
    box-shadow: 0 0 0 4px rgba(157, 218, 26, 0.18);
}
.dark .epic-alert-type-success .epic-alert-icon-wrap {
    background-color: rgba(157, 218, 26, 0.15);
    color: #9dda1a;
    border-color: rgba(157, 218, 26, 0.35);
    box-shadow: 0 0 0 4px rgba(157, 218, 26, 0.15);
}

/* Info */
.epic-alert-type-info .epic-alert-icon-wrap {
    background-color: #ebf6fd;
    color: #096bb0;
    border: 1.5px solid #adddf8;
    box-shadow: 0 0 0 4px rgba(90, 185, 243, 0.18);
}
.dark .epic-alert-type-info .epic-alert-icon-wrap {
    background-color: rgba(90, 185, 243, 0.15);
    color: #5ab9f3;
    border-color: rgba(90, 185, 243, 0.35);
    box-shadow: 0 0 0 4px rgba(90, 185, 243, 0.15);
}

/* Confirm / Question */
.epic-alert-type-confirm .epic-alert-icon-wrap {
    background-color: #f0fdf4;
    color: #0284c7;
    border: 1.5px solid #bae6fd;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}
.dark .epic-alert-type-confirm .epic-alert-icon-wrap {
    background-color: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    border-color: rgba(14, 165, 233, 0.35);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}

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

/* ── Title & Message Body ── */
.epic-alert-title {
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -0.015em;
    margin-bottom: 0.5rem;
    color: #0f172a;
}
.dark .epic-alert-title {
    color: #f8fafc;
}

.epic-alert-message {
    font-size: 0.875rem;
    line-height: 1.45;
    color: #64748b;
    margin-bottom: 1.5rem;
    word-break: break-word;
}
.dark .epic-alert-message {
    color: #94a3b8;
}

/* ── Action Buttons ── */
.epic-alert-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    justify-content: center;
}

.epic-alert-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.6875rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    text-decoration: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.epic-alert-btn:active {
    transform: scale(0.98);
}

/* Primary Button Styles */
.epic-alert-btn-primary {
    background-color: #0f172a;
    color: #ffffff;
}
.epic-alert-btn-primary:hover {
    background-color: #1e293b;
}
.dark .epic-alert-btn-primary {
    background-color: #f8fafc;
    color: #0f172a;
}
.dark .epic-alert-btn-primary:hover {
    background-color: #e2e8f0;
}

/* Destructive / Danger Confirm Button */
.epic-alert-btn-danger {
    background-color: #e11d48;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
}
.epic-alert-btn-danger:hover {
    background-color: #be123c;
    box-shadow: 0 6px 16px rgba(225, 29, 72, 0.35);
}

/* Success Button */
.epic-alert-btn-success {
    background-color: #4f7709;
    color: #ffffff;
}
.epic-alert-btn-success:hover {
    background-color: #3b5a06;
}
.dark .epic-alert-btn-success {
    background-color: #9dda1a;
    color: #1a2e05;
}

/* Cancel Button */
.epic-alert-btn-cancel {
    background-color: #ffffff;
    color: #475569;
    border: 1px solid #cbd5e1;
}
.epic-alert-btn-cancel:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}
.dark .epic-alert-btn-cancel {
    background-color: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}
.dark .epic-alert-btn-cancel:hover {
    background-color: #334155;
    color: #f8fafc;
}

/* ── Modern Toast Notifications ── */
#epic-toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    pointer-events: none;
    max-width: 420px;
    width: calc(100% - 2.5rem);
}

@media (max-width: 640px) {
    #epic-toast-container {
        top: 0.875rem;
        left: 0.875rem;
        right: 0.875rem;
        width: auto;
    }
}

.epic-toast-item {
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    background-color: #ffffff;
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
    font-family: inherit;
}

.epic-toast-item.epic-toast-show {
    transform: translateX(0);
    opacity: 1;
}

.epic-toast-item.epic-toast-hide {
    transform: translateX(120%);
    opacity: 0;
}

.dark .epic-toast-item {
    background-color: #0f172a;
    border-color: rgba(51, 65, 85, 0.8);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.epic-toast-icon-wrap {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.epic-toast-icon-wrap .material-symbols-outlined {
    font-size: 1.25rem !important;
}

.epic-toast-success .epic-toast-icon-wrap {
    background-color: #f5fbe8;
    color: #4f7709;
}
.dark .epic-toast-success .epic-toast-icon-wrap {
    background-color: rgba(157, 218, 26, 0.18);
    color: #9dda1a;
}

.epic-toast-error .epic-toast-icon-wrap {
    background-color: #fff1f2;
    color: #e11d48;
}
.dark .epic-toast-error .epic-toast-icon-wrap {
    background-color: rgba(225, 29, 72, 0.18);
    color: #fb7185;
}

.epic-toast-warning .epic-toast-icon-wrap {
    background-color: #fffbeb;
    color: #d97706;
}
.dark .epic-toast-warning .epic-toast-icon-wrap {
    background-color: rgba(217, 119, 6, 0.18);
    color: #fbbf24;
}

.epic-toast-info .epic-toast-icon-wrap {
    background-color: #ebf6fd;
    color: #096bb0;
}
.dark .epic-toast-info .epic-toast-icon-wrap {
    background-color: rgba(90, 185, 243, 0.18);
    color: #5ab9f3;
}

.epic-toast-content {
    flex: 1;
    min-width: 0;
}

.epic-toast-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}
.dark .epic-toast-title {
    color: #f8fafc;
}

.epic-toast-message {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.125rem;
    line-height: 1.4;
}
.dark .epic-toast-message {
    color: #94a3b8;
}

.epic-toast-close {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    margin: -0.25rem -0.25rem 0 0;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s ease;
}

.epic-toast-close:hover {
    color: #334155;
    background-color: #f1f5f9;
}
.dark .epic-toast-close:hover {
    color: #e2e8f0;
    background-color: #1e293b;
}

.epic-toast-close span {
    font-size: 1rem !important;
}

/* Toast Progress Line */
.epic-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background-color: currentColor;
    opacity: 0.35;
    width: 100%;
    transform-origin: left;
}

.epic-toast-success .epic-toast-progress { color: #4f7709; }
.dark .epic-toast-success .epic-toast-progress { color: #9dda1a; }
.epic-toast-error .epic-toast-progress { color: #e11d48; }
.epic-toast-warning .epic-toast-progress { color: #d97706; }
.epic-toast-info .epic-toast-progress { color: #096bb0; }
.dark .epic-toast-info .epic-toast-progress { color: #5ab9f3; }
