/* ==========================================================================
   ORAX ERP — Reconnect مثل Blazor الافتراضي: الصفحة تبقى تحت طبقة شفافة/ضبابية
   ========================================================================== */

/* المحتوى يبقى مرسوماً تحت النافذة عند انقطاع الدائرة */
body:has(#components-reconnect-modal.components-reconnect-show) #orax-app-root,
body:has(#components-reconnect-modal.components-reconnect-paused) #orax-app-root,
body:has(#components-reconnect-modal.orax-force-show) #orax-app-root,
body:has(#components-reconnect-modal.components-reconnect-failed) #orax-app-root,
body:has(#components-reconnect-modal.components-reconnect-rejected) #orax-app-root {
    visibility: visible !important;
    opacity: 1 !important;
    filter: none !important;
}

#components-reconnect-modal {
    display: none !important;
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    box-sizing: border-box;
    font-family: inherit;
    pointer-events: none;
    /* مهم: لا نلون الحاوية — الطبقة الزجاجية فقط */
    background: transparent !important;
}

#components-reconnect-modal.components-reconnect-hide {
    display: none !important;
    pointer-events: none !important;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-paused,
#components-reconnect-modal.orax-force-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex !important;
    pointer-events: auto !important;
}

/* الضباب يغطي الشاشة؛ الصفحة (orax-app-root) تظهر من تحته */
.orax-reconnect-veil {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: auto;
    /* قريب من القالب الافتراضي: rgba(255,255,255,0.8) لكن أوضح للمحتوى */
    background-color: rgba(255, 255, 255, 0.38);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    backdrop-filter: blur(14px) saturate(120%);
}

#components-reconnect-modal.components-reconnect-show .orax-reconnect-veil,
#components-reconnect-modal.components-reconnect-paused .orax-reconnect-veil,
#components-reconnect-modal.orax-force-show .orax-reconnect-veil {
    display: block;
    background-color: rgba(255, 255, 255, 0.36);
}

#components-reconnect-modal.components-reconnect-failed .orax-reconnect-veil,
#components-reconnect-modal.components-reconnect-rejected .orax-reconnect-veil {
    display: block;
    background-color: rgba(255, 255, 255, 0.48);
    -webkit-backdrop-filter: blur(16px) saturate(115%);
    backdrop-filter: blur(16px) saturate(115%);
}

html[data-theme="dark"] #components-reconnect-modal .orax-reconnect-veil {
    background-color: rgba(15, 23, 42, 0.42);
}

html[data-theme="dark"] #components-reconnect-modal.components-reconnect-failed .orax-reconnect-veil,
html[data-theme="dark"] #components-reconnect-modal.components-reconnect-rejected .orax-reconnect-veil {
    background-color: rgba(15, 23, 42, 0.55);
}

.orax-reconnect-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    margin: auto;
    background: #ffffff;
    border-radius: 16px;
    padding: 1.5rem 1.4rem 1.1rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow:
        0 20px 50px rgba(15, 23, 42, 0.12),
        0 2px 8px rgba(15, 23, 42, 0.06);
    color: #0f172a;
    overflow: hidden;
    box-sizing: border-box;
    animation: oraxCardPopIn 0.3s ease-out forwards;
    pointer-events: auto;
}

html[data-theme="dark"] .orax-reconnect-card {
    background: rgba(30, 41, 59, 0.96);
    border-color: rgba(148, 163, 184, 0.28);
    color: #f1f5f9;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

#components-reconnect-modal.components-reconnect-failed .orax-reconnect-card,
#components-reconnect-modal.components-reconnect-rejected .orax-reconnect-card {
    text-align: center;
    max-width: 420px;
}

.orax-card-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.orax-compact-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.65rem;
    margin-bottom: 0.9rem;
}

.orax-compact-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

html[data-theme="dark"] .orax-compact-logo {
    background: rgba(51, 65, 85, 0.55);
    border-color: rgba(148, 163, 184, 0.2);
}

.orax-brand-logo-sm {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.orax-compact-titles {
    width: 100%;
}

.orax-title-compact {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0.4rem 0 0.3rem;
    line-height: 1.45;
    color: #0f172a;
}

html[data-theme="dark"] .orax-title-compact {
    color: #f8fafc;
}

.orax-desc-compact {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.55;
    color: #475569;
}

html[data-theme="dark"] .orax-desc-compact {
    color: #94a3b8;
}

.orax-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.28rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.orax-status-reconnecting {
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    color: #0369a1;
}

html[data-theme="dark"] .orax-status-reconnecting {
    background: rgba(43, 178, 255, 0.14);
    border-color: rgba(43, 178, 255, 0.35);
    color: #7dd3fc;
}

.orax-status-failed {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #b45309;
    margin-bottom: 0.6rem;
}

.orax-status-rejected {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    margin-bottom: 0.6rem;
}

.orax-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.orax-status-reconnecting .orax-status-dot {
    animation: oraxBlink 1.4s infinite ease-in-out;
}

.orax-title {
    font-size: 1.08rem;
    font-weight: 800;
    margin: 0 0 0.45rem;
    color: #0f172a;
}

html[data-theme="dark"] .orax-title {
    color: #f8fafc;
}

.orax-desc {
    font-size: 0.86rem;
    line-height: 1.55;
    color: #475569;
    margin: 0 0 1rem;
    max-width: 340px;
}

html[data-theme="dark"] .orax-desc {
    color: #94a3b8;
}

.orax-state-expanded .orax-desc {
    margin-left: auto;
    margin-right: auto;
}

.orax-state {
    display: none;
    width: 100%;
}

#components-reconnect-modal.components-reconnect-show .orax-state-reconnecting,
#components-reconnect-modal.components-reconnect-paused .orax-state-reconnecting,
#components-reconnect-modal.state-reconnecting .orax-state-reconnecting,
#components-reconnect-modal.orax-force-show .orax-state-reconnecting {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#components-reconnect-modal.components-reconnect-failed .orax-state-reconnecting {
    display: none !important;
}

#components-reconnect-modal.components-reconnect-failed .orax-state-failed,
#components-reconnect-modal.state-failed .orax-state-failed {
    display: flex !important;
    flex-direction: column;
    align-items: center;
}

#components-reconnect-modal.components-reconnect-rejected .orax-state-reconnecting,
#components-reconnect-modal.components-reconnect-rejected .orax-state-failed {
    display: none !important;
}

#components-reconnect-modal.components-reconnect-rejected .orax-state-rejected,
#components-reconnect-modal.state-rejected .orax-state-rejected {
    display: flex !important;
    flex-direction: column;
    align-items: center;
}

.orax-countdown-box {
    width: 100%;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.85rem;
    box-sizing: border-box;
}

html[data-theme="dark"] .orax-countdown-box {
    background: rgba(15, 23, 42, 0.45);
    border-color: rgba(148, 163, 184, 0.15);
}

.orax-countdown-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    margin-bottom: 0.45rem;
}

.orax-countdown-label {
    color: #334155;
    font-weight: 600;
}

html[data-theme="dark"] .orax-countdown-label {
    color: #cbd5e1;
}

.orax-countdown-badge {
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    color: #0284c7;
    padding: 0.12rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 800;
}

.orax-progress-track {
    width: 100%;
    height: 5px;
    background: #cbd5e1;
    border-radius: 999px;
    overflow: hidden;
}

html[data-theme="dark"] .orax-progress-track {
    background: rgba(255, 255, 255, 0.12);
}

.orax-progress-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #2bb2ff, #00d2ff, #e92223);
    border-radius: 999px;
    transition: width 1s linear;
}

.orax-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    flex-wrap: wrap;
}

.orax-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.62rem 1.1rem;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.orax-btn-sm {
    padding: 0.52rem 0.95rem;
    font-size: 0.84rem;
}

.orax-btn-primary {
    background: linear-gradient(135deg, #2bb2ff 0%, #0284c7 100%);
    color: #fff;
    box-shadow: 0 4px 14px -4px rgba(43, 178, 255, 0.55);
}

.orax-btn-secondary {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

html[data-theme="dark"] .orax-btn-secondary {
    background: rgba(51, 65, 85, 0.6);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.25);
}

.orax-btn-icon {
    width: 17px;
    height: 17px;
}

.orax-btn:hover .spin-hover {
    animation: oraxSpin 0.9s ease;
}

.orax-logo-wrapper.orax-logo-expanded {
    width: 68px;
    height: 68px;
    margin: 0 auto 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orax-logo-container {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

html[data-theme="dark"] .orax-logo-container {
    background: rgba(51, 65, 85, 0.55);
}

.orax-brand-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.orax-footer-network {
    margin-top: 0.7rem;
    padding-top: 0.6rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
}

html[data-theme="dark"] .orax-footer-network {
    border-top-color: rgba(148, 163, 184, 0.12);
}

.orax-network-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.74rem;
    color: #64748b;
}

.orax-network-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}

.orax-network-offline .orax-network-dot {
    background: #ef4444;
}

/* متصفح بدون backdrop-filter: شفافية فقط (لا خلفية بيضاء صلبة) */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .orax-reconnect-veil {
        background-color: rgba(255, 255, 255, 0.55) !important;
    }

    html[data-theme="dark"] .orax-reconnect-veil {
        background-color: rgba(15, 23, 42, 0.6) !important;
    }
}

@keyframes oraxCardPopIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes oraxSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes oraxBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

@media (max-width: 480px) {
    .orax-reconnect-card {
        padding: 1.2rem 1rem;
    }

    .orax-actions {
        flex-direction: column;
    }

    .orax-btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .orax-reconnect-card,
    .orax-status-reconnecting .orax-status-dot,
    .orax-btn:hover .spin-hover {
        animation: none !important;
    }
}