/* نظام تجاوب موحّد — ضيوفنا
   Mobile < 640 | Tablet 640–1024 | Desktop > 1024
   يُحمَّل بعد ملفات الصفحة لضبط المشترك دون إعادة تصميم. */

:root {
    --rs-bp-sm: 640px;
    --rs-bp-lg: 1024px;
    --rs-gutter: clamp(1rem, 2.8vw, 2rem);
    --rs-content: 1300px;
    --rs-content-dash: 1200px;
    --rs-touch: 44px;
    --rs-radius: 16px;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: clip;
    scrollbar-gutter: stable;
    /* يمنع Double Tap Zoom ويبقي Pinch Zoom والتمرير */
    touch-action: manipulation;
}

html:has(body.dash-page) {
    overflow-x: visible;
}

body {
    max-width: 100%;
    overflow-x: hidden;
    touch-action: manipulation;
}

body.dash-page {
    overflow-x: visible;
}

.admin-main,
.dash-main,
.site-info,
.admin-inviter-card,
.admin-table-wrap,
.dash-panel,
.about-box {
    min-width: 0;
}

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

body:not(.page-vip-invite):not(.vip-studio-open) img,
body:not(.page-vip-invite):not(.vip-studio-open) video {
    height: auto;
}

iframe,
video {
    max-width: 100%;
}

.admin-btn,
.admin-send-btn,
.admin-side button,
.start-submit,
.pay-submit,
.start-btn,
.guest-cta,
.ws-btn,
.ws-invite-btn {
    min-height: var(--rs-touch);
}

input,
select,
textarea {
    max-width: 100%;
}

/* يمنع Auto Zoom في iPhone Safari/PWA عند التركيز، بدون منع Pinch Zoom */
@media (max-width: 1023.98px) {
    input,
    textarea,
    select {
        box-sizing: border-box;
        font-size: 16px !important;
        line-height: 1.2;
    }

    .quantity-stepper input {
        font-size: 1.25rem !important;
    }
}

/* ——— أدوات مشتركة لأي صفحة جديدة ——— */
.rs-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.rs-wrap {
    width: min(100% - (var(--rs-gutter) * 2), var(--rs-content));
    margin-inline: auto;
}

.rs-stack {
    display: grid;
    gap: 1rem;
}

.rs-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rs-actions > * {
    min-height: var(--rs-touch);
}

.rs-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
    .rs-grid-2,
    .rs-grid.rs-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .admin-user-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rs-grid-3,
    .rs-grid.rs-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .rs-grid-4,
    .rs-grid.rs-grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.rs-table,
.admin-table-wrap,
.dash-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.rs-table > table,
.admin-table-wrap > table {
    width: 100%;
}

@media (max-width: 1023.98px) {
    .admin-table-wrap > table {
        min-width: 36rem;
    }
}

dialog,
[role="dialog"],
.ws-order-dialog,
.vip-board-modal-card,
.vip-media-dialog,
.studio-dialog {
    max-width: min(calc(100vw - 1.5rem), 36rem);
    max-height: min(90dvh, calc(100dvh - 1.5rem));
    overflow: auto;
}

/* زر القائمة الموحّد */
.rs-menu-btn {
    display: none;
    width: var(--rs-touch);
    height: var(--rs-touch);
    padding: 0;
    border: 1px solid rgba(169, 130, 67, 0.22);
    border-radius: 12px;
    background: #fffdf9;
    color: inherit;
    cursor: pointer;
    place-items: center;
    gap: 5px;
    flex: 0 0 auto;
}

.rs-menu-btn span {
    display: block;
    width: 18px;
    height: 1.6px;
    background: currentColor;
}

.home .rs-menu-btn {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(196, 176, 138, 0.55);
    border-radius: 50%;
    background: #111;
    color: #f3ead8;
    box-shadow: 0 4px 12px rgba(17, 17, 17, 0.16);
    gap: 4px;
    align-content: center;
    justify-items: center;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.home .rs-menu-btn span {
    width: 15px;
    height: 1.35px;
    border-radius: 99px;
    background: #f3ead8;
}

.home .rs-menu-btn:hover {
    border-color: #c4b08a;
    box-shadow: 0 6px 16px rgba(17, 17, 17, 0.22);
}

.home .rs-menu-btn:active {
    transform: scale(0.96);
}

.rs-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(26, 22, 18, 0.42);
}

body.is-drawer-open {
    overflow: hidden;
}

body.is-drawer-open .rs-drawer-backdrop {
    display: block;
}

/* ——— الموقع العام: القائمة ——— */
.site-nav {
    position: relative;
}

.site-menu-btn {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    z-index: 4;
}

.site-nav-links {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    gap: inherit;
}

.site-nav-links a {
    color: inherit;
    text-decoration: none;
    padding-bottom: 0.45rem;
}

@media (min-width: 640px) and (max-width: 1023.98px) {
    .site-header {
        padding-inline: var(--rs-gutter);
    }

    .site-nav,
    .site-nav-links {
        gap: clamp(0.85rem, 2.4vw, 1.8rem);
    }

    .login-link {
        position: static;
        inset: auto;
        margin-left: 1.2rem;
    }
}

@media (max-width: 639.98px) {
    body:not(.home) .site-header {
        min-height: 0;
        padding: 0.75rem var(--rs-gutter);
    }

    body:not(.home) .site-nav {
        display: grid;
        grid-template-columns: var(--rs-touch) 1fr auto;
        align-items: center;
        min-height: var(--rs-touch);
    }

    body:not(.home) .site-nav .rs-menu-btn,
    body:not(.home) .site-nav .site-menu-btn {
        display: grid;
        position: static;
    }

    body:not(.home) .login-link {
        position: static;
        grid-column: 3;
        justify-self: end;
        margin: 0;
        min-height: var(--rs-touch);
    }

    body:not(.home) .site-nav-links {
        display: none;
        position: absolute;
        top: calc(100% + 0.45rem);
        inset-inline: 0;
        z-index: 12;
        padding: 0.65rem;
        border-radius: 16px;
        background: #fffdf9;
        border: 1px solid rgba(169, 130, 67, 0.18);
        box-shadow: 0 12px 28px rgba(26, 22, 18, 0.1);
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
    }

    body:not(.home) .site-nav.is-open .site-nav-links {
        display: flex;
    }

    body:not(.home) .site-nav-links a {
        padding: 0.7rem 0.75rem;
        border-radius: 10px;
        font-size: 0.95rem;
        white-space: normal;
    }

    body:not(.home) .site-nav-links a.is-active {
        background: rgba(169, 130, 67, 0.12);
        box-shadow: none;
    }

    .hero h1,
    .home .art-header h1 {
        white-space: normal;
    }

    .hero-perks,
    .home .art-header .hero-perks {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: stretch;
        justify-content: center;
        width: 100%;
        gap: 0;
    }

    .hero-perks li,
    .hero-perks li + li,
    .home .art-header .hero-perks li {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        border: 0;
        font-size: clamp(0.68rem, 2.4vw, 0.8rem);
        white-space: normal;
    }

    .hero-perks li + li,
    .home .art-header .hero-perks li + li {
        border-right: 1px solid rgba(169, 130, 67, 0.18);
    }

    .home .art-header-ui {
        min-height: 0;
    }

    .home .art-header .hero-copy {
        width: min(100%, 560px);
        margin-bottom: 2rem;
        padding-inline: 0.25rem;
    }

    .home .art-header .login-link,
    body.site-page .site-header .login-link {
        margin-left: 0;
    }

    .art-footer.site-footer,
    .home .art-footer.site-footer,
    .site-page .art-footer.site-footer,
    .site-footer {
        height: auto;
        min-height: 0;
        max-height: none;
        padding: 1.1rem var(--rs-gutter) 1rem;
    }

    body:not(.home) .art-footer .footer-brand,
    body.site-page .art-footer .footer-brand {
        position: static;
        display: block;
        text-align: center;
        margin: 0 auto 0.7rem;
        left: auto;
        top: auto;
    }

    .art-footer .footer-nav,
    .art-footer .footer-legal,
    .footer-nav,
    .footer-legal {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem 1.1rem;
        padding-top: 0;
    }

    .site-info {
        padding-inline: var(--rs-gutter);
    }
}

@media (min-width: 1024px) {
    .home .art-header-ui {
        min-height: 610px;
    }

    .dash-main {
        width: min(100% - 2.5rem, var(--rs-content-dash));
    }

    .admin-main {
        padding-inline: clamp(1.4rem, 2.4vw, 2.2rem);
    }
}

/* ——— لوحة الإدارة: درج جانبي ——— */
.admin-menu-btn {
    color: var(--ad-ink, #1a1612);
}

.admin-side {
    overflow-y: auto;
}

@media (max-width: 1023.98px) {
    body.admin-page {
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-menu-btn {
        display: grid;
    }

    .admin-side {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        z-index: 40;
        width: min(18rem, 86vw);
        transform: translateX(110%);
        transition: transform 0.22s ease;
        box-shadow: none;
    }

    [dir="rtl"] .admin-side {
        transform: translateX(110%);
    }

    .admin-side.is-open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(26, 22, 18, 0.28);
    }

    .admin-main {
        min-width: 0;
        padding: 1rem var(--rs-gutter) 2rem;
    }

    .admin-top {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.65rem;
    }

    .admin-top-start {
        flex: 1 1 auto;
        min-width: 0;
    }

    .admin-top h1 {
        font-size: clamp(1.05rem, 4vw, 1.35rem);
        line-height: 1.35;
    }

    .admin-top > p {
        width: 100%;
        font-size: 0.86rem;
    }

    .admin-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-page-head,
    .admin-inviter-head,
    .admin-inviter-actions,
    .admin-notify-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 0.55rem;
    }

    .admin-page-head {
        align-items: stretch;
    }

    .admin-form,
    .admin-inviter-tool {
        max-width: 100%;
    }

    .admin-inviter-tools {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-inviter-add-guest,
    .admin-inviter-tool,
    .admin-inviter-search,
    .admin-inviter-delete {
        grid-column: auto;
        flex: 1 1 auto;
    }

    .admin-inviter-add-guest {
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-inviter-tool input[type="text"],
    .admin-inviter-tool input[type="tel"],
    .admin-inviter-tool input[type="search"],
    .admin-inviter-tool input[type="number"],
    .admin-inviter-tool input[type="file"],
    .admin-inviter-tool .admin-btn {
        flex: 1 1 100%;
        width: 100%;
    }

    .admin-design-shop-card .admin-actions {
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-guest-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-notify-panel {
        position: fixed;
        top: 4.6rem;
        inset-inline: 0.75rem;
        width: auto;
        max-height: min(70dvh, calc(100dvh - 5.5rem));
    }

    .admin-rsvp-previews {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 639.98px) {
    .admin-mobile-push-devices li {
        align-items: center;
        flex-direction: row;
    }

    .admin-mobile-push-actions {
        align-items: stretch;
        flex-direction: row;
    }

    .admin-mobile-push .admin-btn {
        flex: 1 1 0;
        width: auto;
    }

    .admin-mobile-push-remove {
        width: auto;
    }

    .admin-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-stats article,
    .admin-form,
    .admin-table-wrap,
    .admin-inviter-card {
        padding: 0.9rem;
    }

    .admin-send-cell,
    .admin-invite-link,
    .admin-inviter-actions,
    .admin-guest-actions {
        gap: 0.4rem;
    }

    .admin-guest-actions {
        width: 100%;
        max-width: none;
        min-width: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-user-card-head,
    .admin-user-card-meta {
        gap: 0.55rem;
    }

    .admin-user-card.is-manageable > .admin-user-card-head {
        gap: 0.4rem 0.45rem;
    }

    .admin-user-card-name {
        font-size: 0.98rem;
    }

    .admin-user-actions {
        gap: 0.45rem;
    }

    .admin-user-action {
        min-height: var(--rs-touch);
        font-size: 0.84rem;
    }

    .admin-user-card-phone {
        font-size: 0.84rem;
    }

    .admin-user-card-links .admin-user-link {
        min-height: var(--rs-touch);
    }

    .admin-guest-actions .admin-action,
    .admin-guest-actions .admin-sent-ok {
        min-height: var(--rs-touch);
        padding: 0 0.85rem;
        font-size: 0.8rem;
    }

    .admin-calendar-day {
        min-height: 3.4rem;
        padding: 0.25rem 0.1rem;
    }

    .admin-calendar-day small {
        font-size: 0.62rem;
    }
}

@media (min-width: 1024px) {
    .admin-design-shop {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .admin-guest-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .admin-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ——— حساب المستخدم ——— */
@media (min-width: 640px) and (max-width: 1023.98px) {
    .dash-header-inner,
    .dash-main {
        width: min(100% - 2rem, var(--rs-content-dash));
    }

    .dash-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-stat:last-child {
        grid-column: 1 / -1;
    }

    .dash-quick {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 639.98px) {
    .dash-header-inner {
        width: min(100% - 1.5rem, var(--rs-content-dash));
        min-height: 72px;
    }

    .dash-main {
        width: min(100% - 1.5rem, var(--rs-content-dash));
        padding-top: 1rem;
    }

    .dash-menu-btn {
        display: grid;
        width: var(--rs-touch);
        height: var(--rs-touch);
    }

    .dash-account-name {
        display: none;
    }

    .dash-nav {
        display: none;
        position: absolute;
        top: calc(100% + 0.35rem);
        inset-inline: 0.75rem;
        z-index: 12;
        padding: 0.7rem;
        border-radius: 16px;
        background: #fff;
        border: 1px solid var(--dash-line, #eee);
        box-shadow: 0 12px 28px rgba(23, 23, 23, 0.08);
        flex-direction: column;
        align-items: stretch;
        gap: 0.2rem;
    }

    .dash-nav.is-open {
        display: flex;
    }

    .dash-nav a {
        min-height: var(--rs-touch);
        padding: 0.7rem 0.75rem;
        border-radius: 10px;
        display: flex;
        align-items: center;
    }

    html:has(body.dash-page),
    body.dash-page {
        height: 100%;
        height: 100svh;
        max-height: 100svh;
        overflow: hidden;
        transform: none;
        filter: none;
        perspective: none;
        contain: none;
    }

    body.dash-page {
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
    }

    .dash-shell {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: 0;
        transform: none;
        filter: none;
        perspective: none;
    }

    .dash-bottom {
        flex: 0 0 auto;
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 1000;
        display: grid;
        background: #fffdf9;
        background-color: #fffdf9;
        transform: none;
        filter: none;
        padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
    }

    .dash-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-stat:last-child {
        grid-column: 1 / -1;
    }

    .dash-quick {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-panel-head,
    .ws-card-head,
    .ws-balance-row,
    .ws-invite-form,
    .ws-guest-form,
    .ws-program-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0.7rem;
    }

    .inv-card dl {
        grid-template-columns: minmax(0, 1fr);
    }

    .pay-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .start-card,
    .pay-card,
    .inv-card,
    .login-box {
        padding: 1.35rem 1rem;
        width: min(100%, 520px);
    }

    .start-main,
    .pay-main,
    .pay-top,
    .inv-top,
    .inv-card {
        width: min(100% - 1.5rem, 720px);
    }
}

/* ——— لوحات المدعوين والاستوديو ——— */
@media (max-width: 1023.98px) {
    .vip-studio-grid,
    .studio-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .vip-media-modal {
        padding: 0.75rem;
        align-items: end;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 639.98px) {
    .vip-board-modal-card {
        width: min(100% - 1rem, 420px);
        margin: 0 0.5rem 0.75rem;
        max-height: min(88dvh, calc(100dvh - 1rem));
    }

    .vip-board-top,
    .vip-board-hero,
    .vip-board-manage {
        padding-inline: 0.85rem;
    }

    .guest-add,
    .guest-row,
    .list-toolbar,
    .board-top {
        grid-template-columns: minmax(0, 1fr);
    }

    .gi-wrap {
        width: min(100% - 1.5rem, 420px);
        padding-inline: 0;
        margin-inline: auto;
    }
}

@media (min-width: 1024px) {
    .vip-board-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 767.98px) {
    body.page-vip-invite:not(.vip-embed),
    body.page-vip-invite:not(.vip-embed) .invite,
    body.page-vip-invite:not(.vip-embed) .video-stage,
    body.page-vip-invite:not(.vip-embed) .frame {
        width: 100%;
        max-width: 100%;
    }
}
