/*
 * بوابة «شريك باين» والصفحات العامة للبرنامج: ما يخص البوابة فقط.
 * الهوية المشتركة (الألوان والشارات والأزرار العامة) في bayn-ui.css ويُحمَّل قبل هذا الملف.
 * فاتح فقط. الأرقام الغربية دائمًا (lining-nums مع اتجاه ltr للقيم).
 */

:root {
    --pp-sidebar-width: 272px;
}

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

body.pp-body {
    font-family: 'Tajawal', sans-serif;
    font-variant-numeric: lining-nums;
    background: var(--bn-canvas);
    color: var(--bn-text);
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

[x-cloak] { display: none !important; }

/* ============ الشعار ============ */
.pp-logo-box {
    width: 64px;
    height: 64px;
    background: #fff;
    border-radius: var(--bn-radius-card);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bn-line);
    padding: 10px;
}
.pp-logo-box img { width: 100%; height: 100%; object-fit: contain; }

/* ============ الحقول ============ */
.pp-input {
    width: 100%;
    padding: .8rem 1rem;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: var(--bn-radius-control);
    font: inherit;
    font-size: 1rem;
    color: var(--bn-text);
    transition: border-color .2s ease, box-shadow .2s ease;
    outline: none;
}
.pp-input::placeholder { color: #94a3b8; }
.pp-input:hover { border-color: #94a3b8; }
.pp-input:focus { border-color: var(--bn-primary); box-shadow: 0 0 0 3px rgba(13, 148, 136, .18); }
.pp-input[aria-invalid="true"] { border-color: #475569; background: #f8fafc; }
.pp-input:focus-visible { outline: none; }
.pp-input:disabled { opacity: .55; cursor: not-allowed; }
.pp-input--icon { padding-right: 2.75rem; }
.pp-input-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
    transition: color .2s ease;
}
.pp-input:focus ~ .pp-input-icon { color: var(--bn-primary); }

/* حقل الرمز: كبير وواضح، أرقام لاتينية */
.pp-code {
    text-align: center;
    font-size: clamp(1.6rem, 7vw, 2rem);
    font-weight: 700;
    letter-spacing: .45em;
    padding-block: 1rem;
    /* يعادل الفراغ المضاف بعد آخر رقم كي يبقى الرقم في المنتصف بصريًا */
    text-indent: .45em;
    font-variant-numeric: tabular-nums;
}
.pp-code::placeholder { letter-spacing: .3em; }

select.pp-input { appearance: none; background-image: none; }

/* ============ رسائل الخطأ ============ */
.pp-field-error {
    margin-top: 6px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: .8125rem;
    font-weight: 500;
    color: #334155;
}

/* ============ البطاقات ============ */
.pp-surface {
    background: var(--bn-card);
    border-radius: var(--bn-radius-card);
    border: 1px solid var(--bn-line);
}
.pp-rule { height: 2px; width: 3rem; border-radius: 2px; background: var(--bn-primary-light); }

/* ============ التنقل الجانبي (على الحاسوب) ============ */
.pp-sidebar {
    background: var(--bn-gradient);
    width: var(--pp-sidebar-width);
}
.pp-side-head { position: relative; isolation: isolate; }
.pp-side-head::before,
.pp-hero::before,
.pp-member-card::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .09;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15'%3E%3Cpath d='M7.5 1.5 13.5 7.5 7.5 13.5 1.5 7.5Z' fill='none' stroke='%23fff' stroke-opacity='.9' stroke-width='.7'/%3E%3C/svg%3E");
    background-size: 15px 15px;
}
/* عنوان القائمة بلون accent كما في لوحة التحكم */
.pp-side-title { color: var(--bn-accent); font-weight: 700; }
.pp-side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .7rem 1.1rem;
    margin-bottom: .25rem;
    border-radius: var(--bn-radius-control);
    border-right: 4px solid transparent;
    color: rgba(255, 255, 255, .88);
    font-weight: 500;
    transition: background-color .2s ease, color .2s ease;
}
.pp-side-link i { width: 1.4rem; text-align: center; font-size: 1.05rem; }
.pp-side-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
/* حد العنصر النشط بلون accent كما في لوحة التحكم */
.pp-side-link.is-active {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-weight: 700;
    border-right-color: var(--bn-accent);
}
.pp-side-link.is-active i { color: var(--bn-accent); }
.pp-side-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--bn-radius-control);
    background: #fff;
    color: var(--bn-primary-dark);
    font-weight: 700;
}
.pp-side-cta:hover { background: var(--bn-primary-50); }
.pp-side-user { border-radius: var(--bn-radius-control); background: rgba(255, 255, 255, .1); padding: .75rem; }

/* شارة رقم العضوية: خلفية primary-50 ونص primary-dark */
.pp-member-badge {
    display: inline-block;
    padding: .1rem .6rem;
    border-radius: 9999px;
    background: var(--bn-primary-50);
    color: var(--bn-primary-dark);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
}

/* ============ الشريط العلوي ============ */
.pp-topbar { background: #fff; border-bottom: 1px solid var(--bn-line); }
.pp-icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--bn-radius-control);
    color: var(--bn-muted);
    transition: background-color .2s ease, color .2s ease;
}
.pp-icon-btn:hover { background: var(--bn-primary-50); color: var(--bn-primary-dark); }

/* ============ الشريط السفلي (الجوال) ============ */
.pp-bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
.pp-bottom-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 3.5rem;
    padding: 6px 2px;
    color: var(--bn-muted);
    font-size: .6875rem;
    font-weight: 500;
    transition: color .2s ease;
}
.pp-bottom-item i { font-size: 1.2rem; }
.pp-bottom-item.is-active { color: var(--bn-primary-dark); font-weight: 700; }
.pp-bottom-item.is-active::before {
    content: '';
    position: absolute;
    top: -1px; left: 50%;
    transform: translateX(-50%);
    width: 30px; height: 3px;
    background: var(--bn-accent);
    border-radius: 0 0 3px 3px;
}
/* زر «ربط متجر» الأوسط البارز */
.pp-bottom-item.is-primary-action { color: var(--bn-primary-dark); font-weight: 700; }
.pp-bottom-item.is-primary-action .pp-fab {
    display: grid;
    place-items: center;
    width: 3.25rem; height: 3.25rem;
    margin-top: -1.5rem;
    border-radius: 9999px;
    color: #fff;
    background: var(--bn-primary-dark);
    box-shadow: 0 0 0 4px #fff, 0 4px 14px rgba(15, 118, 110, .35);
}
.pp-bottom-item.is-primary-action .pp-fab i { font-size: 1.3rem; }
.pp-bottom-item.is-primary-action.is-active::before { display: none; }

/* ============ الهيرو وبطاقة العضوية ============ */
.pp-hero,
.pp-member-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border-radius: var(--bn-radius-hero);
    color: #fff;
    background: var(--bn-gradient);
}
.pp-member-card { aspect-ratio: 1.586 / 1; }
@media (max-width: 420px) { .pp-member-card { aspect-ratio: auto; } }

/* ============ المصادقة: لوحة قيمة + نموذج ============ */
.pp-auth-panel {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: var(--bn-gradient);
    color: #fff;
}
.pp-auth-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .09;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15'%3E%3Cpath d='M7.5 1.5 13.5 7.5 7.5 13.5 1.5 7.5Z' fill='none' stroke='%23fff' stroke-opacity='.9' stroke-width='.7'/%3E%3C/svg%3E");
    background-size: 15px 15px;
}
.pp-auth-card {
    background: #fff;
    border: 1px solid var(--bn-line);
    border-radius: var(--bn-radius-hero);
    padding: clamp(20px, 5vw, 32px);
}

/* ============ هيكل التحميل ============ */
.skeleton {
    background: linear-gradient(90deg, rgba(148, 163, 184, .18), rgba(148, 163, 184, .34), rgba(148, 163, 184, .18));
    background-size: 200% 100%;
    animation: pp-sk 1.2s infinite;
    border-radius: .5rem;
}
@keyframes pp-sk { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

/* ============ الحركات ============ */
@keyframes pp-fade-in-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pp-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}
.pp-in { animation: pp-fade-in-up .35s ease both; }
.pp-in-1 { animation-delay: .08s; }
.pp-in-2 { animation-delay: .16s; }
.pp-in-3 { animation-delay: .24s; }
.pp-shake { animation: pp-shake .5s ease; }

/* ============ التركيز بلوحة المفاتيح ============ */
.pp-skip-link {
    position: absolute;
    top: -3rem;
    right: 1rem;
    z-index: 100;
    padding: .6rem 1rem;
    border-radius: 0 0 12px 12px;
    background: var(--bn-primary-dark);
    color: #fff;
    font-weight: 700;
    transition: top .2s ease;
}
.pp-skip-link:focus { top: 0; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid rgba(13, 148, 136, .55);
    outline-offset: 2px;
}

/* ============ جداول تتحول إلى بطاقات على الجوال ============ */
@media (max-width: 639.98px) {
    .pp-table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .pp-table-cards,
    .pp-table-cards tbody,
    .pp-table-cards tr,
    .pp-table-cards td { display: block; width: 100%; }
    .pp-table-cards tr { border: 1px solid var(--bn-line); border-radius: var(--bn-radius-control); margin-bottom: .6rem; padding: .35rem .9rem; background: #fff; }
    .pp-table-cards td { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0 !important; border: 0 !important; }
    .pp-table-cards td::before { content: attr(data-label); color: var(--bn-muted); font-weight: 500; }
}

/* ============ تقليل الحركة ============ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .skeleton { animation: none !important; }
}
