/* ============================================================================
 *  EgToastHost - η στοίβα ειδοποιήσεων
 * ----------------------------------------------------------------------------
 *  Αυτοτελές φύλλο στυλ: δεν εξαρτάται από reset, από grid framework ούτε από
 *  icon font. Ό,τι χρειάζεται ζει στα --egt-* tokens παρακάτω, οπότε μια
 *  εφαρμογή που θέλει άλλα χρώματα τα ξαναγράφει στο δικό της CSS χωρίς να
 *  αγγίξει το πακέτο:
 *
 *      .eg-toast-stack { --egt-error: #8e1f14; --egt-radius: 4px; }
 *
 *  Σύνδεση από το index.html της εφαρμογής:
 *      <link rel="stylesheet"
 *            href="_content/EgritosGroup.Blazor.EgrCoreLib/css/eg-toast.css" />
 * ========================================================================== */

.eg-toast-stack {
    --egt-radius: 10px;
    --egt-width: 380px;
    --egt-gap: 10px;
    --egt-edge: 20px;
    --egt-shadow: 0 10px 28px -6px rgba(15, 28, 44, .38), 0 2px 6px rgba(15, 28, 44, .2);
    --egt-sans: "Public Sans", "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    /* Οι τέσσερις τόνοι είναι σκουρότεροι από τους κλασικούς του toastr ώστε το λευκό
       κείμενο πάνω τους να περνά AA (>= 4.5:1) - το #f89406 του παλιού warning ήταν στο 2.8:1. */
    --egt-info: #10708a;
    --egt-success: #157f43;
    --egt-warning: #b45309;
    --egt-error: #c0392b;

    position: fixed;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: var(--egt-gap);
    width: var(--egt-width);
    max-width: calc(100vw - 2 * var(--egt-edge));
    /* Ο υποδοχέας απλώνεται πάνω από τη σελίδα - μόνο τα ίδια τα toasts πιάνουν κλικ. */
    pointer-events: none;
    font-family: var(--egt-sans);
}

.eg-toast-stack--bottom-right { right: var(--egt-edge); bottom: var(--egt-edge); }
.eg-toast-stack--bottom-left { left: var(--egt-edge); bottom: var(--egt-edge); }
.eg-toast-stack--top-right { right: var(--egt-edge); top: var(--egt-edge); }
.eg-toast-stack--top-left { left: var(--egt-edge); top: var(--egt-edge); }

.eg-toast-stack--top-center,
.eg-toast-stack--bottom-center {
    left: 50%;
    transform: translateX(-50%);
}

.eg-toast-stack--top-center { top: var(--egt-edge); }
.eg-toast-stack--bottom-center { bottom: var(--egt-edge); }

/* Τα αριστερά μπαίνουν από την αντίθετη πλευρά. */
.eg-toast-stack--bottom-left .eg-toast,
.eg-toast-stack--top-left .eg-toast { animation-name: eg-toast-in-left; }

.eg-toast-stack--bottom-left .eg-toast--leaving,
.eg-toast-stack--top-left .eg-toast--leaving { animation-name: eg-toast-out-left; }

/* ---------- Μπάρα στοίβας: πλήθος σε αναμονή + καθάρισμα ---------- */

.eg-toast-stackbar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: -2px;
}

.eg-toast-stackbar__more {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .01em;
    color: #fff;
    background: rgba(15, 28, 44, .82);
    border-radius: 999px;
    padding: 3px 10px;
}

.eg-toast-stackbar__clear {
    appearance: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .01em;
    color: #fff;
    background: rgba(15, 28, 44, .82);
    border-radius: 999px;
    padding: 3px 10px;
    transition: background-color .15s ease;
}

.eg-toast-stackbar__clear:hover { background: rgba(15, 28, 44, .95); }
.eg-toast-stackbar__clear:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ---------- Η κάρτα ---------- */

.eg-toast {
    pointer-events: auto;
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 12px;
    padding: 12px 12px 14px 12px;
    border-radius: var(--egt-radius);
    overflow: hidden;
    cursor: pointer;
    color: #fff;
    background: var(--egt-bg);
    box-shadow: var(--egt-shadow), inset 0 1px 0 rgba(255, 255, 255, .16);
    animation: eg-toast-in .26s cubic-bezier(.21, 1.02, .73, 1) both;
}

.eg-toast--info { --egt-bg: var(--egt-info); }
.eg-toast--success { --egt-bg: var(--egt-success); }
.eg-toast--warning { --egt-bg: var(--egt-warning); }
.eg-toast--error { --egt-bg: var(--egt-error); }

.eg-toast:hover { box-shadow: var(--egt-shadow), inset 0 1px 0 rgba(255, 255, 255, .24); }

.eg-toast--leaving {
    pointer-events: none;
    animation: eg-toast-out .22s ease-in both;
}

.eg-toast__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .17);
}

.eg-toast__icon svg { width: 17px; height: 17px; display: block; }
.eg-toast__icon i { font-size: 15px; line-height: 1; }

.eg-toast__body {
    min-width: 0;
    padding-top: 2px;
}

.eg-toast__title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .005em;
    margin-bottom: 2px;
}

.eg-toast__message {
    font-size: 13px;
    line-height: 1.45;
    color: rgba(255, 255, 255, .93);
    overflow-wrap: anywhere;
    /* Τα μηνύματα validation του backend έρχονται με αλλαγές γραμμής ανά σφάλμα -
       χωρίς αυτό κολλάνε όλα σε μία παράγραφο. */
    white-space: pre-line;
    cursor: auto;
    user-select: text;
    /* Τα validation μηνύματα του backend φτάνουν καμιά φορά τις 10 σειρές - κόβουμε
       με scroll αντί να γίνει το toast μισή οθόνη. */
    max-height: 8.7em;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .45) transparent;
}

.eg-toast__action {
    appearance: none;
    cursor: pointer;
    /* Το ίδιο στοιχείο ζωγραφίζεται άλλοτε ως <button> και άλλοτε ως <a href> (ActionUrl):
       οι δύο επόμενες ιδιότητες κρατούν την όψη ίδια και στις δύο περιπτώσεις. */
    display: inline-block;
    text-decoration: none;
    margin-top: 8px;
    padding: 4px 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .34);
    border-radius: 6px;
    transition: background-color .15s ease;
}

.eg-toast__action:hover,
.eg-toast__action:focus { background: rgba(255, 255, 255, .27); color: #fff; text-decoration: none; }
.eg-toast__action:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.eg-toast__tools {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: -2px -2px 0 0;
}

.eg-toast__count {
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 2px 7px;
    margin-right: 2px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .24);
}

.eg-toast__tool {
    appearance: none;
    border: 0;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    color: rgba(255, 255, 255, .78);
    transition: background-color .15s ease, color .15s ease;
}

.eg-toast__tool svg { width: 13px; height: 13px; display: block; }
.eg-toast__tool i { font-size: 13px; line-height: 1; }

.eg-toast__tool:hover {
    color: #fff;
    background: rgba(255, 255, 255, .18);
}

.eg-toast__tool:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

.eg-toast__progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(0, 0, 0, .16);
}

.eg-toast__progress i {
    display: block;
    height: 100%;
    background: rgba(255, 255, 255, .7);
    transform-origin: left center;
    /* Η διάρκεια μπαίνει inline από το component - εδώ μόνο η καμπύλη. */
    animation-name: eg-toast-progress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

/* Το hover πάνω στη στοίβα παγώνει ΟΛΕΣ τις μπάρες, όχι μόνο αυτή που δείχνει ο κέρσορας:
   η αντίστοιχη παύση στην C# πλευρά είναι κι αυτή καθολική.

   Ο δεύτερος selector είναι δίχτυ ασφαλείας: ο υποδοχέας έχει pointer-events:none, οπότε δεν
   είναι στόχος hit-testing και το :hover δεν τον πιάνει ποτέ. Το ίδιο το toast όμως το πιάνει
   πάντα, άρα η μπάρα κάτω από τον κέρσορα παγώνει ακόμη κι αν το data-paused δεν προλάβει. */
.eg-toast-stack[data-paused="true"] .eg-toast__progress i,
.eg-toast:hover .eg-toast__progress i {
    animation-play-state: paused;
}

/* ---------- Animations ---------- */

@keyframes eg-toast-in {
    from { opacity: 0; transform: translateX(26px) scale(.97); }
    to { opacity: 1; transform: none; }
}

@keyframes eg-toast-in-left {
    from { opacity: 0; transform: translateX(-26px) scale(.97); }
    to { opacity: 1; transform: none; }
}

/* Το max-height/padding μαζεύεται ώστε η στοίβα να κλείνει το κενό ομαλά
   αντί να αναπηδά η επόμενη κάρτα. */
@keyframes eg-toast-out {
    from { opacity: 1; transform: none; max-height: 360px; }
    to { opacity: 0; transform: translateX(26px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: calc(-1 * var(--egt-gap)); }
}

@keyframes eg-toast-out-left {
    from { opacity: 1; transform: none; max-height: 360px; }
    to { opacity: 0; transform: translateX(-26px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: calc(-1 * var(--egt-gap)); }
}

@keyframes eg-toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ---------- Κινητό ---------- */

@media (max-width: 575.98px) {
    .eg-toast-stack {
        --egt-edge: 10px;
        left: var(--egt-edge);
        right: var(--egt-edge);
        width: auto;
        max-width: none;
    }

    .eg-toast-stack--top-center,
    .eg-toast-stack--bottom-center { transform: none; }
}

/* ---------- Μειωμένη κίνηση ---------- */

@media (prefers-reduced-motion: reduce) {
    .eg-toast { animation-duration: .01ms; }
    .eg-toast--leaving { animation-duration: .01ms; }
    .eg-toast__progress i { animation: none; transform: scaleX(1); }
}
