/* =========================================================
   YasCash System Layer
   Final typography, responsive hardening and global toasts.
   Load this file last in every interactive layout.
   ========================================================= */

:root {
    --yc-ui-font: "Tajawal", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
    --yc-toast-width: min(390px, calc(100vw - 28px));
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body,
button,
input,
select,
textarea {
    font-family: var(--yc-ui-font) !important;
}

/*
 * بعض ملفات الإدارة القديمة كانت تستخدم Outfit لعناوين/أرقام متفرقة.
 * نحافظ على خط واجهة واحد في كل الشاشات بدون التأثير على خط رمز الريال.
 */
.yc-shell :where(a, button, input, select, textarea, label, p, span, strong, small, h1, h2, h3, h4, h5, h6, th, td),
.ya18-shell :where(a, button, input, select, textarea, label, p, span, strong, small, h1, h2, h3, h4, h5, h6, th, td),
.yc-public-body :where(a, button, input, select, textarea, label, p, span, strong, small, h1, h2, h3, h4, h5, h6, th, td) {
    font-family: var(--yc-ui-font) !important;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

main,
form,
fieldset,
.yc-page,
.yc-card,
.ya18-content,
.ya18-page-enter {
    min-width: 0;
}

.yc-table-wrap,
.yc-report-table-wrap,
[class*="table-wrap"] {
    -webkit-overflow-scrolling: touch;
}

/* =========================================================
   Global toast notifications
   ========================================================= */

.yc-global-toast-queue {
    display: none !important;
}

.yc-global-toast-stack {
    position: fixed;
    z-index: 20000;
    top: max(16px, env(safe-area-inset-top));
    inset-inline-start: max(16px, env(safe-area-inset-left));
    width: var(--yc-toast-width);
    display: grid;
    gap: 10px;
    pointer-events: none;
}

.yc-global-toast {
    --yc-toast-accent: var(--theme-blue, #3f70df);
    --yc-toast-accent-soft: color-mix(in srgb, var(--yc-toast-accent) 11%, transparent);

    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 30px;
    gap: 10px;
    align-items: start;
    width: 100%;
    padding: 12px 12px 13px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--yc-toast-accent) 24%, var(--theme-border, #d5dee8));
    border-radius: 14px;
    color: var(--theme-text, #17243a);
    background: color-mix(in srgb, var(--theme-surface-solid, #f9fafc) 94%, transparent);
    box-shadow: 0 16px 42px rgba(15, 31, 55, .18);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transform: translateY(-10px) scale(.985);
    opacity: 0;
    pointer-events: auto;
    transition: opacity 170ms ease, transform 170ms ease;
}

.yc-global-toast.success {
    --yc-toast-accent: var(--theme-green, #118f69);
}

.yc-global-toast.error {
    --yc-toast-accent: var(--theme-red, #cf4d61);
}

.yc-global-toast.warning {
    --yc-toast-accent: var(--theme-orange, #bd780d);
}

.yc-global-toast.info {
    --yc-toast-accent: var(--theme-blue, #3f70df);
}

.yc-global-toast.is-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.yc-global-toast.is-leaving {
    transform: translateY(-7px) scale(.985);
    opacity: 0;
}

.yc-global-toast-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--yc-toast-accent);
    background: var(--yc-toast-accent-soft);
}

.yc-global-toast-icon svg {
    width: 19px;
    height: 19px;
}

.yc-global-toast-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
    padding-top: 1px;
}

.yc-global-toast-copy strong {
    color: var(--theme-text, #17243a);
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.4;
}

.yc-global-toast-message {
    color: var(--theme-text-soft, #68778d);
    font-size: .74rem;
    font-weight: 600;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.yc-global-toast-close {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 9px;
    color: var(--theme-text-soft, #68778d);
    background: transparent;
    cursor: pointer;
}

.yc-global-toast-close:hover,
.yc-global-toast-close:focus-visible {
    color: var(--theme-text, #17243a);
    background: color-mix(in srgb, var(--theme-text, #17243a) 7%, transparent);
    outline: none;
}

.yc-global-toast-close svg {
    width: 16px;
    height: 16px;
}

.yc-global-toast-progress {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    transform-origin: right center;
    background: var(--yc-toast-accent);
    opacity: .56;
    animation: ycGlobalToastProgress 4.5s linear forwards;
}

.yc-global-toast.error .yc-global-toast-progress {
    animation-duration: 6.5s;
}

.yc-global-toast.warning .yc-global-toast-progress {
    animation-duration: 6s;
}

.yc-global-toast:hover .yc-global-toast-progress,
.yc-global-toast:focus-within .yc-global-toast-progress {
    animation-play-state: paused;
}

@keyframes ycGlobalToastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* =========================================================
   Responsive hardening
   ========================================================= */

@media (max-width: 900px) {
    .yc-page-heading,
    .yc-entity-heading {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 12px;
    }

    .yc-page-heading > div,
    .yc-entity-heading > div {
        min-width: 0;
    }

    .yc-page-heading h1,
    .yc-entity-heading h1 {
        overflow-wrap: anywhere;
    }

    .yc-form-actions,
    .yc-page-actions,
    .yc-card-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 700px) {
    :root {
        --yc-toast-width: calc(100vw - 24px);
    }

    body {
        overflow-x: hidden;
    }

    input,
    select,
    textarea {
        /* يمنع تكبير Safari التلقائي عند التركيز على الحقول. */
        font-size: 16px !important;
    }

    .yc-global-toast-stack {
        top: max(12px, env(safe-area-inset-top));
        inset-inline: 12px;
        width: auto;
    }

    .yc-global-toast {
        grid-template-columns: 36px minmax(0, 1fr) 28px;
        padding: 11px;
        border-radius: 13px;
    }

    .yc-global-toast-icon {
        width: 36px;
        height: 36px;
    }

    .yc-profile-main-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .yc-profile-photo-column {
        width: 100% !important;
        flex-basis: auto !important;
    }

    .yc-profile-fields-grid,
    .yc-profile-security-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .yc-profile-fields-grid .full {
        grid-column: auto !important;
    }

    .yc-modal-card,
    .yc-admin-confirm-card,
    .yc-email-confirm-card {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
    }

    .yc-table-wrap,
    [class*="table-wrap"] {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yc-global-toast,
    .yc-global-toast-progress {
        animation: none !important;
        transition: none !important;
    }
}
