:root {
    /* Dark Mode Defaults */
    --bg-base: #050508;
    --bg-gradient-start: #0a0a14;
    --glass-bg: rgba(18, 18, 24, 0.65);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-highlight: rgba(255, 255, 255, 0.1);
    
    --primary-core: #4F46E5; 
    --primary-glow: rgba(79, 70, 229, 0.4);
    --secondary-core: #06B6D4; 
    --accent-core: #8B5CF6; 
    
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --success: #10B981;
    --danger: #F43F5E;
    
    --file-item-bg: rgba(0, 0, 0, 0.2);
    --toast-bg: rgba(18, 18, 24, 0.9);
    
    --radius-lg: 24px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Mode Overrides */
[data-theme="light"] {
    --bg-base: #F8FAFC;
    --bg-gradient-start: #E2E8F0;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-highlight: rgba(0, 0, 0, 0.05);
    
    --primary-core: #4338CA;
    --primary-glow: rgba(67, 56, 202, 0.3);
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    
    --file-item-bg: rgba(255, 255, 255, 0.6);
    --toast-bg: rgba(255, 255, 255, 0.95);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Flexbox Body for Sticky Footer */
body { 
    font-family: 'Inter', sans-serif; 
    background-color: var(--bg-base); 
    color: var(--text-primary); 
    min-height: 100vh; max-width: 100vw; overflow-x: hidden; 
    line-height: 1.5;
    transition: background-color 0.5s ease, color 0.5s ease;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; }

/* Top Floating Glass Icon Buttons (Theme & Install) */
.glass-icon-btn {
    position: fixed; top: 25px; z-index: 1001;
    width: 45px; height: 45px; border-radius: 50%;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    color: var(--text-primary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); 
    transition: var(--transition-smooth);
    overflow: hidden; outline: none;
}
.glass-icon-btn:hover { transform: scale(1.1); color: var(--primary-core); border-color: var(--primary-core); box-shadow: 0 4px 20px var(--primary-glow); }
.glass-icon-btn i { position: absolute; transition: 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); }

/* Positions */
.right-btn { right: 30px; }
.left-btn { left: 30px; }

/* Theme Animation Logic */
.right-btn .fa-sun { transform: translateY(40px) rotate(90deg); opacity: 0; }
.right-btn .fa-moon { transform: translateY(0) rotate(0); opacity: 1; }
[data-theme="light"] .right-btn .fa-sun { transform: translateY(0) rotate(0); opacity: 1; color: #F59E0B; }
[data-theme="light"] .right-btn .fa-moon { transform: translateY(-40px) rotate(-90deg); opacity: 0; }

/* Install Icon Animation */
.left-btn .fa-download { color: var(--success); }
.left-btn:hover .fa-download { transform: translateY(3px); }

/* Ambient Background */
.ambient-background { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(circle at top right, var(--bg-gradient-start) 0%, var(--bg-base) 100%); transition: background 0.5s ease; }
.noise-overlay { position: absolute; inset: 0; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E"); z-index: 1; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.4; animation: floatOrb 15s ease-in-out infinite alternate; transition: opacity 0.5s; }
[data-theme="light"] .orb { opacity: 0.15; filter: blur(80px); }
.orb-primary { width: 50vw; height: 50vw; background: var(--primary-core); top: -20%; left: -10%; }
.orb-secondary { width: 40vw; height: 40vw; background: var(--secondary-core); bottom: -10%; right: -10%; animation-delay: -5s; }
.orb-accent { width: 30vw; height: 30vw; background: var(--accent-core); top: 30%; left: 40%; animation-delay: -10s; }
@keyframes floatOrb { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(5vw, 5vh) scale(1.1); } }

/* Glassmorphism */
.luxury-glass { background: var(--glass-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--glass-border); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05); transition: background 0.5s ease, border 0.5s ease; }

/* Header */
.luxury-glass-header { background: var(--glass-bg); backdrop-filter: blur(30px); border-bottom: 1px solid var(--glass-border); padding: 1rem 4rem; display: flex; justify-content: center; align-items: center; position: sticky; top: 0; z-index: 100; width: 100%; transition: background 0.5s ease; }
.logo-wrapper { display: flex; align-items: center; gap: 1rem; }
.brand-text { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; }
.brand-text .dot { color: var(--primary-core); }
.brand-logo { width: 40px; height: 40px; border-radius: var(--radius-sm); }

/* Main Layout (Flex 1 to push footer down) */
.app-layout { flex: 1 0 auto; display: grid; grid-template-columns: 1fr 380px; gap: 2rem; max-width: 1400px; margin: 2rem auto; padding: 0 2rem; align-items: start; width: 100%; box-sizing: border-box; }

/* Dropzone */
.smart-dropzone { border-radius: var(--radius-lg); padding: 4rem 2rem; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer; transition: var(--transition-smooth); border: 2px dashed var(--glass-border); width: 100%; word-break: break-word; }
.smart-dropzone:hover, .smart-dropzone.drag-active { border-color: var(--primary-core); background: var(--glass-highlight); }
.icon-ring { width: 80px; height: 80px; border-radius: 50%; background: var(--glass-highlight); border: 1px solid var(--glass-highlight); display: flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: 1.5rem; transition: var(--transition-smooth); }
.smart-dropzone:hover .icon-ring { background: var(--primary-core); color: #fff; transform: translateY(-5px); box-shadow: 0 0 20px var(--primary-glow); }
.text-highlight { color: var(--primary-core); font-weight: 600; }

/* File Manager */
.file-manager { border-radius: var(--radius-lg); padding: 1.5rem; margin-top: 1.5rem; width: 100%; overflow: hidden; box-sizing: border-box; transition: var(--transition-smooth); }
.drag-active-mini { border: 2px dashed var(--primary-core) !important; background: var(--glass-highlight) !important; transform: scale(1.01); box-shadow: 0 0 30px var(--primary-glow); }
.fm-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 1rem;}
.badge { background: var(--glass-highlight); padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; }
.file-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 400px; overflow-y: auto; overflow-x: hidden; padding-right: 5px; width: 100%; }
.file-list::-webkit-scrollbar { width: 6px; }
.file-list::-webkit-scrollbar-thumb { background: var(--glass-highlight); border-radius: 10px; }

/* File Item & Enhanced Drag Reordering Styles */
.file-item { position: relative; background: var(--file-item-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-md); padding: 1rem; display: flex; align-items: center; gap: 1rem; max-width: 100%; box-sizing: border-box; transition: background 0.3s, transform 0.2s; cursor: grab; }
.file-item:active { cursor: grabbing; }
.file-item.dragging { opacity: 0.5; background: var(--glass-highlight); border-color: var(--primary-core); transform: scale(0.98); }

/* الخط المضيء الاحترافي لتحديد مكان السحب */
.file-item.drag-over-top::before {
    content: ''; position: absolute; top: -5px; left: 0; right: 0;
    height: 4px; background: var(--primary-core); border-radius: 4px;
    box-shadow: 0 0 15px var(--primary-glow); z-index: 10;
}
.file-item.drag-over-bottom::after {
    content: ''; position: absolute; bottom: -5px; left: 0; right: 0;
    height: 4px; background: var(--primary-core); border-radius: 4px;
    box-shadow: 0 0 15px var(--primary-glow); z-index: 10;
}
.file-item.drag-over-top, .file-item.drag-over-bottom { background: rgba(79, 70, 229, 0.15); }

.drag-handle { color: var(--text-secondary); cursor: grab; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; padding-right: 10px; transition: 0.3s;}
.file-item:hover .drag-handle { color: var(--text-primary); }
.file-icon { width: 40px; height: 40px; min-width: 40px; border-radius: var(--radius-sm); object-fit: cover; background: var(--glass-highlight); display:flex; align-items:center; justify-content:center; color: var(--text-secondary);}
.file-info { flex: 1; min-width: 0; pointer-events: none; }
.file-name { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; pointer-events: none;}
.file-meta { font-size: 0.75rem; color: var(--text-secondary); pointer-events: none;}
.file-remove { background: transparent; border: none; color: var(--text-secondary); cursor: pointer; padding: 5px 10px; transition: 0.2s; font-size: 1.2rem;}
.file-remove:hover { color: var(--danger); transform: scale(1.1);}
.fm-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* Smart Toolset Panel */
.toolset-panel { border-radius: var(--radius-lg); padding: 1.5rem; position: sticky; top: 100px; width: 100%; box-sizing: border-box;}
.panel-header { margin-bottom: 1.5rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 1rem; }
.panel-header h3 { display: flex; align-items: center; gap: 10px; color: var(--primary-core); font-size: 1.2rem;}
.panel-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-top: 5px;}

.dynamic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; width: 100%; }

/* Smart Buttons */
.smart-btn {
    background: var(--glass-highlight);
    border: 1px solid var(--glass-border); color: var(--text-primary);
    padding: 12px; border-radius: var(--radius-md); font-size: 0.95rem; font-weight: 600;
    cursor: pointer; transition: var(--transition-smooth);
    display: flex; flex-direction: column; align-items: center; gap: 8px; justify-content: center;
    text-align: center; word-break: break-word; white-space: normal; line-height: 1.2;
}
.smart-btn i { font-size: 1.5rem; color: var(--text-secondary); transition: 0.3s; }
.smart-btn:hover { background: var(--glass-highlight); border-color: var(--primary-core); transform: translateY(-3px); box-shadow: 0 5px 20px var(--primary-glow); }
.smart-btn:hover i { color: var(--primary-core); }

.smart-btn.action-compress:hover { border-color: var(--secondary-core); }
.smart-btn.action-compress:hover i { color: var(--secondary-core); }
.smart-btn.action-pdf:hover { border-color: var(--danger); }
.smart-btn.action-pdf:hover i { color: var(--danger); }
.smart-btn.action-vector:hover { border-color: #F59E0B; }
.smart-btn.action-vector:hover i { color: #F59E0B; }

/* Basic Buttons */
.btn { padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 500; cursor: pointer; transition: 0.3s; font-size: 0.9rem; border:none;}
.btn-outline { background: transparent; border: 1px solid var(--primary-core); color: var(--text-primary); }
.btn-outline:hover { background: var(--primary-core); color: #fff; box-shadow: 0 0 15px var(--primary-glow); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--danger); background: rgba(244, 63, 94, 0.1); }

/* Footer */
.app-footer {
    flex-shrink: 0; margin-top: auto;
    text-align: center; padding: 25px 20px;
    color: var(--text-secondary); font-size: 0.95rem; font-weight: 500;
    border-top: 1px solid var(--glass-border); width: 100%;
    backdrop-filter: blur(10px); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Toast Notifications */
.toast-container { position: fixed; bottom: 30px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: 90vw; }
.toast { background: var(--toast-bg); backdrop-filter: blur(10px); border: 1px solid var(--glass-border); padding: 16px 20px; border-radius: var(--radius-sm); color: var(--text-primary); display: flex; align-items: center; gap: 12px; font-size: 0.9rem; font-weight: 500; animation: slideInRight 0.4s forwards; box-shadow: 0 10px 30px rgba(0,0,0,0.15); word-break: break-word; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.hiding { animation: slideOutRight 0.4s forwards; }
@keyframes slideInRight { from { transform: translateX(120%); } to { transform: translateX(0); } }
@keyframes slideOutRight { from { transform: translateX(0); } to { transform: translateX(120%); } }

/* Loader Overlay */
.overlay { position: fixed; inset: 0; background: var(--glass-bg); backdrop-filter: blur(15px); z-index: 2000; display: flex; align-items: center; justify-content: center; transition: 0.3s; }
.loader-core { text-align: center; width: 90%; max-width: 300px; color: var(--text-primary); }
.circular-loader { width: 60px; height: 60px; animation: rotate 2s linear infinite; margin-bottom: 20px;}
.loader-path { stroke: var(--primary-core); stroke-linecap: round; animation: dash 1.5s ease-in-out infinite; }
.progress-bar-container { width: 100%; height: 6px; background: var(--glass-highlight); border-radius: 10px; margin-top: 15px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary-core), var(--secondary-core)); transition: width 0.3s ease; }
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash { 0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; } 50% { stroke-dasharray: 89, 200; stroke-dashoffset: -35px; } 100% { stroke-dasharray: 89, 200; stroke-dashoffset: -124px; } }

.hidden { display: none !important; }

/* Responsive Rules for Mobile */
@media (max-width: 1024px) {
    .app-layout { grid-template-columns: 1fr; padding: 0 1.5rem; gap: 1rem; margin: 1rem auto; width: 100%; box-sizing: border-box; }
    .toolset-panel { position: relative; top: 0; width: 100%; }
}

@media (max-width: 600px) {
    .luxury-glass-header { padding: 1rem; }
    .brand-text { font-size: 1.2rem; }
    
    .app-layout { padding: 0 10px; margin: 10px auto; width: 100%; box-sizing: border-box; }
    .smart-dropzone { padding: 2rem 1rem; }
    .smart-dropzone h2 { font-size: 1.2rem; }
    .icon-ring { width: 60px; height: 60px; font-size: 1.5rem; }
    
    /* Top Floating Buttons Mobile Fixes */
    .glass-icon-btn { top: 15px; width: 40px; height: 40px; font-size: 1.1rem; }
    .right-btn { right: 15px; }
    .left-btn { left: 15px; }

    .dynamic-grid { grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
    .smart-btn { padding: 10px 5px; font-size: 0.8rem; }
    .smart-btn i { font-size: 1.2rem; margin-bottom: 3px; }
    
    .toast-container { right: 5%; left: 5%; align-items: center; bottom: 30px; width: 90%; }
    .fm-actions { flex-direction: column; width: 100%; }
    .fm-actions .btn { width: 100%; }
}


/* --- Protection Rules: Disable Text Selection --- */
body {
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none;   /* Safari */
    -moz-user-select: none;      /* Firefox */
    -ms-user-select: none;       /* Internet Explorer/Edge */
    user-select: none;           /* Non-prefixed version, currently supported by Chrome, Opera and Edge */
}

/* Allow text selection only inside input fields if needed */
input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}