/* FileXL Scan: the app screen of the Document Scanner (/tools/document-scanner/app/).
   Loaded after the page's own CSS, so it only has to override. Everything here is scoped to body.ds-app,
   except the small "Get the app" strip that the web page shows (.ds-getapp). */

:root {
    --ap-bg: #eef3fb;
    --ap-surface: #ffffff;
    --ap-ink: #1e293b;
    --ap-muted: #64748b;
    --ap-line: #dde5f1;
    --ap-blue: #0d6efd;
    --ap-violet: #6a3df0;
    --ap-bar-h: 58px;
    --ap-tab-h: 62px;
    --ap-sat: env(safe-area-inset-top, 0px);
    --ap-sab: env(safe-area-inset-bottom, 0px);
}
body.ds-app.dark-theme {
    --ap-bg: #0b1226;
    --ap-surface: #15203a;
    --ap-ink: #f1f5f9;
    --ap-muted: #a5b4cc;
    --ap-line: rgba(255, 255, 255, .12);
}

html { -webkit-text-size-adjust: 100%; }
body.ds-app {
    padding: 0 !important; margin: 0; display: block !important; min-height: 100vh; min-height: 100dvh;
    background: var(--ap-bg) !important; animation: none !important; color: var(--ap-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Nastaliq Urdu", sans-serif;
    -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; overflow-x: hidden;
}
body.ds-app { --text-main: var(--ap-ink); --text-muted: var(--ap-muted); --line: var(--ap-line); --bg-soft: rgba(100, 116, 139, .1); --bg-card: var(--ap-surface); }
body.ds-app.dark-theme { --bg-soft: rgba(255, 255, 255, .06); }
body.ds-app button, body.ds-app select, body.ds-app input { font-family: inherit; }
body.ds-app a { color: var(--ap-blue); }
body.ds-app.dark-theme a { color: #93c5fd; }

/* ---------- top bar ---------- */
.ap-bar {
    position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 10px;
    min-height: calc(var(--ap-bar-h) + var(--ap-sat)); padding: var(--ap-sat) 10px 0 12px; color: #fff;
    background: linear-gradient(120deg, #0d6efd, #5b4bf0 70%, #6a3df0); box-shadow: 0 2px 14px rgba(13, 40, 120, .28);
}
.ap-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; color: #fff !important; text-decoration: none; }
.ap-logo { width: 36px; height: 36px; border-radius: 10px; flex: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.ap-brand b { display: block; font-size: 1.04rem; font-weight: 700; line-height: 1.15; letter-spacing: .01em; }
.ap-brand small { display: block; font-size: .72rem; opacity: .85; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-ib { flex: none; width: 42px; height: 42px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.05rem; display: grid; place-items: center; cursor: pointer; }
.ap-ib:hover, .ap-ib:focus-visible { background: rgba(255, 255, 255, .26); outline: none; }
.ap-ib[hidden], .ap-pill[hidden] { display: none; }
.ap-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 13px; border: 0; border-radius: 999px; background: #fff; color: #1d4ed8; font-weight: 700; font-size: .84rem; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.ap-off { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; background: rgba(0, 0, 0, .26); font-size: .74rem; font-weight: 600; }
.ap-off[hidden] { display: none; }

/* ---------- main column ---------- */
.ap-main { width: 100%; max-width: 680px; margin: 0 auto; padding: 14px 14px calc(var(--ap-tab-h) + var(--ap-sab) + 28px); }
@media (min-width: 992px) { body.ds-editing .ap-main { max-width: 1060px; } }
.ap-view[hidden] { display: none; }

.ap-hero { text-align: center; padding: 6px 4px 14px; }
.ap-hero h1 { margin: 0 0 6px; font-size: 1.55rem; font-weight: 800; letter-spacing: -.01em; }
.ap-hero h1 span { background: linear-gradient(90deg, #0d6efd, #6a3df0); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.ap-hero p { margin: 0 auto; max-width: 460px; color: var(--ap-muted); font-size: .94rem; line-height: 1.55; }
body.ds-editing .ap-hero, body.ds-editing .ap-recent, body.ds-editing .ap-install, body.ds-editing .ap-foot { display: none !important; }

.ap-card { background: var(--ap-surface); border: 1px solid var(--ap-line); border-radius: 20px; padding: 16px; margin: 14px 0; box-shadow: 0 6px 20px rgba(15, 40, 100, .06); }
.ap-card h2 { margin: 0 0 4px; font-size: 1.02rem; font-weight: 700; }
.ap-card p { margin: 0; font-size: .88rem; color: var(--ap-muted); line-height: 1.5; }

/* the tool, as app screens */
body.ds-app .hj-tool { background: transparent; border: 0; box-shadow: none; padding: 0; max-width: none; border-radius: 0; margin: 0; }
body.ds-app .hj-note { display: none; }
body.ds-app .ds-drop {
    border: 0; border-radius: 26px; padding: 30px 18px 26px; cursor: default;
    background: var(--ap-surface); box-shadow: 0 14px 40px rgba(13, 70, 200, .14), 0 0 0 1px var(--ap-line);
}
body.ds-app .ds-drop:hover, body.ds-app .ds-drop:focus-visible { background: var(--ap-surface); }
body.ds-app .ds-drop.over { box-shadow: 0 0 0 3px var(--ap-violet); transform: none; }
body.ds-app .hj-drop-ico { width: 78px; height: 78px; border-radius: 24px; font-size: 2rem; margin-bottom: 10px; }
body.ds-app .hj-drop-t { font-size: 1.2rem; }
body.ds-app .hj-drop-s { font-size: .86rem; max-width: 320px; }
body.ds-app .ds-drop-btns { flex-direction: column; align-self: stretch; gap: 10px; margin-top: 16px; }
body.ds-app .ds-drop-btns .hj-btn { width: 100%; padding: 15px 20px; font-size: 1.04rem; border-radius: 16px; }
body.ds-app .ds-drop-btns .hj-btn.ghost { padding: 12px 18px; font-size: .95rem; }
body.ds-app.ds-pulse #dsTake { animation: ap-pulse 1.4s ease-in-out 3; }
@keyframes ap-pulse { 0%, 100% { box-shadow: 0 10px 24px rgba(13, 110, 253, .35); } 50% { box-shadow: 0 0 0 9px rgba(13, 110, 253, .22), 0 10px 24px rgba(13, 110, 253, .35); } }

body.ds-app .ds-work { background: var(--ap-surface); border: 1px solid var(--ap-line); border-radius: 22px; padding: 12px; box-shadow: 0 8px 26px rgba(15, 40, 100, .07); }
body.ds-app .ds-ai { margin: 12px 4px 0; }
body.ds-app .ds-ai small { display: none; }
body.ds-app .ds-ai span::after { content: ' (about 3.5 MB once, then works offline)'; color: var(--ap-muted); font-size: .78rem; }
body.ds-app .ds-stripbar { background: transparent; border: 0; padding: 0; margin-bottom: 10px; }

/* steps on phones: one thing at a time */
@media (max-width: 991px) {
    #hjTool[data-step="crop"] .ds-prev-sec, #hjTool[data-step="crop"] .ds-look-sec, #hjTool[data-step="crop"] .ds-save-sec { display: none; }
    #hjTool[data-step="look"] .ds-crop-sec, #hjTool[data-step="look"] .ds-save-sec { display: none; }
    #hjTool[data-step="save"] .ds-crop-sec, #hjTool[data-step="save"] .ds-prev-sec, #hjTool[data-step="save"] .ds-look-sec, #hjTool[data-step="save"] .ds-stripbar { display: none; }
    #hjTool[data-step] .ds-h { margin-top: 2px; }
}
@media (min-width: 992px) { .ap-stepbar { display: none !important; } }

/* ---------- bottom bars ---------- */
.ap-tabs, .ap-stepbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: stretch; justify-content: center;
    padding: 6px 10px calc(6px + var(--ap-sab)); background: var(--ap-surface); border-top: 1px solid var(--ap-line); box-shadow: 0 -6px 22px rgba(15, 40, 100, .09);
}
.ap-tabs[hidden], .ap-stepbar[hidden] { display: none; }
.ap-tabs button { flex: 1 1 0; max-width: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 50px; border: 0; background: transparent; color: var(--ap-muted); font-size: .74rem; font-weight: 600; border-radius: 14px; cursor: pointer; }
.ap-tabs button i { font-size: 1.2rem; }
.ap-tabs button[aria-current="page"] { color: var(--ap-blue); background: rgba(13, 110, 253, .09); }
body.dark-theme .ap-tabs button[aria-current="page"] { color: #93c5fd; background: rgba(147, 197, 253, .12); }
.ap-tabs button:focus-visible { outline: 3px solid var(--ap-blue); outline-offset: -2px; }
.ap-tabs .ap-badge { position: relative; }
.ap-tabs .ap-badge b { position: absolute; top: -6px; left: 62%; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: #fff; font-size: .64rem; line-height: 17px; text-align: center; }

.ap-stepbar { gap: 10px; align-items: center; }
.ap-sbtn { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1.5px solid var(--ap-line); background: transparent; color: var(--ap-ink); font-weight: 700; font-size: .95rem; cursor: pointer; }
.ap-sbtn.primary { border: 0; color: #fff; background: linear-gradient(135deg, #0d6efd, #6a3df0); box-shadow: 0 8px 20px rgba(13, 110, 253, .32); }
.ap-sbtn[disabled] { opacity: .4; pointer-events: none; }
.ap-sbtn[hidden] { display: none; }
.ap-dots { flex: 1 1 auto; display: flex; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ap-dots li { display: flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 600; color: var(--ap-muted); }
.ap-dots li::before { content: attr(data-n); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; color: var(--ap-muted); background: var(--bg-soft); }
.ap-dots li.on { color: var(--ap-ink); }
.ap-dots li.on::before { color: #fff; background: linear-gradient(135deg, #0d6efd, #6a3df0); }
@media (max-width: 380px) { .ap-dots li span { display: none; } }

/* ---------- lists: recent scans and My scans ---------- */
.ap-secthead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 2px 8px; }
.ap-secthead h2 { margin: 0; font-size: 1.04rem; font-weight: 700; }
.ap-link { border: 0; background: transparent; color: var(--ap-blue); font-weight: 600; font-size: .86rem; cursor: pointer; padding: 4px 2px; }
body.dark-theme .ap-link { color: #93c5fd; }
.ap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ap-item { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 4px 12px; padding: 12px; background: var(--ap-surface); border: 1px solid var(--ap-line); border-radius: 18px; box-shadow: 0 4px 14px rgba(15, 40, 100, .05); }
.ap-th { grid-row: span 2; width: 56px; height: 74px; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--ap-line); display: grid; place-items: center; color: #94a3b8; font-size: 1.4rem; }
.ap-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ap-nm { margin: 0; font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-meta { margin: 1px 0 0; font-size: .78rem; color: var(--ap-muted); }
.ap-acts { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ap-act { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--ap-line); background: transparent; color: var(--ap-ink); font-size: .8rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.ap-act:hover, .ap-act:focus-visible { border-color: var(--ap-blue); outline: none; }
.ap-act.x { color: #dc2626; }
.ap-empty { text-align: center; padding: 30px 18px; color: var(--ap-muted); }
.ap-empty i { font-size: 2rem; color: #94a3b8; margin-bottom: 8px; display: block; }
.ap-empty p { margin: 0; font-size: .9rem; line-height: 1.55; }
.ap-foot { margin: 18px 4px 0; text-align: center; font-size: .78rem; color: var(--ap-muted); line-height: 1.55; }

/* ---------- install card ---------- */
.ap-install { display: flex; gap: 12px; align-items: flex-start; }
.ap-install img { width: 46px; height: 46px; border-radius: 12px; flex: none; }
.ap-install .btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ap-install ol { margin: 8px 0 0; padding-left: 20px; font-size: .86rem; color: var(--ap-muted); line-height: 1.6; }
.ap-install[hidden] { display: none; }
.ap-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 12px; border: 0; cursor: pointer; font-weight: 700; font-size: .88rem; color: #fff; background: linear-gradient(135deg, #0d6efd, #6a3df0); text-decoration: none; }
body.ds-app a.ap-btn { color: #fff; }
.ap-btn.ghost { background: transparent; color: var(--ap-muted); border: 1.5px solid var(--ap-line); font-weight: 600; }
body.ds-app a.ap-btn.ghost { color: var(--ap-muted); }

/* ---------- sheet and toast ---------- */
.ap-sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; background: rgba(8, 15, 35, .55); }
.ap-sheet[hidden] { display: none; }
.ap-sheet-in { width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; background: var(--ap-surface); color: var(--ap-ink); border-radius: 24px 24px 0 0; padding: 10px 18px calc(20px + var(--ap-sab)); box-shadow: 0 -12px 40px rgba(0, 0, 0, .3); animation: ap-up .22s ease both; }
@keyframes ap-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .ap-sheet { align-items: center; } .ap-sheet-in { border-radius: 24px; padding-bottom: 20px; } }
.ap-grab { width: 42px; height: 4px; border-radius: 4px; background: var(--ap-line); margin: 2px auto 12px; }
.ap-sheet-in h2 { margin: 0 0 6px; font-size: 1.1rem; font-weight: 700; }
.ap-sheet-in p { margin: 0 0 10px; color: var(--ap-muted); font-size: .9rem; line-height: 1.55; }
.ap-menu { list-style: none; margin: 8px 0 0; padding: 0; }
.ap-menu li { border-top: 1px solid var(--ap-line); }
.ap-menu li:first-child { border-top: 0; }
.ap-menu a, .ap-menu button { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 6px 2px; border: 0; background: transparent; color: var(--ap-ink) !important; font-size: .96rem; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; }
.ap-menu i { width: 22px; text-align: center; color: var(--ap-blue); }
.ap-menu .sub { display: block; font-size: .76rem; font-weight: 500; color: var(--ap-muted); }
.ap-menu .tg { margin-left: auto; width: 44px; height: 26px; border-radius: 13px; background: #cbd5e1; position: relative; flex: none; transition: background .15s; }
.ap-menu .tg::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); transition: transform .15s; }
.ap-menu [aria-checked="true"] .tg { background: #22c55e; }
.ap-menu [aria-checked="true"] .tg::after { transform: translateX(18px); }
.ap-sheet-btns { display: flex; gap: 10px; margin-top: 14px; }
.ap-sheet-btns .ap-btn { flex: 1; justify-content: center; min-height: 46px; }
.ap-btn.danger { background: #dc2626; }

.ap-toast { position: fixed; left: 50%; bottom: calc(var(--ap-tab-h) + var(--ap-sab) + 16px); transform: translate(-50%, 20px); z-index: 90; max-width: calc(100% - 28px); padding: 11px 16px; border-radius: 14px; background: #0f172a; color: #fff; font-size: .86rem; font-weight: 600; box-shadow: 0 10px 28px rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; }
.ap-toast.on { opacity: 1; transform: translate(-50%, 0); }
.ap-hide { display: none !important; }

/* installed app: no browser bar, so the top bar is the only header */
@media (display-mode: standalone) { .ap-install-hint { display: none; } }

/* ---------- feature grid and questions (home screen) ---------- */
.ap-feats ul { list-style: none; margin: 14px 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ap-feats li { padding: 13px 12px; border-radius: 16px; background: var(--ap-surface); border: 1px solid var(--ap-line); display: grid; gap: 2px; align-content: start; }
.ap-feats i { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-size: .95rem; margin-bottom: 6px; background: linear-gradient(135deg, #0d6efd, #6a3df0); }
.ap-feats b { font-size: .9rem; font-weight: 700; }
.ap-feats span { font-size: .78rem; color: var(--ap-muted); line-height: 1.45; }
@media (min-width: 640px) { .ap-feats ul { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ap-faq details { border-top: 1px solid var(--ap-line); padding: 2px 0; }
.ap-faq h2 + details { border-top: 0; }
.ap-faq summary { cursor: pointer; padding: 12px 22px 12px 0; font-weight: 600; font-size: .92rem; list-style: none; position: relative; }
.ap-faq summary::-webkit-details-marker { display: none; }
.ap-faq summary::after { content: '+'; position: absolute; right: 2px; top: 9px; font-size: 1.3rem; font-weight: 400; color: var(--ap-muted); }
.ap-faq details[open] summary::after { content: '\2212'; }
.ap-faq details p { padding: 0 0 12px; }
.ap-faq summary:focus-visible { outline: 3px solid var(--ap-blue); outline-offset: 2px; border-radius: 6px; }
@media (max-width: 991px) { body.ds-editing .ap-tabs { display: none; } body.ds-editing .ap-toast { bottom: calc(var(--ap-tab-h) + var(--ap-sab) + 16px); } }
@media (prefers-reduced-motion: reduce) { body.ds-app * { animation: none !important; transition: none !important; } }

/* step bar: only the current step keeps its name, so Back, the dots and Next always fit */
.ap-dots { min-width: 0; }
.ap-dots li:not(.on) span { display: none; }
@media (min-width: 520px) { .ap-dots li:not(.on) span { display: inline; } }
.ap-sbtn { min-width: 0; }
@media (max-width: 991px) {
    #hjTool[data-step="look"] .ds-ai, #hjTool[data-step="save"] .ds-ai { display: none; }
}
body.ds-editing .ap-feats, body.ds-editing .ap-faq { display: none !important; }
