/*
 * 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:
 *  - DM Sans + royal/vivid purple palette to match saved.css, landing.css.
 *  - WCAG AA contrast on all type variants.
 *  - 44x44 touch targets (Apple HIG; older-users rule in CLAUDE.md).
 *  - Top-center across all viewports; individual toast cards are capped at 420px.
 *  - env(safe-area-inset-bottom) for iOS notched devices.
 *  - prefers-reduced-motion crossfade.
 *  - z-index above Bootstrap 5 modals (1055) and any in-app drawer (1050).
 */

.sdc-toast-stack {
    --toast-ink: #1a1a2e;
    --toast-ink-light: #4b5563;
    --toast-bg: #ffffff;
    --toast-border: #e2e8f0;
    --toast-shadow: 0 10px 40px -8px rgba(15, 23, 42, 0.22),
                    0 6px 14px -4px rgba(81, 28, 102, 0.10);
    --toast-radius: 12px;

    --toast-success:      #047857;
    --toast-success-bg:   #ecfdf5;
    --toast-success-text: #064e3b;
    --toast-error:        #b91c1c;
    --toast-error-bg:     #fef2f2;
    --toast-error-text:   #7f1d1d;
    --toast-info:         #6500F8;
    --toast-info-bg:      #f5f3ff;
    --toast-info-text:    #4c1d95;
    --toast-warning:      #b45309;
    --toast-warning-bg:   #fffbeb;
    --toast-warning-text: #78350f;

    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;
    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-left-width: 4px;
    border-radius: var(--toast-radius);
    box-shadow: var(--toast-shadow);
    padding: 14px 10px 14px 16px;

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

    min-width: 280px;
    max-width: 420px;
    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; }

.sdc-toast--success {
    border-left-color: var(--toast-success);
    background: var(--toast-success-bg);
    color: var(--toast-success-text);
}
.sdc-toast--error {
    border-left-color: var(--toast-error);
    background: var(--toast-error-bg);
    color: var(--toast-error-text);
}
.sdc-toast--info {
    border-left-color: var(--toast-info);
    background: var(--toast-info-bg);
    color: var(--toast-info-text);
}
.sdc-toast--warning {
    border-left-color: var(--toast-warning);
    background: var(--toast-warning-bg);
    color: var(--toast-warning-text);
}

.sdc-toast__icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    margin-top: 1px;
}
.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: 6px 10px;
    margin: 0;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    color: inherit;
    text-decoration: underline;
    min-height: 32px;
    border-radius: 6px;
}
.sdc-toast__action:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.sdc-toast__dismiss {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    color: inherit;
    opacity: 0.65;
    padding: 0;
    flex-shrink: 0;
    transition: opacity 120ms ease-out, background-color 120ms ease-out;
}
.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 */
        padding: 16px 12px 16px 16px;
        grid-template-columns: auto 1fr auto;
    }

    /* 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: 480px;
    width: 100%;
    padding: 28px;
    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); }

.sdc-confirm__title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.3;
}
.sdc-confirm__msg {
    margin: 0 0 24px;
    font-size: 16px;
    line-height: 1.5;
    color: #1a1a2e;
}
.sdc-confirm__actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}
.sdc-confirm__cancel,
.sdc-confirm__ok {
    min-height: 44px;
    padding: 0 20px;
    border-radius: 10px;
    font-size: 15px;
    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 #6500F8;
    outline-offset: 2px;
}

.sdc-confirm__ok--default {
    background: #511c66;
    color: #ffffff;
    border-color: #511c66;
}
.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: 22px; }
    .sdc-confirm__title { font-size: 19px; }
    .sdc-confirm__msg   { font-size: 16px; }
    .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; }
}
