/**
 * ZERTI admin layer: zerti-wp-chrome.css
 * WordPress page chrome reset, scrollbars, Jalali datepicker
 * Loaded via assets/css/zerti-admin.css manifest and includes/admin/assets.php.
 * @see docs/DESIGN-SYSTEM.md
 */

/**
 * ZERTI admin shell (toplevel_page_zerti-admin).
 * Body class matches menu slug zerti-admin (see ZERTI_ADMIN_PAGE_SLUG in zerti.php).
 */

#wpadminbar,
#adminmenumain,
#adminmenuback,
#adminmenuwrap,
#wpfooter,
#screen-meta,
#screen-meta-links,
.update-nag,
.notice {
    display: none !important;
}

html.wp-toolbar {
    padding-top: 0 !important;
}

html.wp-toolbar:has(body.toplevel_page_zerti-admin) {
    margin-top: 0 !important;
    overflow: hidden;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

/*
 * Core reserves ~160px (36px folded) for the admin menu on #wpwrap. This page hides the menu but
 * the margin remains. LTR uses margin-left; RTL admin uses margin-right — without clearing both,
 * a blank strip appears opposite the menu (often on the right in Persian/RTL installs).
 */
body.toplevel_page_zerti-admin #wpwrap,
body.toplevel_page_zerti-admin #wpcontent,
body.toplevel_page_zerti-admin #wpbody,
body.toplevel_page_zerti-admin #wpbody-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-inline: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-inline: 0 !important;
}

body.toplevel_page_zerti-admin #wpwrap {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
    overflow: hidden;
    max-height: 100dvh;
}

/* Core can still cap #wpcontent / #wpbody width on some installs — force full bleed for this screen. */
body.toplevel_page_zerti-admin #wpcontent,
body.toplevel_page_zerti-admin #wpbody,
body.toplevel_page_zerti-admin #wpbody-content {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}

body.toplevel_page_zerti-admin #wpbody-content {
    padding-bottom: 0;
    float: none;
}

/* Core admin reserves toolbar space â‰¤782px; bar is hidden on this screen. */
@media screen and (max-width: 782px) {
    html.wp-toolbar:has(body.toplevel_page_zerti-admin) {
        padding-top: 0 !important;
    }

    body.toplevel_page_zerti-admin #wpbody {
        padding-top: 0 !important;
    }

    body.toplevel_page_zerti-admin #wpbody-content {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
}

body.toplevel_page_zerti-admin #wpwrap,
body.toplevel_page_zerti-admin #wpcontent,
body.toplevel_page_zerti-admin #wpbody {
    min-height: 100vh;
    min-height: 100dvh;
}

body.toplevel_page_zerti-admin #wpbody-content > .wrap {
    margin: 0;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
    /* Lock to viewport so #zertiAdmin (same node when id=zertiAdmin) fills the screen, not content height. */
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* No visible scrollbars anywhere in ZERTI; keep overflow functional where needed. */
body.toplevel_page_zerti-admin,
body.toplevel_page_zerti-admin #zertiAdmin,
body.toplevel_page_zerti-admin #zertiAdmin * {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body.toplevel_page_zerti-admin #zertiAdmin *::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
    background: transparent;
}

/* Thin themed scrollbar — direction follows #zertiAdmin (RTL bar on physical left). Overrides global hide. */
body.toplevel_page_zerti-admin #zertiAdmin .zerti-scrollbar-thin {
    --zerti-scrollbar-size: 1px;
    --zerti-scrollbar-thumb: color-mix(in srgb, var(--zerti-docs-muted) 50%, var(--zerti-docs-border));
    --zerti-scrollbar-thumb-hover: color-mix(in srgb, var(--zerti-bs-purple) 42%, var(--zerti-docs-muted));
    direction: inherit;
    unicode-bidi: isolate;
    scrollbar-width: 0px;
    scrollbar-color: var(--zerti-scrollbar-thumb) transparent;
    -ms-overflow-style: auto;
    overscroll-behavior: contain;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-scrollbar-thin::-webkit-scrollbar {
    width: var(--zerti-scrollbar-size);
    height: var(--zerti-scrollbar-size);
    display: block;
    background: transparent;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-scrollbar-thin::-webkit-scrollbar-track {
    background: transparent;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-scrollbar-thin::-webkit-scrollbar-thumb {
    background-color: var(--zerti-scrollbar-thumb);
    border-radius: 999px;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background-color: var(--zerti-scrollbar-thumb-hover);
}

/* Jalali (Persian) datepicker popup — fixed compact panel on body (outside #zertiAdmin). */
body.toplevel_page_zerti-admin .zerti-jalali-datepicker {
    position: fixed !important;
    z-index: 100060;
    width: 17.5rem;
    max-width: calc(100vw - 1rem);
    margin: 0;
    display: none;
    direction: rtl;
    font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 9pt;
    line-height: 1.35;
    color: var(--zerti-docs-text);
    background: var(--zerti-docs-bg);
    border: 1px solid var(--zerti-docs-border);
    border-radius: 0.65rem;
    box-shadow: 0 12px 32px color-mix(in srgb, var(--zerti-docs-text) 16%, transparent);
    padding: 0.65rem;
    box-sizing: border-box;
    pointer-events: auto;
    inset: auto;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker.is-open {
    display: block;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker[data-bs-theme='dark'] {
    --zerti-docs-bg: #212529;
    --zerti-docs-subtle-bg: #2b3035;
    --zerti-docs-border: #495057;
    --zerti-docs-text: #dee2e6;
    --zerti-docs-muted: #adb5bd;
    color-scheme: dark;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker[data-bs-theme='light'] {
    --zerti-docs-bg: #fff;
    --zerti-docs-subtle-bg: #f8f9fa;
    --zerti-docs-border: #dee2e6;
    --zerti-docs-text: #212529;
    --zerti-docs-muted: #6c757d;
    color-scheme: light;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-bottom: 0.45rem;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__nav {
    flex: 0 0 auto;
    min-width: 1.75rem;
    padding-inline: 0.35rem;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__title {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__weekdays,
body.toplevel_page_zerti-admin .zerti-jalali-datepicker__days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.12rem;
    width: 100%;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__weekday {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--zerti-docs-muted);
    padding: 0.1rem 0;
    aspect-ratio: 1;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__day {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    max-height: 2.1rem;
    padding: 0;
    border: none;
    border-radius: 0.45rem;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1;
    cursor: pointer;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__day--empty {
    pointer-events: none;
    visibility: hidden;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__day:hover:not(.zerti-jalali-datepicker__day--selected) {
    background: color-mix(in srgb, var(--zerti-docs-subtle-bg) 70%, transparent);
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__day--today {
    box-shadow: inset 0 0 0 1px var(--zerti-docs-border);
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__day--selected {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-top: 0.4rem;
    padding-top: 0.35rem;
    border-top: 1px solid color-mix(in srgb, var(--zerti-docs-border) 65%, transparent);
}

body.toplevel_page_zerti-admin .zerti-jalali-datepicker__footer .btn-link {
    font-size: inherit;
    padding: 0.15rem 0.35rem;
    text-decoration: none;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-jalali-date-input {
    width: 7.5rem;
    max-width: 100%;
    flex: 0 0 auto;
    min-width: 7.5rem;
    text-align: center;
    letter-spacing: 0.02em;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-wc-sale-dates {
    flex-wrap: wrap;
    align-items: center;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-wc-sale-date-group {
    flex: 0 0 auto;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-wc-sale-date-label {
    flex: 0 0 auto;
    font-size: 9pt;
    font-weight: 600;
    color: var(--zerti-docs-muted);
    white-space: nowrap;
}

body.toplevel_page_zerti-admin #zertiAdmin .zerti-wc-sale-date-sep {
    flex: 0 0 auto;
    color: var(--zerti-docs-muted);
}

body.toplevel_page_zerti-admin #wpbody,
body.toplevel_page_zerti-admin #wpbody-content {
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100dvh;
}

body.toplevel_page_zerti-admin {
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    background-color: #212529;
    font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
    /* Above fixed theme switch / mobile menu (1060) and WP admin bar (~99999) so modals receive taps. */
    --bs-modal-zindex: 100050;
    --bs-backdrop-zindex: 100040;
}
