/*
 * ShowDogCentral toast + confirm-modal styles.
 * Scoped under .sdc-toast-stack / .sdc-toast / .sdc-confirm-* to avoid any
 * collision with Bootstrap's .toast / .modal classes.
 *
 * Design targets (Round 116 TLC pass):
 *  - DM Sans + royal purple palette to match saved.css, landing.css.
 *  - Body copy is INK (--ink) on every variant — semantics are carried by the
 *    tinted background, tinted border, and colored icon. No left color bar
 *    (removed on explicit user direction — don't reintroduce it).
 *  - 15px/1.45 desktop, 16px mobile (older-audience rule in CLAUDE.md).
 *  - Dismiss target 40x40 desktop, 44x44 mobile (Apple HIG).
 *  - Top-center across all viewports; individual toast cards are capped at 400px.
 *  - prefers-reduced-motion crossfade.
 *  - z-index above Bootstrap 5 modals (1055) and any in-app drawer (1050).
 */

.sdc-toast-stack {
    --toast-ink: var(--ink);
    --toast-bg: #ffffff;
    --toast-border: var(--line);
    --toast-shadow: 0 10px 40px -8px rgba(15, 23, 42, 0.22),
                    0 6px 14px -4px rgba(81, 28, 102, 0.10);
    --toast-radius: var(--radius-md);

    --toast-success: var(--success);
    --toast-success-bg:     #ecfdf5;
    --toast-success-border: #b9e6d4;
    --toast-error: var(--danger);
    --toast-error-bg:       #fef2f2;
    --toast-error-border:   #f3c6c6;
    --toast-info: var(--brand-vivid);
    --toast-info-bg:        #f5f3ff;
    --toast-info-border:    #ddd3f0;
    --toast-warning: var(--warn);
    --toast-warning-bg:     #fffbeb;
    --toast-warning-border: #f0dfae;

    position: fixed;
    z-index: 10000;
    pointer-events: none;
    /* Top-center: full-width stack with horizontal padding so card
       edges never touch the viewport, and align-items: center centers
       each individual toast card (which carries its own max-width).
       Avoids `transform: translateX(-50%)` so it doesn't collide with
       the per-toast slide-in transform. */
    left: 0;
    right: 0;
    /* App uses a sticky <nav class="navbar"> at top:0 (~68-75px tall). Offset
       enough to clear it on desktop, plus env(safe-area-inset-top) for
       notched iOS devices where the nav's position:sticky doesn't itself
       respect the safe area. */
    top: calc(88px + env(safe-area-inset-top, 0px));
    bottom: auto;

    display: flex;
    /* column-reverse + top anchor → newest toast sits at the top of the stack
       (closest to the viewport edge), older ones push down. Matches iOS
       notification banner stacking. */
    flex-direction: column-reverse;
    align-items: center;
    gap: 12px;

    width: auto;
    margin: 0;
    padding: 0 16px;

    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    /* Round 116: 15px ink body — the old 13px was the smallest type in the
       app, on the audience the project rules say needs larger. Mobile bumps
       to 16px in the @media block. */
    font-size: 15px;
    line-height: 1.45;
    color: var(--toast-ink);
}

.sdc-toast {
    pointer-events: auto;
    background: var(--toast-bg);
    border: 1px solid var(--toast-border);
    border-radius: var(--toast-radius);
    box-shadow: var(--toast-shadow);
    padding: 12px 10px 12px 16px;

    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 12px;

    min-width: 220px;
    max-width: 400px;
    width: 100%;

    transform: translateY(-16px);
    opacity: 0;
    transition: transform 180ms cubic-bezier(.2,.8,.2,1), opacity 180ms ease-out;
}

.sdc-toast.show   { transform: translateY(0);    opacity: 1; }
.sdc-toast.hiding { transform: translateY(-16px); opacity: 0; }

/* Round 116: body text stays ink on every variant — the tinted ground,
   tinted border, and colored icon carry the semantics. */
.sdc-toast--success {
    background: var(--toast-success-bg);
    border-color: var(--toast-success-border);
}
.sdc-toast--error {
    background: var(--toast-error-bg);
    border-color: var(--toast-error-border);
}
.sdc-toast--info {
    background: var(--toast-info-bg);
    border-color: var(--toast-info-border);
}
.sdc-toast--warning {
    background: var(--toast-warning-bg);
    border-color: var(--toast-warning-border);
}

.sdc-toast__icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    margin-top: 0;
}
.sdc-toast--success .sdc-toast__icon { color: var(--toast-success); }
.sdc-toast--error   .sdc-toast__icon { color: var(--toast-error); }
.sdc-toast--info    .sdc-toast__icon { color: var(--toast-info); }
.sdc-toast--warning .sdc-toast__icon { color: var(--toast-warning); }

.sdc-toast__body {
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}

.sdc-toast__action {
    background: transparent;
    border: 0;
    padding: 4px 10px;
    margin: 0;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    color: inherit;
    text-decoration: underline;
    min-height: 40px;
    border-radius: 8px;
}
.sdc-toast__action:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.sdc-toast__dismiss {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 0;
    flex-shrink: 0;
    transition: opacity 120ms ease-out, background-color 120ms ease-out;
}
.sdc-toast__dismiss svg {
    width: 22px;
    height: 22px;
}
.sdc-toast__dismiss:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}
.sdc-toast__dismiss:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    opacity: 1;
}

/* --- Mobile: full-width cards, tighter offsets --------------------- */
@media (max-width: 600px) {
    .sdc-toast-stack {
        /* Mobile nav is ~75px tall; offset enough to clear it + safe-area. */
        top: calc(84px + env(safe-area-inset-top, 0px));
        padding: 0 8px;
    }
    .sdc-toast {
        min-width: 0;
        max-width: none;
        font-size: 16px; /* older-users rule from CLAUDE.md — match page baseline on phones */
        padding: 12px 10px 12px 16px;
        grid-template-columns: auto 1fr auto;
    }
    .sdc-toast__dismiss {
        width: 44px;
        height: 44px; /* full Apple HIG target on touch devices */
    }

    /* Hide the text-underline action on the tightest widths; the toast
       itself remains tappable and any CTA should be accessible via the
       surrounding page UI. */
    .sdc-toast__action {
        grid-column: 2 / 4;
        grid-row: 2;
        justify-self: flex-start;
        margin-top: 4px;
    }
}

/* --- Reduced motion: crossfade only --------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .sdc-toast {
        transition: opacity 150ms linear;
        transform: none !important;
    }
    .sdc-toast.show, .sdc-toast.hiding { transform: none !important; }
}

/* --- Confirm modal -------------------------------------------------- */

.sdc-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 160ms ease-out;
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
.sdc-confirm-backdrop.show   { opacity: 1; }
.sdc-confirm-backdrop.hiding { opacity: 0; }

.sdc-confirm-dialog {
    background: #ffffff;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    padding: 32px;
    box-shadow: 0 24px 64px -12px rgba(15, 23, 42, 0.25);
    transform: translateY(8px);
    transition: transform 160ms cubic-bezier(.2,.8,.2,1);
}
.sdc-confirm-backdrop.show .sdc-confirm-dialog { transform: translateY(0); }

/* Round 116: intent icon beside the title so danger reads before a word does. */
.sdc-confirm__head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 0 0 10px;
}
.sdc-confirm__badge {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sdc-confirm__badge svg { width: 24px; height: 24px; }
.sdc-confirm__badge--default { background: #ede9fe; color: var(--brand); }
.sdc-confirm__badge--danger  { background: #fde8e8; color: #b91c1c; }

.sdc-confirm__title {
    margin: 4px 0 0;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.25;
}
.sdc-confirm__msg {
    margin: 0 0 26px;
    font-size: 17px;
    line-height: 1.55;
    color: #1a1a2e;
}
.sdc-confirm__actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}
.sdc-confirm__cancel,
.sdc-confirm__ok {
    min-height: 48px;
    padding: 0 22px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
    color: #1a1a2e;
    transition: background-color 120ms ease-out, border-color 120ms ease-out,
                transform 80ms ease-out;
}
.sdc-confirm__cancel:hover { background: #f1f5f9; }
.sdc-confirm__cancel:focus-visible,
.sdc-confirm__ok:focus-visible {
    outline: 3px solid var(--brand-vivid);
    outline-offset: 2px;
}

.sdc-confirm__ok--default {
    background: var(--brand);
    color: #ffffff;
    border-color: var(--brand);
}
.sdc-confirm__ok--default:hover { background: #3d1550; border-color: #3d1550; }

.sdc-confirm__ok--danger {
    background: #b91c1c;
    color: #ffffff;
    border-color: #b91c1c;
}
.sdc-confirm__ok--danger:hover { background: #991b1b; border-color: #991b1b; }

@media (max-width: 600px) {
    .sdc-confirm-dialog { padding: 24px; }
    .sdc-confirm__title { font-size: 20px; }
    .sdc-confirm__msg   { font-size: 17px; }
    .sdc-confirm__actions {
        flex-direction: column-reverse;
        gap: 10px;
    }
    .sdc-confirm__cancel,
    .sdc-confirm__ok { width: 100%; min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    .sdc-confirm-backdrop,
    .sdc-confirm-dialog { transition: opacity 150ms linear; transform: none !important; }
}
