/* مملكة الملفات — main stylesheet. Logical properties (inline/block) keep RTL & LTR working. */
:root {
  --bg: #f6f7fb; --surface: #fff; --surface-2: #f1f3f9; --text: #161a2b; --muted: #5b6275; --border: #e2e5ef;
  --primary: #4338ca; --primary-2: #6366f1; --primary-soft: #eef0ff; --on-primary: #fff;
  --danger: #dc2626; --warn-bg: #fff7e6; --warn: #92400e; --ok: #059669;
  --c-pdf: #e5484d; --c-image: #0ea5e9; --c-excel: #16a34a; --c-utility: #8b5cf6;
  --radius: 14px; --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 4px 16px rgb(16 24 40 / .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1120; --surface: #161a2e; --surface-2: #1d2238; --text: #e8eaf4; --muted: #a2a8bd; --border: #2a3050;
    --primary: #818cf8; --primary-2: #a5b4fc; --primary-soft: #23284a; --on-primary: #0e1120;
    --warn-bg: #3a2a0a; --warn: #fcd34d; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.65; font-size: 16px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg, canvas { max-width: 100%; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.2rem, 2.6vw, 1.5rem); }
.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 16px; }
.icon { width: 1.25em; height: 1.25em; vertical-align: -.25em; flex: none; }
.i { display: inline-flex; }
.muted { color: var(--muted); }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; top: -100px; inset-inline-start: 16px; }
.skip:focus { top: 8px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--primary-2); outline-offset: 2px; }

/* Header */
.site-header { background: var(--surface); border-block-end: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-icon { width: 30px; height: 30px; color: #f59e0b; fill: #fde68a; }
.site-nav { margin-inline-start: auto; }
.site-nav > ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.site-nav a { display: block; padding: 8px 12px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: .95rem; }
.site-nav a:hover { background: var(--surface-2); text-decoration: none; }
.menu-btn { display: none; margin-inline-start: auto; background: none; border: 1px solid var(--border); border-radius: 10px; padding: 8px; color: var(--text); cursor: pointer; }
.lang-menu { position: relative; }
.lang-menu summary { list-style: none; display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: .9rem; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu ul { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); list-style: none; margin: 0; padding: 6px; min-width: 200px; max-height: 60vh; overflow: auto; z-index: 30; }
.lang-menu li a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); }
.lang-menu li a:hover, .lang-menu [aria-current] { background: var(--primary-soft); text-decoration: none; }
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .site-nav { display: none; position: absolute; inset-inline: 0; top: 64px; background: var(--surface); border-block-end: 1px solid var(--border); padding: 8px 16px 16px; }
  .site-nav.open { display: block; }
  .site-nav > ul { flex-direction: column; }
  .lang-menu summary span { display: none; }
}

/* Hero & sections */
main { padding-block: 24px 48px; }
.hero { text-align: center; padding-block: 32px 16px; }
.hero-sm { padding-block: 16px 8px; }
.hero h1 { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 720px; margin: 0 auto 1rem; }
.search-box { position: relative; max-width: 560px; margin: 20px auto 12px; }
.search-box .icon { position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { width: 100%; padding: 14px 16px; padding-inline-start: 46px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; box-shadow: var(--shadow); }
.privacy-pill { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 600; font-size: .92rem; }
p.privacy-pill.center { display: flex; justify-content: center; margin-block: 12px 0; }
.cat-section { margin-block: 36px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-block-end: 14px; }
.section-head h2 { margin: 0; display: flex; gap: 8px; align-items: center; }
.no-results { text-align: center; color: var(--muted); }

/* Tool cards */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tool-card { --c: var(--primary); display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.tool-card:hover { transform: translateY(-2px); border-color: var(--c); text-decoration: none; }
.tool-card-icon, .tool-head-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 12px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); flex: none; }
.tool-card-icon .icon { width: 30px; height: 30px; }
.tool-card-body { display: flex; flex-direction: column; gap: 2px; }
.tool-card-body span { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.cat-pdf { --c: var(--c-pdf); } .cat-image { --c: var(--c-image); } .cat-excel { --c: var(--c-excel); } .cat-utility { --c: var(--c-utility); }

/* Why */
.why { margin-block-start: 56px; text-align: center; }
.why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-block-start: 16px; }
.why-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.why-item .icon { width: 32px; height: 32px; color: var(--primary); }
.why-item h3 { margin-block: 10px 4px; font-size: 1.05rem; }
.why-item p { margin: 0; color: var(--muted); font-size: .93rem; }

/* Breadcrumb */
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; font-size: .88rem; color: var(--muted); }
.breadcrumb li:not(:last-child)::after { content: "›"; margin-inline-start: 6px; }
[dir="rtl"] .breadcrumb li:not(:last-child)::after { content: "‹"; }

/* Tool page */
.tool-head { display: flex; gap: 16px; align-items: flex-start; margin-block: 8px 12px; }
.tool-head-icon { width: 64px; height: 64px; border-radius: 18px; }
.tool-head-icon .icon { width: 40px; height: 40px; }
.tool-head .lead { margin: 0; text-align: start; }
.steps-inline { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 8px 0 0; counter-reset: s; }
.steps-inline li { counter-increment: s; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px 6px 6px; padding-inline: 6px 14px; font-size: .9rem; }
.steps-inline li::before { content: counter(s); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: .8rem; }
.tool-box { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: clamp(16px, 4vw, 32px); margin-block: 24px; min-height: 220px; }
.tool-loading { text-align: center; color: var(--muted); padding: 60px 0; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 48px 16px; border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--border)); border-radius: 16px; background: var(--primary-soft); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone .icon { width: 44px; height: 44px; color: var(--primary); }
.dropzone.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 18%, transparent); }
.dropzone.compact { padding: 18px; flex-direction: row; justify-content: center; flex-wrap: wrap; }
.dropzone.compact .icon { width: 26px; height: 26px; }
.dropzone.compact .btn-lg { padding: 8px 16px; font-size: .95rem; }
.file-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: 12px; }
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fsize { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: #fff; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 9px; cursor: pointer; }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.tool-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; margin-block: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field[hidden] { display: none; }
.field-label { display: flex; justify-content: space-between; gap: 8px; }
.field label { font-weight: 600; font-size: .93rem; }
.field small { color: var(--muted); font-size: .82rem; }
.field-check { flex-direction: row; align-items: center; gap: 10px; }
.field-check input { width: 20px; height: 20px; accent-color: var(--primary); }
.field-row { display: flex; gap: 14px; }
input[type=text], input[type=number], input[type=search], select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { resize: vertical; min-height: 120px; }
input[type=color] { width: 64px; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 3px; }
input[type=range] { width: 100%; accent-color: var(--primary); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none !important; transition: filter .15s, background .15s; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--on-primary); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover, .btn-outline.active { border-color: var(--primary); color: var(--primary); }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-sm { padding: 6px 12px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.notice { padding: 12px 14px; border-radius: 12px; margin-block: 12px; font-size: .93rem; }
.notice[hidden] { display: none; }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.tool-progress { text-align: center; padding: 40px 0; }
.progress { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; max-width: 520px; margin: 0 auto; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: inherit; transition: width .2s; }
.progress-bar.indeterminate { width: 35% !important; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-inline-start: -35%; } 100% { margin-inline-start: 100%; } }
.progress-text { color: var(--muted); margin-block-start: 12px; }
.result-head { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--ok); }
.result-head h2 { margin: 0; }
.result-head .icon { width: 32px; height: 32px; }
.result-note { text-align: center; color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-block: 16px; }

/* Utility tools */
.qr-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.qr-preview { text-align: center; }
.qr-canvas { width: 100%; max-width: 320px; height: auto; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
@media (max-width: 700px) { .qr-layout { grid-template-columns: 1fr; } }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-block-end: 16px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px; text-align: center; display: flex; flex-direction: column; }
.stat strong { font-size: 1.5rem; color: var(--primary); }
.stat span { color: var(--muted); font-size: .85rem; }

/* Ads — kept far from interactive controls */
.ad-wrap { margin-block: 40px; text-align: center; min-height: 100px; }
.ad-label { display: block; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-block-end: 4px; }
.ad-preview { display: grid; place-items: center; height: 120px; border: 2px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: .85rem; }

/* Content */
.content { margin-block: 40px; }
.content p { color: var(--text); }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px; margin-block: 10px; }
.faq-item summary { cursor: pointer; font-weight: 700; padding-block: 10px; }
.faq-item p { margin-block: 0 12px; color: var(--muted); }
.prose { max-width: 820px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(18px, 4vw, 40px); }
.prose h2 { margin-block-start: 1.6em; }
.contact-mail { font-size: 1.15rem; display: flex; gap: 8px; align-items: center; }

/* Bookmark bar */
.bookmark-bar { margin-block: 40px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.bookmark-bar summary { cursor: pointer; padding: 14px 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.bookmark-bar summary .icon { color: #f59e0b; }
.bookmark-body { padding: 0 18px 18px; }
.bm-actions { display: flex; flex-wrap: wrap; gap: 10px; }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-family: inherit; font-weight: 700; }

/* Footer */
.site-footer { background: var(--surface); border-block-start: 1px solid var(--border); padding-block: 40px 24px; margin-block-start: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.footer-grid p { color: var(--muted); font-size: .93rem; }
.footer-grid h2 { font-size: 1rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.footer-grid a:not(.brand) { color: var(--muted); }
.footer-langs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-block: 24px 12px; padding-block-start: 16px; border-block-start: 1px solid var(--border); font-size: .88rem; }
.footer-langs a { color: var(--muted); }
.copyright { color: var(--muted); font-size: .85rem; margin: 0; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > div:first-child { grid-column: 1 / -1; } }

/* Root language chooser */
.root-langs { text-align: center; padding-block: 60px; }
.lang-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.lang-list a { display: block; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.lang-list small { display: block; color: var(--muted); }

/* Category tiles (home) — hover/focus opens the tool list; tap on touch devices (JS toggles .open) */
.cat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-block: 8px 28px; position: relative; z-index: 5; }
.cat-tile { position: relative; }
.cat-tile-head { all: unset; box-sizing: border-box; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; width: 100%; height: 100%; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-block-start: 4px solid var(--c); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.cat-tile-head:focus-visible { outline: 3px solid var(--primary-2); }
.cat-tile-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.cat-tile-text strong { font-size: 1.1rem; }
.cat-tile-text span { color: var(--muted); font-size: .86rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-count { flex: none; min-width: 28px; height: 28px; padding: 0 8px; display: grid; place-items: center; border-radius: 999px; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); font-weight: 800; font-size: .85rem; }
.cat-flyout { position: absolute; top: calc(100% - 6px); inset-inline: 0; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-block-start: 3px solid var(--c); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 18px 40px rgb(16 24 40 / .18); opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .15s, transform .15s, visibility .15s; z-index: 10; }
.flyout-all { display: block; text-align: center; padding: 8px; margin-block-start: 4px; border-block-start: 1px solid var(--border); font-weight: 700; font-size: .9rem; }
@media (hover: hover) {
  .cat-tile:hover .cat-flyout, .cat-tile:focus-within .cat-flyout { opacity: 1; visibility: visible; transform: none; }
  .cat-tile:hover .cat-tile-head { transform: translateY(-2px); box-shadow: 0 10px 28px rgb(16 24 40 / .14); }
  .cat-tile:hover { z-index: 11; }
}
.cat-tile.open .cat-flyout { opacity: 1; visibility: visible; transform: none; }
.cat-tile.open { z-index: 11; }
@media (max-width: 900px) { .cat-tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) {
  .cat-tiles { grid-template-columns: 1fr; }
  .cat-flyout { position: static; display: none; min-width: 0; border-radius: 0 0 var(--radius) var(--radius); box-shadow: none; }
  .cat-tile.open .cat-flyout { display: block; }
}

/* Shared compact tool list (dropdowns) */
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.menu-list a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: .93rem; }
.menu-list a:hover, .menu-list a:focus-visible { background: color-mix(in srgb, var(--c) 10%, transparent); color: var(--c); text-decoration: none; }
.ml-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--c); flex: none; }
.ml-icon .icon { width: 22px; height: 22px; }

/* Header dropdowns */
.site-nav .has-menu { position: relative; }
.site-nav .mega { position: absolute; top: 100%; inset-inline-start: 0; width: 290px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 18px 40px rgb(16 24 40 / .18); opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .15s, transform .15s, visibility .15s; z-index: 40; }
.site-nav .mega a { padding: 7px 10px; }
@media (min-width: 861px) {
  .site-nav .has-menu:hover .mega, .site-nav .has-menu:focus-within .mega { opacity: 1; visibility: visible; transform: none; }
}
@media (max-width: 860px) {
  .site-nav { max-height: calc(100vh - 64px); overflow: auto; }
  .site-nav .has-menu > a { font-size: 1rem; color: var(--c); }
  .site-nav .mega { position: static; width: auto; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; padding: 0 0 8px; }
  .site-nav .menu-list { grid-template-columns: 1fr 1fr; }
}
.cat-tiles[hidden] { display: none; }

.site-nav .has-menu:nth-last-child(-n+2) .mega { inset-inline-start: auto; inset-inline-end: 0; }
