/* Customer-facing mobile polish */

.btn-primary,
.btn-secondary,
.btn-outline,
.btn-link,
.btn-cta,
.payment-submit,
.checkout-btn,
.submit-btn,
.dp-cta,
.danger-btn,
.secondary-btn {
    min-height: 44px;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.card-sub,
.item-desc,
.dp-subtitle,
.summary-subtitle,
.lede,
.page-sub,
.muted-card,
.message-box,
.voucher-note,
.delete-card p,
.danger-zone p,
.footer-brand p {
    max-width: 62ch;
}

.card-sub,
.item-desc,
.dp-subtitle,
.summary-subtitle,
.lede,
.page-sub {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.payment-help,
.payment-preview-result,
.payment-preview-note {
    display: none !important;
}

.payment-panel {
    overflow: visible;
}

.payment-selector,
.payment-grid,
.payment-choice,
.payment-choice-head,
.payment-choice-head>span,
.payment-method-badges,
.payment-submit-bar {
    min-width: 0;
    max-width: 100%;
}

.payment-selector {
    width: 100%;
    gap: 12px;
}

.payment-selector-head {
    display: none !important;
}

.payment-grid {
    display: grid;
    gap: 10px;
}

.payment-choice {
    width: 100%;
    min-height: auto !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 26px;
    grid-template-areas:
        "content check"
        "badges badges";
    align-items: start;
    gap: 12px;
    padding: 16px !important;
    border-style: solid !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.payment-choice.is-preview-gateway {
    border-style: solid !important;
}

.payment-check {
    position: static !important;
    grid-area: check;
    margin-top: 2px;
    justify-self: end;
}

.payment-choice-head {
    grid-area: content;
    width: 100%;
}

.payment-choice-head>span {
    width: 100%;
}

.payment-choice-head strong,
.payment-choice-head small {
    overflow-wrap: anywhere;
}

.payment-method-badges {
    grid-area: badges;
    width: 100%;
    margin-top: 0 !important;
    padding-inline: 0 38px;
    overflow: hidden;
}

.payment-method-badges em {
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
}

.payment-submit-bar {
    width: 100%;
    display: block !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 8px;
    background: transparent !important;
    box-shadow: none !important;
    overflow: hidden;
}

.payment-submit-bar>div {
    display: none !important;
}

.payment-submit {
    width: min(100%, 220px);
    min-width: 0;
    margin-inline-start: auto;
    border-radius: 8px;
}

.dp-cover,
.course-cover,
.item-cover,
.card-cover,
.item-card>img {
    contain: paint;
}

.dp-cover {
    display: grid;
    place-items: center;
    background: #f8fafc;
}

.dp-cover img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain !important;
    object-position: center;
    background: #fff;
}

.dp-section,
.dp-desc {
    max-width: 100%;
    overflow: hidden;
}

.dp-section img,
.dp-desc img,
.dp-card img:not(.dp-cover img) {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: min(70vh, 520px);
    object-fit: contain;
    object-position: center;
    border-radius: 8px;
    background: #fff;
}

.item-card>img {
    display: block;
    height: auto;
    max-height: 320px;
    object-fit: contain !important;
    object-position: center;
    background: #fff;
}

@media (max-width: 760px) {
    :root {
        --container: min(100% - 20px, 560px);
        --bottom-nav-h: 72px;
    }

    body {
        font-size: 14px;
        line-height: 1.55;
    }

    .bottom-nav {
        gap: 0;
        border-top-color: rgba(226, 232, 240, .9);
    }

    .bottom-nav a,
    .bottom-nav button {
        min-width: 0;
        gap: 4px;
        padding: 7px 2px;
        font-size: .67rem;
        font-weight: 800;
    }

    .bottom-nav i {
        font-size: 1.12rem;
    }

    .bottom-nav .pill .badge {
        top: 3px;
        min-width: 15px;
        height: 15px;
        font-size: .58rem;
    }

    .drawer {
        width: min(90vw, 330px);
    }

    .drawer-head {
        padding: 12px 12px 10px;
    }

    .drawer .nav-logo-img {
        width: 84px;
        height: 42px;
    }

    .drawer-close {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }

    .drawer-body {
        padding: 10px 10px calc(var(--bottom-nav-h) + 18px);
        gap: 4px;
    }

    .drawer-account {
        grid-template-columns: 38px minmax(0, 1fr);
        gap: 9px;
        padding: 10px;
        border-radius: 12px;
    }

    .drawer-account-icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .drawer-account strong {
        font-size: .88rem;
    }

    .drawer-account small {
        font-size: .7rem;
    }

    .drawer-link {
        min-height: 39px;
        padding: 9px 10px;
        border-radius: 9px;
        font-size: .82rem;
        gap: 9px;
    }

    .drawer-link i {
        width: 18px;
        font-size: .9rem;
    }

    .drawer-section {
        padding: 10px 10px 3px;
        font-size: .64rem;
    }

    .news-ticker {
        min-height: 30px;
    }

    .nt-item {
        font-size: .78rem;
        white-space: nowrap;
    }

    .flash-stack {
        width: calc(100% - 20px);
        inset-inline: 10px;
    }

    .flash {
        padding: 11px 12px;
        border-radius: 8px;
        font-size: .86rem;
        line-height: 1.5;
    }

    .section,
    .features,
    .testimonials,
    .catalog,
    .course-page,
    .dp,
    .cart-page,
    .library,
    .orders-page,
    .profile-edit-page,
    .status-page,
    .order-page,
    .payment-page,
    .legal-page {
        width: var(--container) !important;
        margin-inline: auto !important;
    }

    main :where(.library, .catalog, .orders-page, .course-room, .dp, .cart-page, .payment-page, .status-page, .order-page) {
        font-size: .92rem;
    }

    .section {
        padding-block: 20px;
    }

    .section-head,
    .catalog-head,
    .cart-head,
    .status-hero,
    .order-hero,
    .course-hero,
    .payment-hero {
        gap: 10px;
    }

    .section-head h2,
    .catalog-title,
    .summary-title,
    .dp-title,
    .payment-hero h1,
    .status-hero h1,
    .order-hero h1,
    .profile-edit-page h1,
    .library h1 {
        font-size: 1.22rem !important;
        line-height: 1.35;
    }

    .library h1,
    .catalog-head,
    .cart-head {
        margin-bottom: 12px !important;
    }

    .catalog-sub,
    .section-bar .count,
    .item-meta,
    .lesson-desc {
        font-size: .74rem !important;
    }

    .section-bar {
        margin: 18px 0 10px !important;
        align-items: center !important;
    }

    .section-bar h2,
    .library h2,
    .orders-page h2 {
        font-size: .95rem !important;
    }

    .hero {
        min-height: 390px;
    }

    .hero-overlay-inner {
        width: calc(100% - 28px);
        padding-inline: 0;
    }

    .hero-overlay h1 {
        font-size: 1.7rem !important;
    }

    .hero-overlay p,
    .hero-trust,
    .features .lede,
    .testimonials .eyebrow,
    .see-all {
        display: none !important;
    }

    .cards-grid,
    .features-grid,
    .testimonial-grid,
    .catalog-grid,
    .cart-grid,
    .dp-grid,
    .page-grid,
    .order-grid,
    .status-grid,
    .payment-layout {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .card,
    .item-card,
    .feature,
    .testimonial,
    .panel,
    .dp-card,
    .payment-summary,
    .payment-panel,
    .status,
    .section .panel,
    .edit-card,
    .danger-zone,
    .tu-096 {
        border-radius: 10px !important;
        padding: 12px !important;
    }

    .item-card {
        padding: 0 !important;
    }

    .card-cover,
    .item-cover,
    .dp-cover,
    .course-cover {
        border-radius: 8px !important;
        overflow: hidden;
    }

    .card-body,
    .item-body,
    .dp-body {
        gap: 8px !important;
    }

    .item-body {
        padding: 11px !important;
    }

    .card-title,
    .item-title {
        font-size: .94rem !important;
        line-height: 1.45;
    }

    .card-sub,
    .item-desc,
    .dp-subtitle,
    .summary-subtitle,
    .footer-brand p,
    .danger-zone p,
    .delete-card p {
        font-size: .78rem !important;
        line-height: 1.6 !important;
    }

    .card-foot,
    .item-foot,
    .price-row,
    .summary-total,
    .total-box,
    .payment-submit-bar {
        grid-template-columns: 1fr !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .card-cta,
    .btn-cta,
    .btn-primary,
    .btn-secondary,
    .btn-outline,
    .checkout-btn,
    .submit-btn,
    .dp-cta,
    .payment-submit,
    .danger-btn,
    .secondary-btn {
        width: 100%;
        min-width: 0;
    }

    .chip,
    .tag,
    .status-chip,
    .status-pill,
    .dp-kicker {
        border-radius: 999px !important;
        font-size: .72rem !important;
        line-height: 1.35;
    }

    .tag-row,
    .badge-row,
    .card-badges,
    .payment-method-badges {
        gap: 6px !important;
    }

    .field-grid,
    .data-list,
    .summary-list,
    .voucher-grid,
    .tu-098 {
        grid-template-columns: 1fr !important;
    }

    .info-field,
    .data-item,
    .summary-list div,
    .row,
    .tu-099 {
        min-width: 0;
    }

    .order-details summary,
    .fold-box summary {
        min-height: 44px;
        font-size: .86rem;
    }

    .payment-choice {
        grid-template-columns: minmax(0, 1fr) 24px;
        padding: 12px !important;
        gap: 10px;
    }

    .payment-method-badges {
        padding-inline: 0 34px;
    }

    .payment-submit {
        width: 100%;
        margin-inline-start: 0;
    }

    .installment-widgets,
    [data-installment-widgets],
    .payment-provider-widget {
        max-width: 100%;
        overflow: hidden;
    }

    /* تصغير ودجت تابي وتمارا على الجوال — الويدجت طرف ثالث يرسم نفسه،
       فنستخدم zoom لتقليص الصندوق كاملاً بنسب متناسقة */
    .installment-widgets {
        gap: 8px;
    }

    .installment-official-widget {
        zoom: 0.82;
        -webkit-transform: scale(1);
        /* تقليل الحاشية الخارجية */
        padding: 0 !important;
        border-radius: 10px !important;
    }

    /* اطار خارجي رفيع بدل الحاشية الكبيرة التي يضعها الودجت داخلياً */
    .installment-official-widget[data-installment-provider="tabby"],
    .installment-official-widget[data-installment-provider="tamara"] {
        background: #fff;
    }

    /* تقليل ارتفاع الشعار */
    .installment-official-widget img,
    .installment-official-widget svg {
        max-height: 26px !important;
        width: auto !important;
    }

    .site-footer {
        padding-bottom: calc(var(--bottom-nav-h) + 18px);
    }

    .footer-grid {
        gap: 18px;
    }

    .footer-col a {
        min-height: 38px;
    }

    .payments-strip {
        justify-content: center;
        gap: 8px;
    }

    .delete-card {
        width: min(100% - 22px, 420px);
        padding: 18px !important;
        border-radius: 10px !important;
    }

    .danger-actions,
    .otp-actions,
    .actions-row {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
}

@media (max-width: 380px) {
    :root {
        --container: min(100% - 14px, 560px);
    }

    .bottom-nav span {
        font-size: .62rem;
    }

    .section-head h2,
    .catalog-title,
    .summary-title,
    .dp-title,
    .payment-hero h1,
    .status-hero h1,
    .order-hero h1 {
        font-size: 1.2rem !important;
    }

    /* في الشاشات الأضيق ضغط أكبر للودجت */
    .installment-official-widget {
        zoom: 0.74;
    }
}

/* iOS zooms the visual viewport when a focused control renders below 16px.
   That zoom is one of the triggers for the WebKit/Chrome fixed-footer drift,
   so keep editable controls at the platform-safe size on Apple touch devices. */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 879px) {
        input:not([type]),
        input:is([type="text"], [type="email"], [type="tel"], [type="url"], [type="search"], [type="password"], [type="number"], [type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]),
        textarea,
        select {
            font-size: 16px !important;
        }

        html.mobile-keyboard-open .bottom-nav,
        html.mobile-keyboard-open .wa-fab,
        html.mobile-keyboard-open .cs-mobile-question-nav,
        html.mobile-keyboard-open .cs-intake-panel.is-mobile-last-question > .cs-wizard-actions {
            opacity: 0 !important;
            visibility: hidden !important;
            pointer-events: none !important;
        }
    }
}
