/*
 * ═══════════════════════════════════════════════════════════════════════════
 * gateway-responsive.css
 * بوابة الوصول الذكية — آفاق (Multi-Device Responsive Gateway)
 * 
 * 🚀 طلب تنفيذ برمجى: البوابة الذكية متجاوزة الاستجابة
 * 
 * الهدف البرمجي:
 * - تطبيق نظام الـ 3 تابات (ابدأ مشروعك، دخول الأعضاء، حجز المواعيد)
 * - استخدام CSS Grid و Flexbox للتموضع الصحيح حسب حجم الشاشة
 * - على الكمبيوتر/اللابتوب: عرض أفقي (Horizontal) جنباً إلى جنب
 * - على الموبايل: عرض رأسي (Vertical Stack) للنقر بالإبهام
 * - تفعيل Glassmorphism و Hover effects مع الحفاظ على سرعة الاستجابة
 * - Modal يغطي الشاشة بشكل مريح مع مراعاة Safe Areas (iPhone/Android)
 * - ربط "دخول الأعضاء" بـ GPS للموظفين على الموبايل
 * - User-Role Based Redirect محفوظ بغض النظر عن الجهاز
 * 
 * سياسة القطارة (The Drop Policy):
 * - لا تغيير للملفات الرئيسية
 * - كل الأكواد الجديدة في هذا الملف المنفصل
 * - يُستدعى من <head> في index.php فقط
 * 
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ══════════════════════════════════════════════════
   BASE — Mobile First  (< 600px)
   التصميم الرأسي (Vertical Stack) للموبايل
══════════════════════════════════════════════════ */

.sgw-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9980;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    
    /* iPhone/Android Safe Areas — مراعاة المناطق الآمنة */
    padding: max(20px, env(safe-area-inset-top))
             max(16px, env(safe-area-inset-right))
             max(20px, env(safe-area-inset-bottom))
             max(16px, env(safe-area-inset-left));
}
.sgw-overlay.open { display: flex; }

.sgw-box {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    padding: 56px 18px 32px;
    width: 100%;
    max-width: 100%;
    position: relative;
    box-shadow: 
        0 24px 80px rgba(0, 0, 0, 0.28),
        0 0 0 1px rgba(212, 175, 55, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    text-align: center;
    animation: sgwPop .35s cubic-bezier(.34, 1.56, .64, 1) both;
    margin: auto 0;
    
    /* Glassmorphism effect */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

@keyframes sgwPop {
    from { transform: scale(.88) translateY(30px); opacity: 0; }
    to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* ── Close button ── */
.sgw-close {
    position: absolute;
    top: 16px; left: 16px;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(241, 245, 249, 0.95);
    border: 2px solid #e2e8f0;
    color: #475569;
    font-size: 17px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .25s cubic-bezier(.4, 0, .2, 1);
    z-index: 3;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.sgw-close:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.2);
}

/* ── Heading ── */
.sgw-head { margin-bottom: 26px; }
.sgw-head-title {
    font-size: 1.35rem;
    font-weight: 900;
    color: #0f172a;
    margin-bottom: 8px;
    font-family: 'Cairo', sans-serif;
    line-height: 1.3;
}
.sgw-head-sub {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    font-family: 'Cairo', sans-serif;
}

/* ── Cards grid — single column (vertical stack) on mobile ── */
.sgw-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Single card ── */
.sgw-card {
    background: linear-gradient(160deg, rgba(255,255,255,1) 0%, rgba(248,250,252,1) 100%);
    border: 2.5px solid #e2e8f0;
    border-radius: 18px;
    padding: 24px 18px 22px;
    text-decoration: none;
    color: #0f172a;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

/* Shimmer effect on hover/active */
.sgw-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(212,175,55,.06) 0%, transparent 60%);
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
    border-radius: inherit;
}

.sgw-card:hover::after,
.sgw-card:active::after {
    opacity: 1;
}

.sgw-card:hover,
.sgw-card:active {
    transform: translateY(-6px);
    box-shadow: 
        0 16px 40px rgba(0, 0, 0, 0.14),
        0 0 0 1px rgba(212, 175, 55, 0.15);
    color: #0f172a;
}

/* ── Icon circle ── */
.sgw-icon {
    width: 64px; height: 64px;
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform .3s;
}

.sgw-card:hover .sgw-icon {
    transform: scale(1.08);
}

.sgw-card-title { 
    font-size: 16px; 
    font-weight: 900; 
    color: #0f172a; 
    line-height: 1.3;
    font-family: 'Cairo', sans-serif;
}

.sgw-card-desc  { 
    font-size: 12.5px; 
    color: #64748b; 
    font-weight: 600; 
    line-height: 1.7; 
    text-align: center;
    font-family: 'Cairo', sans-serif;
}

/* ── CTA button inside card ── */
.sgw-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    border-radius: 50px;
    font-size: 13.5px;
    font-weight: 800;
    margin-top: 6px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    transition: all .25s cubic-bezier(.4, 0, .2, 1);
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.sgw-cta:hover { 
    transform: scale(1.08) translateY(-2px); 
    box-shadow: 0 8px 24px rgba(0,0,0,.18); 
}

/* ── Card color themes ── */
.sgw-c1 { border-color: rgba(212,175,55,.40); }
.sgw-c1:hover { border-color: #D4AF37; background: linear-gradient(160deg, #fffef8 0%, #fffdf5 100%); }
.sgw-c1 .sgw-icon { background: rgba(212,175,55,.14); color: #b8962e; }
.sgw-c1 .sgw-cta  { background: linear-gradient(135deg,#b8962e,#D4AF37,#e4c158); color: #07111f; }

.sgw-c2 { border-color: rgba(34,197,94,.35); }
.sgw-c2:hover { border-color: #22c55e; background: linear-gradient(160deg, #f7fef9 0%, #f0fdf4 100%); }
.sgw-c2 .sgw-icon { background: rgba(34,197,94,.14); color: #16a34a; }
.sgw-c2 .sgw-cta  { background: linear-gradient(135deg,#16a34a,#22c55e,#4ade80); color: #fff; }

.sgw-c3 { border-color: rgba(99,102,241,.35); }
.sgw-c3:hover { border-color: #6366f1; background: linear-gradient(160deg, #f9f8ff 0%, #f5f3ff 100%); }
.sgw-c3 .sgw-icon { background: rgba(99,102,241,.14); color: #4338ca; }
.sgw-c3 .sgw-cta  { background: linear-gradient(135deg,#4338ca,#6366f1,#818cf8); color: #fff; }

/* GPS badge — visible on mobile only (للموظفين) */
.sgw-gps-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #16a34a;
    font-weight: 800;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border: 1.5px solid #86efac;
    border-radius: 24px;
    padding: 4px 12px;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.15);
    animation: gps-pulse 2s ease-in-out infinite;
}

@keyframes gps-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ══════════════════════════════════════════════════
   TABLET  ≥ 600px — 3-column horizontal layout
   التصميم الأفقي (Horizontal) للتابلت
══════════════════════════════════════════════════ */
@media (min-width: 600px) {
    .sgw-overlay {
        align-items: center;
        padding: 24px;
        background: rgba(0, 0, 0, 0.70);
    }
    
    .sgw-box {
        max-width: 720px;
        padding: 60px 36px 48px;
        border-radius: 32px;
        margin: 0;
    }
    
    .sgw-close { 
        width: 48px; 
        height: 48px; 
        font-size: 19px; 
        top: 18px; 
        left: 18px; 
    }
    
    .sgw-head  { margin-bottom: 32px; }
    .sgw-head-title { font-size: 1.7rem; }
    .sgw-head-sub   { font-size: 14px; }

    /* 3 columns side-by-side (horizontal layout) */
    .sgw-cards { 
        display: grid;
        grid-template-columns: repeat(3, 1fr); 
        gap: 18px; 
        flex-direction: row;
    }
    
    .sgw-card  { 
        padding: 28px 18px 24px; 
        gap: 14px; 
        border-radius: 22px; 
    }
    
    .sgw-icon  { 
        width: 72px; 
        height: 72px; 
        border-radius: 20px; 
        font-size: 32px; 
    }
    
    .sgw-card-title { font-size: 16.5px; }
    .sgw-card-desc  { font-size: 12.5px; }
    .sgw-cta   { padding: 11px 26px; font-size: 13.5px; }

    /* Hide GPS badge on tablet+ */
    .sgw-gps-badge { display: none; }
}

/* ══════════════════════════════════════════════════
   LAPTOP  ≥ 900px — Enhanced horizontal layout
   تحسين التصميم الأفقي للابتوب
══════════════════════════════════════════════════ */
@media (min-width: 900px) {
    .sgw-overlay {
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }
    
    .sgw-box {
        max-width: 1020px;
        padding: 76px 64px 64px;
        border-radius: 40px;
        box-shadow: 
            0 32px 100px rgba(0, 0, 0, 0.32),
            0 0 0 1px rgba(212, 175, 55, 0.30),
            inset 0 2px 0 rgba(255, 255, 255, 0.95);
    }
    
    .sgw-close { 
        width: 56px; 
        height: 56px; 
        font-size: 24px; 
        top: 22px;
        left: 22px;
    }
    
    .sgw-head  { margin-bottom: 44px; }
    .sgw-head-title { font-size: 2.3rem; }
    .sgw-head-sub   { font-size: 17px; }

    .sgw-cards { gap: 28px; }
    
    .sgw-card  { 
        padding: 42px 28px 38px; 
        gap: 18px; 
        border-radius: 28px; 
        border-width: 3px; 
    }
    
    .sgw-card:hover { 
        transform: translateY(-10px); 
        box-shadow: 
            0 24px 60px rgba(0, 0, 0, 0.18),
            0 0 0 1px rgba(212, 175, 55, 0.25);
    }
    
    .sgw-icon  { 
        width: 104px; 
        height: 104px; 
        border-radius: 26px; 
        font-size: 48px; 
    }
    
    .sgw-card-title { font-size: 21px; }
    .sgw-card-desc  { font-size: 15px; line-height: 1.8; }
    .sgw-cta   { padding: 15px 40px; font-size: 17px; }
}

/* ══════════════════════════════════════════════════
   DESKTOP  ≥ 1280px — Full premium experience
   Glassmorphism overlay + large cards
   التجربة الكاملة للكمبيوتر المكتبي
══════════════════════════════════════════════════ */
@media (min-width: 1280px) {
    .sgw-overlay { 
        backdrop-filter: blur(22px); 
        -webkit-backdrop-filter: blur(22px);
        background: rgba(0, 0, 0, 0.75);
    }

    .sgw-box {
        max-width: 1440px;
        padding: 100px 88px 88px;
        border-radius: 52px;
        border-width: 2px;
        box-shadow:
            0 40px 120px rgba(0,0,0,.35),
            0 0 0 1px rgba(255,255,255,.65) inset,
            0 2px 0 rgba(255,255,255,.95) inset,
            0 0 60px rgba(212, 175, 55, 0.12);
    }
    
    .sgw-close { 
        width: 76px; 
        height: 76px; 
        font-size: 32px; 
        top: 28px; 
        left: 28px; 
        border-width: 2.5px; 
    }

    .sgw-head  { margin-bottom: 60px; }
    .sgw-head-title { font-size: 3.6rem; letter-spacing: -0.5px; }
    .sgw-head-sub   { font-size: 28px; }

    .sgw-cards { gap: 40px; }
    
    .sgw-card  {
        padding: 60px 40px 54px;
        gap: 24px;
        border-radius: 40px;
        border-width: 3.5px;
    }
    
    .sgw-card:hover { 
        transform: translateY(-14px); 
        box-shadow: 
            0 32px 80px rgba(0,0,0,.20),
            0 0 0 1px rgba(212, 175, 55, 0.35);
    }
    
    .sgw-icon  { 
        width: 148px; 
        height: 148px; 
        border-radius: 40px; 
        font-size: 72px; 
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    }
    
    .sgw-card-title { font-size: 36px; letter-spacing: -0.3px; }
    .sgw-card-desc  { font-size: 24px; line-height: 1.9; }
    
    .sgw-cta   {
        padding: 22px 56px;
        font-size: 28px;
        gap: 16px;
        border-radius: 64px;
        box-shadow: 0 10px 32px rgba(0,0,0,.16);
    }
    
    .sgw-cta:hover {
        transform: scale(1.1) translateY(-3px);
        box-shadow: 0 16px 48px rgba(0,0,0,.24);
    }
}

/* ══════════════════════════════════════════════════
   PRINT — إخفاء الـ Modal عند الطباعة
══════════════════════════════════════════════════ */
@media print {
    .sgw-overlay { display: none !important; }
}

/* ══════════════════════════════════════════════════
   RTL SUPPORT — دعم اللغة العربية
══════════════════════════════════════════════════ */
[dir="rtl"] .sgw-close {
    left: auto;
    right: 16px;
}

@media (min-width: 600px) {
    [dir="rtl"] .sgw-close {
        left: auto;
        right: 18px;
    }
}

@media (min-width: 900px) {
    [dir="rtl"] .sgw-close {
        left: auto;
        right: 22px;
    }
}

@media (min-width: 1280px) {
    [dir="rtl"] .sgw-close {
        left: auto;
        right: 28px;
    }
}

/* ══════════════════════════════════════════════════
   ACCESSIBILITY — تحسينات إمكانية الوصول
══════════════════════════════════════════════════ */
.sgw-card:focus-visible {
    outline: 3px solid #D4AF37;
    outline-offset: 4px;
}

.sgw-close:focus-visible {
    outline: 3px solid #dc2626;
    outline-offset: 3px;
}

.sgw-cta:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .sgw-box,
    .sgw-card,
    .sgw-icon,
    .sgw-cta,
    .sgw-close {
        animation: none;
        transition: none;
    }
}
