* { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; }
html { touch-action: pan-x pan-y; }
/* ==========================================================================
   VOID CONVERTER PRO - ENTERPRISE UI (SHADCN/UI INSPIRED)
   Engineered for Performance and Professionalism
   ========================================================================== */

html, body {
    /* يمنع حركة الارتداد والسحب للتحديث */
    overscroll-behavior-y: none;
    overscroll-behavior-x: none;
}

/* --------------------------------------------------------------------------
   CSS VARIABLES (THEME TOKENS)
   -------------------------------------------------------------------------- */
:root {
    /* Dark Theme (Zinc/Slate Vibe) */
    --bg: #09090b;
    --bg-2: #09090b;
    --surface: #09090b;
    --surface-2: #18181b;
    --surface-3: #27272a;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --muted: #a1a1aa;
    
    /* Primary Colors (High Contrast White on Dark) */
    --primary: #fafafa;
    --primary-2: #e4e4e7;
    --primary-text: #09090b;
    
    /* Shadows & Radiuses (Minimalist) */
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-soft: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --radius-xl: 8px;
    --radius-lg: 8px;
    --radius-md: 6px;
    --radius-sm: 4px;
}

html[data-theme=light] {
    /* Light Theme (Clean Zinc) */
    --bg: #ffffff;
    --bg-2: #ffffff;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --surface-3: #e4e4e7;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #09090b;
    --muted: #71717a;
    
    /* Primary Colors (High Contrast Black on Light) */
    --primary: #18181b;
    --primary-2: #27272a;
    --primary-text: #fafafa;
    
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-soft: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* --------------------------------------------------------------------------
   GLOBAL RESET & BASE
   -------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    color-scheme: dark;
}

html[data-theme=light] body {
    color-scheme: light;
}

/* إخفاء البارتكلز أو جعلها شبه معدومة للحفاظ على جدية التصميم */
#particles-js {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.02; 
}

/* --------------------------------------------------------------------------
   LAYOUT STRUCTURE
   -------------------------------------------------------------------------- */
.main-container {
    position: relative;
    z-index: 1;
    width: min(100%, 1024px); /* عرض أكثر احترافية للداشبورد */
    margin: 0 auto;
    padding: 32px 24px;
    min-height: 100vh;
}

.brand, .brand-text, .field, .file-meta { min-width: 0; }
.brand-icon, .theme-switcher { background: var(--surface); box-shadow: var(--shadow-soft); }
.brand-icon, .sphere, .upload-area { place-items: center; }
.file-remove, .sphere, .theme-btn, .upload-area { cursor: pointer; }

/* --------------------------------------------------------------------------
   HEADER COMPONENTS
   -------------------------------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: grid;
    border: 1px solid var(--border);
    font-size: 20px;
    flex: 0 0 auto;
    background: var(--surface-2);
}

.brand-text h1 { margin: 0; font-size: 18px; line-height: 1.2; color: var(--text); font-weight: 700; }
.brand-text p { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.7; letter-spacing: 0; }

.theme-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.theme-btn {
    min-width: 70px;
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    user-select: none;
    transition: all 0.15s ease;
}

.theme-btn.is-active {
    background: var(--surface-3);
    color: var(--text);
    box-shadow: var(--shadow-soft);
}

/* Language buttons: make the selected state unmistakable in both RTL/LTR */
.theme-switcher [data-lang-value].is-active,
.theme-switcher [data-lang-value].active {
    background: var(--surface-3);
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: none;
    outline: 1px solid var(--border-strong);
    outline-offset: -1px;
}

html[data-theme=dark] .theme-switcher [data-lang-value].is-active,
html[data-theme=dark] .theme-switcher [data-lang-value].active {
    background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
    color: var(--text);
}

/* --------------------------------------------------------------------------
   CARDS & CONTAINERS
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.upload-card {
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.list-card, .controls-card {
    padding: 24px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); line-height: 1.5; }
.section-note { color: var(--muted); font-size: 13px; line-height: 1.6; }

/* --------------------------------------------------------------------------
   UPLOAD AREA (DRAG & DROP)
   -------------------------------------------------------------------------- */
.sphere {
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: grid;
    background: var(--surface-2);
    box-shadow: var(--shadow-soft);
}
.preview-icon { font-size: 20px; line-height: 1; }

.upload-area {
    width: 100%;
    min-height: 180px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background: var(--surface);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.upload-area:hover {
    background: var(--surface-2);
    border-color: var(--muted);
}
.upload-area.is-dragover {
    border-color: var(--primary);
    background: var(--surface-2);
    box-shadow: 0 0 0 1px var(--primary);
}


.upload-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.8; letter-spacing: 0; text-wrap: balance; }
.upload-subtitle { display: block; margin-top: 8px; font-size: 14px; color: var(--muted); }

/* --------------------------------------------------------------------------
   FILES LIST
   -------------------------------------------------------------------------- */
.files-list { display: grid; gap: 8px; }

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    transition: border-color 0.15s ease;
}

.file-item:hover { border-color: var(--border-strong); }

.file-item-info { min-width: 0; display: flex; align-items: center; gap: 16px; }

.file-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    padding: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    flex: 0 0 auto;
}

.file-name { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.file-size { margin: 4px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-stats { margin-top: 6px; display: grid; gap: 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-stats-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.compression-note { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.6; }

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

.file-remove, .file-status {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s ease;
}

.file-remove:hover { background: var(--surface-3); border-color: var(--border-strong); }

.file-status { min-width: 90px; text-align: center; }
.file-status.is-success { border-color: #22c55e; color: #22c55e; background: rgba(34, 197, 94, 0.1); }
.file-status.is-error { border-color: #ef4444; color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.file-item.is-busy { opacity: 0.7; pointer-events: none; }

/* --------------------------------------------------------------------------
   FORM CONTROLS & ADVANCED SETTINGS
   -------------------------------------------------------------------------- */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    align-items: start;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: end;
}

.field { display: flex; flex-direction: column; gap: 8px; }

.format-label { display: block; color: var(--text); font-size: 13px; font-weight: 600; }

.format-select {
    width: 100%;
    min-height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0 12px;
    font-size: 14px;
    outline: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: auto;
}

.format-select:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.format-select:disabled { opacity: 0.5; cursor: not-allowed; background: var(--surface-2); }

/* إزالة أسهم حقول الأرقام لشكل أكثر احترافية */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

.dimensions-inputs { display: flex; align-items: center; gap: 8px; }
.dimensions-inputs input { width: 100%; text-align: center; font-variant-numeric: tabular-nums; }
.dim-separator { color: var(--muted); font-weight: 600; font-size: 14px; user-select: none; }

/* --------------------------------------------------------------------------
   BUTTONS
   -------------------------------------------------------------------------- */
.btn, .btn-download-single, .zip-form button {
    min-height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-convert {
    background: var(--primary);
    color: var(--primary-text);
}
.btn-convert:hover { background: var(--primary-2); }

.btn-download-single, .btn-zip {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}
.btn-download-single:hover, .btn-zip:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
}

.is-hidden { display: none !important; }

/* --------------------------------------------------------------------------
   UTILITIES
   -------------------------------------------------------------------------- */
.noscript-box {
    width: min(100%, 740px);
    margin: 20px auto;
    padding: 16px;
    border: 1px solid #ef4444;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    text-align: center;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   RESPONSIVE DESIGN
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .controls-grid { grid-template-columns: 1fr; }
    .upload-area { min-height: 160px; }
}

@media (max-width: 680px) {
    .main-container { padding: 16px 12px; }
    .file-item, .topbar { flex-direction: column; align-items: stretch; }
    .topbar { gap: 20px; }
    .theme-switcher { justify-content: stretch; width: 100%; }
    .theme-btn { width: 50%; }
    .controls-card, .list-card, .upload-card { padding: 16px; }
    .section-head { flex-direction: column; align-items: flex-start; }
    .btn, .btn-download-single, .file-item-info, .format-select, .zip-form button { width: 100%; }
    .file-actions { width: 100%; justify-content: stretch; }
    .file-remove, .file-status { flex: 1; text-align: center; }
}

.list-card { min-height: 200px; contain: paint; }
body.is-ar .brand-text p { letter-spacing: 0; }
