/* ==========================================================================
   هيكل التطبيق: عرض كامل على الشاشات الكبيرة + تجربة تطبيق على الهواتف
   ========================================================================== */

:root {
    --gutter: clamp(16px, 3.2vw, 56px);
    --appbar-h: 74px;
    --tabbar-h: 64px;
    /* هامش الشريط العلوي للنوتش: يُطبَّق فقط في التطبيق المثبت.
       داخل المتصفح يرسم المتصفح شريطه بنفسه، وبعض أجهزة سامسونج/أندرويد تُرجع
       ارتفاع شريط الحالة هنا فيظهر فراغ كبير فوق الهيدر. */
    --safe-top: 0px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    color-scheme: dark;
}
@media (display-mode: standalone), (display-mode: fullscreen) {
    :root { --safe-top: env(safe-area-inset-top, 0px); }
}
html.standalone { --safe-top: env(safe-area-inset-top, 0px); }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
a, button, label, summary { touch-action: manipulation; }

/* ---------- عرض الشاشة الكامل ---------- */
.container,
.nav-container { max-width: none; padding-inline: var(--gutter); }

.slider-container { height: clamp(300px, 32vw, 600px); }
.home-search { max-width: min(1280px, 100%); }

@media (min-width: 1600px) {
    .grid-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
    .dir-layout { grid-template-columns: 320px minmax(0, 1fr); }
    .cat-tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}

/* عناصر الجوال مخفية على الشاشات الكبيرة */
.mobile-only, .tab-bar, .action-bar { display: none; }

/* ---------- تبويبات مقسّمة (صفحة الأعراس) ---------- */
.seg-tabs { display: flex; gap: 8px; margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tabs a {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 50px; text-decoration: none; font-weight: 700;
    background: var(--bg-glass); border: 1px solid var(--border-glass); color: var(--text-muted);
    transition: var(--transition-smooth);
}
.seg-tabs a span { background: rgba(255, 255, 255, .08); border-radius: 50px; padding: 0 8px; font-size: .78rem; }
.seg-tabs a.active { background: var(--accent-gold); border-color: var(--accent-gold); color: var(--bg-dark); }
.seg-tabs a.active span { background: rgba(0, 0, 0, .15); }
.wedding-filter input.form-control { flex: 2 1 220px; width: auto; }

/* ---------- رسائل النجاح ---------- */
.alert { transition: opacity .4s, transform .4s; }
.alert.fade-out { opacity: 0; transform: translateY(-10px); pointer-events: none; }

/* ---------- النافذة المنزلقة (الحساب) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 1900; background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.sheet {
    position: fixed; z-index: 1950; left: 0; right: 0; bottom: 0; margin-inline: auto;
    width: min(100%, 520px); max-height: 86vh; overflow-y: auto; overscroll-behavior: contain;
    background: #0c2735; border: 1px solid var(--border-glass); border-bottom: 0;
    border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + var(--safe-bottom));
    transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
}
.sheet.open { transform: translateY(0); }
.sheet[hidden], .sheet-backdrop[hidden] { display: none; }
.sheet-handle { width: 42px; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, .25); margin: 0 auto 14px; }
.sheet-title { font-weight: 800; font-size: 1.1rem; margin-bottom: 12px; padding: 0 4px; }
.sheet-user { display: flex; align-items: center; gap: 12px; padding: 4px 4px 14px; }
.sheet-user strong { display: block; }
.sheet-user small { color: var(--text-muted); font-size: .8rem; }
.sheet-link {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 14px 14px; margin-bottom: 6px; border-radius: 14px;
    background: rgba(255, 255, 255, .04); border: 1px solid var(--border-glass);
    color: var(--text-white); text-decoration: none; font-family: inherit; font-size: 1rem; font-weight: 700;
    cursor: pointer; text-align: right;
}
.sheet-link i { width: 22px; text-align: center; color: var(--accent-gold); }
.sheet-link:active { transform: scale(.98); }
.sheet-link.primary { background: var(--accent-gold); color: var(--bg-dark); border-color: var(--accent-gold); }
.sheet-link.primary i { color: var(--bg-dark); }
.sheet-link.compact { padding: 11px 14px; font-weight: 600; font-size: .93rem; background: transparent; border-color: transparent; margin-bottom: 0; }
.sheet-link.install { background: rgba(47, 125, 74, .15); border-color: rgba(47, 125, 74, .4); margin-top: 10px; }
.sheet-link.install i { color: #5fd79a; }
.sheet-link.danger { color: #ff8798; margin-top: 10px; }
.sheet-link.danger i { color: #ff8798; }
.sheet-sep { height: 1px; background: var(--border-glass); margin: 10px 0 8px; }
.ios-hint { color: var(--text-muted); font-size: .85rem; padding: 10px 4px 0; line-height: 1.8; }
.ios-hint i { color: var(--accent-gold); }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
    background: rgba(217, 164, 65, .18); color: var(--accent-gold); font-weight: 800; font-size: .95rem;
}
.avatar.lg { width: 48px; height: 48px; font-size: 1.25rem; }

body.no-scroll { overflow: hidden; }

/* ==========================================================================
   الهواتف: تجربة تطبيق
   ========================================================================== */
/* هيكل التطبيق (الشريط العلوي المختصر وشريط التبويب السفلي) للهواتف والأجهزة اللوحية */
@media (max-width: 1024px) {
    :root { --appbar-h: 58px; }
    .nav-links { display: none; }

    body { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); overscroll-behavior-y: none; }
    body.has-action-bar { padding-bottom: calc(var(--tabbar-h) + 70px + var(--safe-bottom)); }

    /* شريط التطبيق العلوي */
    header { padding-top: var(--safe-top); transition: box-shadow .2s, background .2s; }
    body.scrolled header { box-shadow: 0 6px 20px rgba(0, 0, 0, .35); background: rgba(6, 26, 36, .96); }
    .nav-container { height: var(--appbar-h); padding-block: 0; }
    .logo-area a { font-size: 1.2rem; }
    .mobile-only { display: inline-flex; }
    .app-icon-btn {
        width: 40px; height: 40px; border-radius: 50%; align-items: center; justify-content: center;
        background: var(--bg-glass); border: 1px solid var(--border-glass); color: var(--text-white);
        font-size: 1.05rem; cursor: pointer;
    }
    .app-icon-btn .avatar { width: 100%; height: 100%; }

    main { margin-top: calc(var(--appbar-h) + var(--safe-top)); padding: 14px 0 26px; min-height: auto; }

    /* شريط التبويب السفلي */
    .tab-bar {
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
        position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0;
        height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
        background: rgba(6, 26, 36, .94); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
        border-top: 1px solid var(--border-glass);
    }
    .tab-bar a, .tab-bar button {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        background: none; border: 0; color: var(--text-muted); text-decoration: none; font-family: inherit;
        font-size: .7rem; font-weight: 700; cursor: pointer;
    }
    .tab-bar i { font-size: 1.25rem; transition: transform .2s; }
    .tab-bar .active { color: var(--accent-gold); }
    .tab-bar .active i { transform: translateY(-1px) scale(1.08); }
    .tab-bar .active::before {
        content: ''; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 4px 4px; background: var(--accent-gold);
    }
    .tab-bar a:active i, .tab-bar button:active i { transform: scale(.88); }

    /* شريط الإجراءات الثابت (اتصال / واتساب / اشتراك) */
    .action-bar {
        display: flex; gap: 8px; position: fixed; z-index: 999; left: 0; right: 0;
        bottom: calc(var(--tabbar-h) + var(--safe-bottom)); padding: 10px var(--gutter);
        background: rgba(12, 39, 53, .97); backdrop-filter: blur(14px); border-top: 1px solid var(--border-glass);
    }
    .action-bar a, .action-bar button {
        flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
        height: 48px; border-radius: 14px; font-family: inherit; font-weight: 800; font-size: .95rem;
        text-decoration: none; border: 0; cursor: pointer;
    }
    .action-bar .primary { background: var(--accent-gold); color: var(--bg-dark); }
    .action-bar .wa { background: #25d366; color: #fff; }
    .action-bar .ghost { background: rgba(255, 255, 255, .08); color: var(--text-white); flex: 0 0 48px; }
    .action-bar a:active, .action-bar button:active { transform: scale(.97); }

    /* رسائل كتنبيهات عائمة */
    .alert {
        position: fixed; z-index: 1800; left: 12px; right: 12px; top: calc(var(--appbar-h) + var(--safe-top) + 8px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, .45); animation: toast-in .35s ease;
    }
    .alert-danger { position: static; box-shadow: none; animation: none; }
    @keyframes toast-in { from { opacity: 0; transform: translateY(-14px); } }
}

/* تصغير المحتوى للهواتف */
@media (max-width: 768px) {
    :root { --gutter: 14px; }

    /* شرائح العرض */
    .slider-container { height: 230px; border-radius: 18px; }
    .slide-content { padding: 22px 20px; }
    .slide-content h2 { font-size: 1.3rem; margin-bottom: 6px; }
    .slide-content p { font-size: .85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .slider-arrow { display: none; }
    .home-hero { padding: 40px 18px 60px; }

    /* صفوف أفقية قابلة للسحب حتى الحافة */
    .dir-tabs, .home-search-tabs, .seg-tabs {
        flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
        margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter);
    }
    .dir-tabs::-webkit-scrollbar, .home-search-tabs::-webkit-scrollbar { display: none; }
    .dir-tabs a, .home-search-tab, .seg-tabs a { flex: 0 0 auto; scroll-snap-align: start; }
    .dir-tabs { margin-bottom: 16px; }
    .dir-tabs a { padding: 9px 15px; font-size: .88rem; }
    .home-search-tabs { margin-inline: -16px; padding-inline: 16px; }
    .strip-track { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); }

    /* العناوين والأقسام */
    .dir-head h1 { font-size: 1.45rem; }
    .dir-head p { font-size: .9rem; }
    .home-section { margin-bottom: 34px; }
    .section-head { margin-bottom: 14px; }
    .section-title::before { height: 22px; width: 6px; }
    .stats-strip { margin-bottom: 30px; }

    /* البطاقات */
    .grid-cards { gap: 14px; }
    .grid-cards .card-img-wrapper { height: 180px; }
    .wedding-card:hover { transform: none; }
    .wedding-card:active { transform: scale(.985); }
    .cat-tiles { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .cat-tile { padding: 16px 6px; }
    .cat-tile i { font-size: 1.5rem; }
    .cat-tile strong { font-size: .8rem; line-height: 1.4; }
    .cat-tile small { font-size: .72rem; }

    /* حقول بحجم 16px لمنع التكبير التلقائي في iPhone */
    input.form-control, select.form-control, textarea.form-control, .form-control { font-size: 16px; }
    .wedding-filter .form-control { flex: 1 1 100%; }
    .wedding-filter .btn-submit { flex: 1; }

    /* لوحة الفلاتر كنافذة سفلية */
    .filter-panel.open {
        display: block; position: fixed; z-index: 1950; left: 0; right: 0; bottom: 0; top: auto;
        max-height: 88vh; border-radius: 22px 22px 0 0; padding: 16px 16px 0;
        background: #0c2735; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .6);
        animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
    }
    .filter-panel.open .btn-submit {
        position: sticky; bottom: 0; margin: 8px -16px 0; width: calc(100% + 32px);
        border-radius: 0; padding: 16px 16px calc(16px + var(--safe-bottom)); font-size: 1rem;
    }
    .filter-panel .filter-close { display: inline-flex; }
    @keyframes sheet-up { from { transform: translateY(100%); } }
    .results-bar { position: sticky; top: calc(var(--appbar-h) + var(--safe-top)); z-index: 50; background: var(--bg-dark); margin-inline: calc(-1 * var(--gutter)); padding: 10px var(--gutter); }

    /* صفحات التفاصيل */
    .wedding-details-grid { gap: 16px; }
    .details-body h1 { font-size: 1.35rem; }
    .gallery-mosaic { border-radius: 16px; margin-inline: calc(-1 * var(--gutter)); border-radius: 0; }
    .contact-card { display: none; }
    .back-link { margin-bottom: 8px; }

    /* نماذج الدخول والتسجيل */
    .glass-form-card { padding: 22px 18px; margin: 10px auto; }

    footer { margin-top: 20px; padding: 26px 0; }
}

/* أزرار الإغلاق تظهر فقط داخل النوافذ على الجوال */
.filter-close { display: none; }
.filter-close {
    width: 34px; height: 34px; border-radius: 50%; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .08); border: 0; color: var(--text-white); cursor: pointer;
}

/* عند فتح الموقع كتطبيق مثبت */
.standalone footer { display: none; }

@media (max-width: 768px) {
    /* زر واتساب صغير بجانب زر الاشتراك */
    .action-bar .wa:not(:only-child):has(+ .ghost):first-child { flex: 1; }
    .action-bar .primary + .wa { flex: 0 0 56px; }
    #register { scroll-margin-top: calc(var(--appbar-h) + 16px); }
}

@media (max-width: 768px) {
    /* نماذج بحث أقصر: المحافظة والولاية جنباً إلى جنب */
    .home-search { margin-top: -16px; padding: 14px; }
    .home-search-fields { grid-template-columns: 1fr 1fr; gap: 10px; }
    .home-search-fields .form-group:first-child, .home-search-fields .btn-submit { grid-column: 1 / -1; }
    .home-search-fields label { font-size: .8rem; margin-bottom: 4px; }
    .slider-dots { bottom: 26px; }
    .wedding-filter { gap: 8px; }
    .wedding-filter select.form-control { flex: 1 1 calc(50% - 4px); min-width: 0; }
}

/* الأجهزة اللوحية: إبعاد نص الشريحة عن أسهم التنقل */
@media (min-width: 769px) and (max-width: 1024px) {
    .slide-content { padding-inline: 84px; }
}

/* ---------- منع اتساع الصفحة أفقياً على الجوال ----------
   أي عنصر يخرج عن عرض الشاشة يجعل متصفحات أندرويد (سامسونج وكروم) توسّع الصفحة كلها،
   فينزاح المحتوى خارج الشاشة ويبقى الهيدر وحده ظاهراً. */
.home-search-tab { position: relative; }  /* أزرار الاختيار المخفية تبقى داخل شريط التبويبات القابل للسحب */
.bg-glow { width: min(400px, 90vw); height: min(400px, 90vw); }
html, body { overflow-x: clip; }
