/* ============================================================================
   APEX SHIELD AI - ULTIMATE LUXURY EXECUTIVE STYLE (v18.0 Performance Edition)
   Developer & Founder: Karam Hamdy (كرم حمدي عبدالعظيم محمود عجاج)
   ============================================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    
    /* منع تحديد النصوص ومنع الزوم والتكبير باللمس */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

/* تخصيص الثيمات الفاخرة */
body.theme-cyan {
    --accent-color: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #4f46e5, #0284c7, #38bdf8);
    --orb-glow: rgba(56, 189, 248, 0.4);
    --panel-border: rgba(56, 189, 248, 0.25);
    --quantum-glow: rgba(245, 158, 11, 0.5);
    --ghost-1: transparent;
    --ghost-2: transparent;
}

body.theme-emerald {
    --accent-color: #10b981;
    --accent-gradient: linear-gradient(135deg, #047857, #059669, #34d399);
    --orb-glow: rgba(16, 185, 129, 0.4);
    --panel-border: rgba(16, 185, 129, 0.25);
    --quantum-glow: rgba(16, 185, 129, 0.5);
    --ghost-1: transparent;
    --ghost-2: transparent;
}

body.theme-purple {
    --accent-color: #c084fc;
    --accent-gradient: linear-gradient(135deg, #7e22ce, #9333ea, #e879f9);
    --orb-glow: rgba(192, 132, 252, 0.4);
    --panel-border: rgba(192, 132, 252, 0.25);
    --quantum-glow: rgba(192, 132, 252, 0.5);
    --ghost-1: transparent;
    --ghost-2: transparent;
}

body.theme-gold {
    --accent-color: #ffb703;
    --accent-gradient: linear-gradient(135deg, #d97706, #fb8500, #ffb703);
    --orb-glow: rgba(255, 183, 3, 0.4);
    --panel-border: rgba(255, 183, 3, 0.25);
    --quantum-glow: rgba(255, 183, 3, 0.5);
    --ghost-1: transparent;
    --ghost-2: transparent;
}

/* تهيئة الـ HTML و Body */
html {
    width: 100%;
    min-height: 100%;
    touch-action: pan-y;
}

body {
    width: 100%;
    min-height: 100dvh;
    background-color: #020617;
    color: #f8fafc;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    touch-action: pan-y;
}

/* إلغاء الهالات والمؤثرات الشبحية الثقيلة في الخلفية لمنع التهنيج */
body::before,
body::after {
    display: none !important;
}

/* Toast Notification Styles */
.toast-container {
    position: fixed;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 92%;
    max-width: 380px;
    pointer-events: none;
}

.toast-message {
    background: #0f172a;
    border: 1px solid var(--accent-color);
    color: #f8fafc;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: fadeInOut 3.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
    text-align: right;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-20px) scale(0.95); }
    15% { opacity: 1; transform: translateY(0) scale(1); }
    85% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-20px) scale(0.95); }
}

.panic-icon {
    border-color: rgba(239, 68, 68, 0.5) !important;
    color: #ef4444 !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}
.panic-icon:hover {
    background: #ef4444 !important;
    color: #fff !important;
}

/* Toggle Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(51, 65, 85, 0.8); transition: .3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.slider:before {
    position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px;
    background-color: white; transition: .3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
input:checked + .slider { background: var(--accent-gradient); border-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(18px); }

/* Radar Screen UI Styles */
.radar-screen {
    position: relative;
    width: 190px;
    height: 190px;
    margin: 15px auto;
    background: rgba(2, 6, 23, 0.95);
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    overflow: hidden;
}
.radar-sweep {
    position: absolute;
    top: 50%; left: 50%;
    width: 95px; height: 95px;
    background: linear-gradient(45deg, var(--accent-color), transparent);
    transform-origin: top left;
    animation: radar-spin 3.5s linear infinite;
    opacity: 0.6;
}
@keyframes radar-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.radar-center-dot {
    position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; background: #fff; border-radius: 50%; transform: translate(-50%, -50%);
}
.radar-blip {
    position: absolute; width: 8px; height: 8px; background: #ef4444; border-radius: 50%;
}
.blip-1 { top: 45px; right: 55px; animation: blip-pulse 2s infinite; }
.blip-2 { bottom: 50px; left: 45px; animation: blip-pulse 1.5s infinite 0.7s; }
@keyframes blip-pulse {
    0% { transform: scale(0.8); opacity: 0.4; }
    50% { transform: scale(1.4); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.4; }
}
.radar-log-box {
    background: rgba(2, 6, 23, 0.9); padding: 10px; border-radius: 10px; max-height: 100px; overflow-y: auto; text-align: right; font-size: 0.7rem; border: 1px solid var(--panel-border);
}
.radar-log-item { margin-bottom: 5px; color: #cbd5e1; font-family: monospace; }

/* Panels */
.glass-panel {
    background: #0f172a;
    border: 1px solid var(--panel-border);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
}

.glass-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease;
}
.glass-card:hover {
    border-color: var(--panel-border);
}

/* حاوية التطبيق الرئيسية */
.app-container {
    width: 100%;
    max-width: 430px;
    min-height: 100dvh;
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    padding: 0 16px 20px 16px;
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    touch-action: pan-y;
    overflow: hidden;
}

/* تثبيت المنطقة العلوية (STICKY TOP AREA) */
.sticky-top-area {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #0f172a;
    margin: 0 -16px 14px -16px;
    padding: 16px 16px 12px 16px;
    border-bottom: 1px solid var(--panel-border);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

/* تنسيق الهيدر والشعار والأزرار */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 1;
    min-width: 0;
}

.logo-area h1 {
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: -0.3px;
    color: #f8fafc;
    white-space: nowrap;
}

.ai-badge {
    background: var(--accent-gradient);
    color: white;
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 800;
    white-space: nowrap;
}

.ai-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-color);
    border-radius: 50%;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--accent-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--accent-color);
    color: #020617;
}

.badge-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.badge {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-color);
    padding: 5px 9px;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: all 0.2s;
    white-space: nowrap;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}
.badge:hover {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.1);
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
    justify-content: flex-start;
}

.connection-card {
    border-radius: 20px;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.orb-container {
    position: relative;
    width: 75px;
    height: 75px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.status-orb {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444, #7f1d1d);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    transition: background 0.3s ease;
}

.status-orb.connected {
    background: var(--accent-gradient);
    box-shadow: 0 0 20px var(--orb-glow);
}

.connection-card h2 { font-size: 1.05rem; font-weight: 800; color: #f8fafc; }
.connection-card p { font-size: 0.72rem; color: #94a3b8; font-weight: 500; }

.session-timer {
    font-size: 0.72rem;
    color: #34d399;
    font-weight: 700;
}
.session-timer.hidden { display: none; }

.connect-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 10px 24px;
    font-size: 0.88rem;
    font-weight: 800;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
.connect-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.connect-btn:active { transform: translateY(1px); }

.threat-widget {
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
}
.threat-widget:hover { background: #1e293b; border-color: var(--accent-color); }
.threat-label { font-size: 0.7rem; color: #94a3b8; display: block; font-weight: 600; }
.threat-widget strong { font-size: 1.05rem; color: var(--accent-color); font-weight: 800; }
.shield-status-indicator { width: 10px; height: 10px; border-radius: 50%; background-color: #10b981; }

.advanced-panel {
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 280px;
    overflow-y: auto;
}
.setting-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: #cbd5e1; font-weight: 500; padding: 2px 0; }
.clickable-row { cursor: pointer; padding: 4px 2px; border-radius: 6px; transition: color 0.2s; }
.clickable-row:hover { color: var(--accent-color); background: rgba(255, 255, 255, 0.03); padding-right: 6px; }
.accent-link { color: var(--accent-color); font-weight: 800; font-size: 0.7rem; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { border-radius: 14px; padding: 10px; text-align: center; }
.stat-box span { display: block; font-size: 0.65rem; color: #94a3b8; margin-bottom: 3px; font-weight: 600; }
.stat-box strong { font-size: 0.95rem; color: var(--accent-color); font-weight: 800; }

/* Modals & Layouts */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(2, 6, 23, 0.92);
    display: flex; justify-content: center; align-items: center;
    z-index: 99999; padding: 15px;
}
.modal.hidden { display: none; }
.modal-content {
    background: #0f172a;
    border-radius: 24px; padding: 22px; max-width: 390px; width: 100%;
    text-align: right; border: 1px solid var(--panel-border);
    max-height: 85vh; overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}
.text-center { text-align: center; }
.modal-icon { font-size: 2rem; margin-bottom: 10px; }
.modal-content h2 { font-size: 1.1rem; color: var(--accent-color); margin-bottom: 10px; font-weight: 800; }
.modal-content p { font-size: 0.75rem; color: #cbd5e1; line-height: 1.6; margin-bottom: 12px; }

.search-input {
    width: 100%; padding: 10px 14px; border-radius: 10px;
    background: rgba(2, 6, 23, 0.7); border: 1px solid rgba(255, 255, 255, 0.1);
    color: white; font-size: 0.8rem; margin-bottom: 12px;
}
.search-input:focus { outline: none; border-color: var(--accent-color); }

.vault-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.server-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.server-item {
    background: rgba(2, 6, 23, 0.5); padding: 10px 12px; border-radius: 10px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.05); font-size: 0.75rem; font-weight: 600;
    transition: background 0.2s;
}
.server-item:hover, .server-item.active { border-color: var(--accent-color); background: rgba(56, 189, 248, 0.08); }

.ping { font-size: 0.65rem; padding: 3px 6px; border-radius: 6px; font-weight: 700; }
.ping.good { color: #10b981; background: rgba(16, 185, 129, 0.15); }
.ping.medium { color: #f59e0b; background: rgba(245, 158, 11, 0.15); }

/* History & Vault items */
.history-list-container { max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.history-item { background: rgba(2, 6, 23, 0.6); padding: 10px; border-radius: 10px; font-size: 0.7rem; border: 1px solid rgba(255,255,255,0.05); display: flex; justify-content: space-between; align-items: center; }
.history-item strong { color: var(--accent-color); }

.split-apps-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.split-item { display: flex; justify-content: space-between; align-items: center; background: rgba(2, 6, 23, 0.5); padding: 10px 14px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; border: 1px solid rgba(255,255,255,0.05); cursor: pointer; }
.split-item:hover { background: rgba(2, 6, 23, 0.8); }
.split-toggle { accent-color: var(--accent-color); width: 16px; height: 16px; cursor: pointer; }

/* Scanner & Analytics */
.scanner-box { background: rgba(2, 6, 23, 0.6); padding: 12px; border-radius: 12px; font-size: 0.75rem; margin-top: 10px; border: 1px solid rgba(255,255,255,0.05); }
.threat-list-container { max-height: 130px; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.safe-item { background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.3); padding: 8px; border-radius: 8px; color: #a7f3d0; font-size: 0.7rem; font-weight: 600; }

.analytics-container { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
.metric-card { background: rgba(2, 6, 23, 0.5); padding: 10px 12px; border-radius: 10px; display: flex; justify-content: space-between; font-size: 0.75rem; font-weight: 600; border: 1px solid rgba(255,255,255,0.05); }
.metric-card strong { color: var(--accent-color); }
.app-usage-list { font-size: 0.75rem; background: rgba(2, 6, 23, 0.5); padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05); }
.app-usage-item { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-weight: 500; }

.wifi-stats-box { background: rgba(2, 6, 23, 0.5); padding: 12px; border-radius: 12px; font-size: 0.75rem; display: flex; flex-direction: column; gap: 8px; border: 1px solid rgba(255,255,255,0.05); }
.wifi-row { display: flex; justify-content: space-between; font-weight: 500; }
.wifi-row strong { color: var(--accent-color); font-weight: 700; }

#firewall-traffic-container::-webkit-scrollbar,
#stalkerware-results-container::-webkit-scrollbar,
#insights-stats-box::-webkit-scrollbar {
    width: 4px;
}

#firewall-traffic-container::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

/* Theme Buttons & AI Chat */
.theme-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.theme-btn { padding: 10px; border-radius: 10px; border: none; font-weight: 800; cursor: pointer; color: white; font-size: 0.75rem; transition: transform 0.2s; }
.theme-btn:hover { transform: scale(1.02); }
.theme-btn.cyan { background: #38bdf8; color: #020617; }
.theme-btn.emerald { background: #10b981; }
.theme-btn.purple { background: #c084fc; color: #020617; }
.theme-btn.gold { background: #ffb703; color: #020617; }

.ai-panel { max-width: 380px; height: 450px; display: flex; flex-direction: column; justify-content: space-between; }
.ai-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; font-weight: 800; color: var(--accent-color); border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px; }
.close-icon { background: none; border: none; color: #f8fafc; font-size: 1.3rem; cursor: pointer; }
.close-icon:hover { color: var(--accent-color); }
.ai-chat-box { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px 0; font-size: 0.75rem; }
.ai-message { padding: 8px 12px; border-radius: 12px; max-width: 85%; line-height: 1.5; font-weight: 500; }
.ai-message.bot { background: rgba(255, 255, 255, 0.05); color: #f8fafc; align-self: flex-start; border: 1px solid rgba(255,255,255,0.05); }
.ai-message.user { background: var(--accent-gradient); color: white; align-self: flex-end; font-weight: 700; }
.ai-input-area { display: flex; gap: 8px; margin-top: 8px; }
.ai-input-area input { flex-grow: 1; background: rgba(2, 6, 23, 0.6); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px; padding: 8px 12px; color: white; font-size: 0.75rem; }

.modal-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 15px; }
.btn-primary { background: var(--accent-gradient); color: white; border: none; padding: 9px 18px; border-radius: 10px; cursor: pointer; font-weight: 800; font-size: 0.8rem; transition: filter 0.2s; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: #334155; color: white; border: none; padding: 9px 18px; border-radius: 10px; cursor: pointer; font-size: 0.8rem; font-weight: 700; transition: background 0.2s; }
.btn-secondary:hover { background: #475569; }

.app-footer { text-align: center; font-size: 0.65rem; color: #64748b; margin-top: 12px; font-weight: 600; }
.app-footer a { color: #94a3b8; text-decoration: none; transition: color 0.2s; }
.app-footer a:hover { color: var(--accent-color); }

/* Apex Shield Pro Modal */
#pro-subscription-modal .modal-content {
    background: #0f172a;
    border: 1px solid #f59e0b;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

#open-pro-subscription-btn {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.4) !important;
    position: relative;
    overflow: hidden;
    transition: background 0.2s;
}

#open-pro-subscription-btn:hover {
    background: rgba(245, 158, 11, 0.2);
}

#photonic-canvas-overlay {
    transition: opacity 0.3s ease;
   }
