/*
 * HKU Toast Notification System
 * --------------------------------------------------
 * Sağ üst köşede sabit toast container + 4 variant (success/danger/info/warning).
 * Vanilla CSS, framework bağımsız. HKU palet (hku-auth token seti: --hku-primary #003865) ile uyumlu.
 *
 * Kullanım:
 *   <link rel="stylesheet" href="~/css/hku-toast.css" asp-append-version="true" />
 *   JS API: HkuToast.success("Kayıt eklendi"); HkuToast.danger("Hata oluştu");
 */

/* ============================================================
   CSS Custom Properties (palet + spacing)
   ============================================================ */
:root {
    --hku-toast-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.06);
    --hku-toast-radius: 10px;
    --hku-toast-bg: #ffffff;
    --hku-toast-fg: #1f2937;
    --hku-toast-muted: #6b7280;
    --hku-toast-border: #e5e7eb;

    --hku-toast-success: var(--hku-success);
    --hku-toast-success-bg: #f0fdf4;

    --hku-toast-danger: var(--hku-danger);
    --hku-toast-danger-bg: #fef2f2;

    --hku-toast-info: var(--hku-info);
    --hku-toast-info-bg: #eff6ff;

    --hku-toast-warning: var(--hku-warn);
    --hku-toast-warning-bg: #fffbeb;
}

/* ============================================================
   Container — sağ üst köşede, topbar altında sabit
   ============================================================ */
#hku-toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: var(--hku-z-toast);
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none; /* container tıklanmaz, sadece toast'lar */
    max-width: 420px;
    width: auto;
}

/* ============================================================
   Toast item
   ============================================================ */
.hku-toast {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 320px;
    max-width: 420px;
    padding: 14px 16px 14px 16px;
    background-color: var(--hku-toast-bg);
    color: var(--hku-toast-fg);
    border: 1px solid var(--hku-toast-border);
    border-left: 4px solid var(--hku-toast-muted);
    border-radius: var(--hku-toast-radius);
    box-shadow: var(--hku-toast-shadow);
    font-size: 14px;
    line-height: 1.45;
    overflow: hidden;
    /* başlangıç durumu: sağdan slide-in */
    opacity: 0;
    transform: translateX(110%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.32s ease-out;
    will-change: transform, opacity;
}

.hku-toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.hku-toast.is-leaving {
    opacity: 0;
    transform: translateX(110%);
    transition: transform 0.28s ease-in, opacity 0.22s ease-in;
}

/* Hover'da auto-dismiss progress pause görsel hint */
.hku-toast:hover .hku-toast-progress-bar {
    animation-play-state: paused;
}

/* ============================================================
   Icon
   ============================================================ */
.hku-toast-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    margin-top: 1px;
}

/* ============================================================
   Body (title + message)
   ============================================================ */
.hku-toast-body {
    flex: 1 1 auto;
    min-width: 0; /* word-break için */
}

.hku-toast-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--hku-toast-fg);
    margin: 0 0 2px 0;
    line-height: 1.3;
    word-wrap: break-word;
}

.hku-toast-message {
    color: var(--hku-toast-fg);
    font-size: 13.5px;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.hku-toast-title + .hku-toast-message {
    color: var(--hku-toast-muted);
}

/* ============================================================
   Close button
   ============================================================ */
.hku-toast-close {
    flex: 0 0 auto;
    appearance: none;
    background: transparent;
    border: 0;
    padding: 2px 6px;
    margin: -2px -4px -2px 0;
    color: var(--hku-toast-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.hku-toast-close:hover,
.hku-toast-close:focus {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--hku-toast-fg);
    outline: none;
}

.hku-toast-close:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 51, 102, 0.35);
}

/* ============================================================
   Progress bar (kalan süre)
   ============================================================ */
.hku-toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background-color: rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.hku-toast-progress-bar {
    height: 100%;
    width: 100%;
    transform-origin: left center;
    animation-name: hku-toast-progress-shrink;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
    background-color: var(--hku-toast-muted);
}

@keyframes hku-toast-progress-shrink {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ============================================================
   Variants
   ============================================================ */
.hku-toast--success {
    border-left-color: var(--hku-toast-success);
    background-color: var(--hku-toast-success-bg);
}
.hku-toast--success .hku-toast-icon { color: var(--hku-toast-success); }
.hku-toast--success .hku-toast-progress-bar { background-color: var(--hku-toast-success); }

.hku-toast--danger {
    border-left-color: var(--hku-toast-danger);
    background-color: var(--hku-toast-danger-bg);
}
.hku-toast--danger .hku-toast-icon { color: var(--hku-toast-danger); }
.hku-toast--danger .hku-toast-progress-bar { background-color: var(--hku-toast-danger); }

.hku-toast--info {
    border-left-color: var(--hku-toast-info);
    background-color: var(--hku-toast-info-bg);
}
.hku-toast--info .hku-toast-icon { color: var(--hku-toast-info); }
.hku-toast--info .hku-toast-progress-bar { background-color: var(--hku-toast-info); }

.hku-toast--warning {
    border-left-color: var(--hku-toast-warning);
    background-color: var(--hku-toast-warning-bg);
}
.hku-toast--warning .hku-toast-icon { color: var(--hku-toast-warning); }
.hku-toast--warning .hku-toast-progress-bar { background-color: var(--hku-toast-warning); }

/* ============================================================
   Responsive — mobile full-width
   ============================================================ */
@media (max-width: 768px) {
    #hku-toast-container {
        top: 68px;
        left: 12px;
        right: 12px;
        max-width: none;
        width: auto;
    }

    .hku-toast {
        min-width: 0;
        max-width: none;
        width: 100%;
    }
}

/* ============================================================
   Reduced motion — animasyon kapalı
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .hku-toast {
        transition: opacity 0.15s ease-out;
        transform: none !important;
    }
    .hku-toast.is-leaving {
        transition: opacity 0.15s ease-in;
    }
    .hku-toast-progress-bar {
        animation: none !important;
        transform: scaleX(1);
    }
}

/* ============================================================
   Print — toast'lar gizli
   ============================================================ */
@media print {
    #hku-toast-container {
        display: none !important;
    }
}
