/**
 * منصة واحد مهني - PWA & Web Push Notifications Styles (RTL)
 */

/* =========================================================
   1. Topbar PWA Action Buttons (Install & Enable Push)
   ========================================================= */
.pwa-install-btn {
    background: linear-gradient(135deg, #008cff 0%, #0062cc 100%);
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 140, 255, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    white-space: nowrap;
}

.pwa-install-btn:hover,
.pwa-install-btn:focus {
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 140, 255, 0.42);
    filter: brightness(1.06);
}

.pwa-push-status-btn,
.pwa-enable-push-chip {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.16) 0%, rgba(217, 119, 6, 0.24) 100%);
    color: #d97706 !important;
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 999px;
    padding: 5px 13px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

html.dark-theme .pwa-enable-push-chip,
html.semi-dark .topbar .pwa-enable-push-chip {
    color: #fbbf24 !important;
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(251, 191, 36, 0.4);
}

.pwa-push-status-btn:hover,
.pwa-enable-push-chip:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: #ffffff !important;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(245, 158, 11, 0.32);
}

/* =========================================================
   2. Topbar Notification Bell & Unread Pulse Badge
   ========================================================= */
.pwa-bell-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.pwa-bell-btn:hover {
    background-color: rgba(0, 140, 255, 0.1);
}

.pwa-bell-btn.has-unread i {
    color: #008cff;
    animation: pwaBellSwing 2.4s ease-in-out infinite;
    transform-origin: top center;
}

.pwa-bell-btn.has-unread::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 2px solid rgba(0, 140, 255, 0.45);
    animation: pwaPulseRing 2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
    pointer-events: none;
}

@keyframes pwaBellSwing {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-12deg); }
    30% { transform: rotate(9deg); }
    40% { transform: rotate(-6deg); }
    50% { transform: rotate(0deg); }
}

@keyframes pwaPulseRing {
    0% {
        transform: scale(0.92);
        opacity: 0.85;
    }
    100% {
        transform: scale(1.32);
        opacity: 0;
    }
}

.pwa-bell-badge {
    position: absolute;
    top: 3px !important;
    right: 3px !important;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    line-height: 19px !important;
    text-align: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    border: 2px solid #ffffff;
    z-index: 2;
}

/* =========================================================
   3. Notification Dropdown Menu
   ========================================================= */
.pwa-notif-dropdown {
    width: 370px;
    max-width: calc(100vw - 24px);
    border-radius: 16px !important;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.06) !important;
    direction: rtl;
    text-align: right;
}

.pwa-notif-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
}

.pwa-header-action {
    font-size: 0.76rem !important;
    font-weight: 600 !important;
    color: #475569 !important;
    border-radius: 8px;
    padding: 4px 8px !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pwa-header-action:hover {
    background-color: rgba(0, 140, 255, 0.1);
    color: #008cff !important;
}

.pwa-push-status-strip {
    background: #f8fafc;
    border-bottom: 1px solid #eef2f6;
    font-size: 0.78rem;
    color: #475569;
}

.pwa-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
    display: inline-block;
    flex-shrink: 0;
}

.pwa-status-dot.enabled {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.55);
}

.pwa-status-dot.prompt {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.pwa-status-dot.denied {
    background: #ef4444;
}

.pwa-notif-list {
    max-height: 360px;
    overflow-y: auto;
    overscroll-behavior: contain;
    divide-y: 1px solid #f1f5f9;
}

.pwa-notif-list::-webkit-scrollbar {
    width: 5px;
}

.pwa-notif-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.pwa-notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: #1e293b;
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
}

.pwa-notif-item:last-child {
    border-bottom: none;
}

.pwa-notif-item:hover {
    background-color: #f8fafc;
    color: #0f172a;
}

.pwa-notif-item.unread {
    background: linear-gradient(90deg, rgba(0, 140, 255, 0.04) 0%, rgba(0, 140, 255, 0.1) 100%);
}

.pwa-notif-item.unread:hover {
    background: linear-gradient(90deg, rgba(0, 140, 255, 0.08) 0%, rgba(0, 140, 255, 0.14) 100%);
}

.pwa-notif-item.unread::before {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3.5px;
    background: #008cff;
    border-radius: 3px 0 0 3px;
}

.pwa-notif-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.pwa-notif-avatar.type-chat {
    background: rgba(0, 140, 255, 0.12);
    color: #008cff;
}

.pwa-notif-avatar.type-support {
    background: rgba(139, 92, 246, 0.14);
    color: #7c3aed;
}

.pwa-notif-avatar.type-exam {
    background: rgba(245, 158, 11, 0.14);
    color: #d97706;
}

.pwa-notif-avatar.type-order,
.pwa-notif-avatar.type-product {
    background: rgba(16, 185, 129, 0.14);
    color: #059669;
}

.pwa-notif-avatar.type-enrollment {
    background: rgba(6, 182, 212, 0.14);
    color: #0891b2;
}

.pwa-notif-avatar.type-test {
    background: rgba(236, 72, 153, 0.14);
    color: #db2777;
}

.pwa-notif-avatar.type-general {
    background: rgba(100, 116, 139, 0.14);
    color: #475569;
}

.pwa-notif-content {
    flex: 1;
    min-width: 0;
}

.pwa-notif-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}

.pwa-notif-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-notif-time {
    font-size: 0.7rem;
    color: #64748b;
    white-space: nowrap;
    flex-shrink: 0;
}

.pwa-notif-body {
    font-size: 0.79rem;
    color: #475569;
    margin: 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pwa-notif-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #008cff;
    flex-shrink: 0;
    margin-top: 6px;
}

.pwa-notif-footer {
    background: #f8fafc;
}

/* =========================================================
   4. Soft Floating Permission Banner
   ========================================================= */
.pwa-permission-banner {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1060;
    width: 380px;
    max-width: calc(100vw - 32px);
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    border: 1px solid rgba(0, 140, 255, 0.35);
    border-radius: 18px;
    padding: 16px 18px;
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
    direction: rtl;
    text-align: right;
    animation: pwaSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pwaSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pwa-permission-banner .pwa-banner-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.pwa-permission-banner .pwa-banner-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(0, 140, 255, 0.18);
    color: #38bdf8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.pwa-permission-banner .pwa-banner-title {
    font-size: 0.94rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.pwa-permission-banner .pwa-banner-desc {
    font-size: 0.8rem;
    color: #cbd5e1;
    line-height: 1.5;
    margin-bottom: 12px;
}

.pwa-permission-banner .pwa-banner-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.pwa-permission-banner .pwa-btn-allow {
    background: linear-gradient(135deg, #008cff 0%, #0066cc 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 7px 16px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pwa-permission-banner .pwa-btn-allow:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 140, 255, 0.4);
}

.pwa-permission-banner .pwa-btn-later {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: none;
    border-radius: 10px;
    padding: 7px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pwa-permission-banner .pwa-btn-later:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* =========================================================
   5. Floating Live Toast Notification Popup
   ========================================================= */
.pwa-live-toast-container {
    position: fixed;
    top: 76px;
    left: 20px;
    z-index: 1085;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 350px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
    direction: rtl;
}

.pwa-live-toast {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #f8fafc;
    border-radius: 15px;
    padding: 13px 15px;
    border: 1px solid rgba(0, 140, 255, 0.4);
    box-shadow: 0 16px 38px rgba(2, 6, 23, 0.4);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    animation: pwaToastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.pwa-live-toast:hover {
    border-color: #38bdf8;
    transform: translateY(-2px);
}

.pwa-live-toast.hiding {
    opacity: 0;
    transform: translateX(-20px);
}

@keyframes pwaToastIn {
    from {
        opacity: 0;
        transform: translateX(-24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.pwa-live-toast-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(0, 140, 255, 0.2);
    color: #38bdf8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.pwa-live-toast-body {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.pwa-live-toast-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 2px;
}

.pwa-live-toast-text {
    font-size: 0.78rem;
    color: #cbd5e1;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pwa-live-toast-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    line-height: 1;
    padding: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.pwa-live-toast-close:hover {
    color: #ffffff;
}

/* =========================================================
   6. iOS Install Instructions Modal
   ========================================================= */
.pwa-ios-modal {
    position: fixed;
    inset: 0;
    z-index: 1095;
    background: rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    direction: rtl;
    text-align: right;
}

.pwa-ios-modal.d-none {
    display: none !important;
}

.pwa-ios-modal-card {
    width: 100%;
    max-width: 400px;
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    padding: 26px 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    animation: pwaSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-ios-step {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #e2e8f0;
}

.pwa-ios-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #008cff;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@media (max-width: 576px) {
    .pwa-notif-dropdown {
        width: calc(100vw - 20px);
        position: fixed !important;
        top: 64px !important;
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
    }

    .pwa-permission-banner {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
    }
}
