/* PDF Surgeon — dumbshit.app
 * Theme: clinical operating-room dark, with surgical teal accents.
 */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg: #0a0d10;
    --bg-2: #15191e;
    --bg-3: #1f242b;
    --border: #2a323b;
    --text: #f0f4f8;
    --text-dim: #a8b3bf;
    --text-mute: #6b7785;
    --accent: #14b8a6;          /* surgical teal */
    --accent-hov: #5eead4;
    --warning: #fbbf24;
    --danger: #ef4444;
    --select: rgba(20, 184, 166, 0.16);
}

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ===== topbar ===== */
.topbar { padding: 24px 24px 8px; max-width: 1400px; margin: 0 auto; }
.back { color: var(--text-mute); text-decoration: none; font-family: ui-monospace, monospace; font-size: 12px; }
.back:hover { color: var(--text); }
.topbar h1 {
    margin: 12px 0 4px;
    font-size: clamp(24px, 4vw, 36px);
    font-weight: 900;
    letter-spacing: 0.06em;
    font-family: ui-monospace, "SF Mono", monospace;
    color: var(--accent);
}
.topbar .sub { margin: 0; color: var(--text-dim); font-size: 14px; font-family: ui-monospace, monospace; font-style: italic; }

.app { max-width: 1400px; margin: 0 auto; padding: 16px 24px 60px; }

/* ===== landing / drop ===== */
.landing { padding: 20px 0; max-width: 880px; margin: 0 auto; }
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 80px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.18s;
    background: linear-gradient(180deg, rgba(20, 184, 166, 0.02), transparent);
    user-select: none;
}
.dropzone:hover, .dropzone:focus, .dropzone.is-drag {
    border-color: var(--accent);
    background: rgba(20, 184, 166, 0.06);
}
.dropzone:focus { outline: none; }
.dz-icon { font-size: 56px; margin-bottom: 18px; }
.dz-title { font-family: ui-monospace, monospace; font-weight: 800; font-size: 20px; letter-spacing: 0.08em; color: var(--text); }
.dz-sub { margin-top: 10px; color: var(--text-dim); font-size: 14px; }
.dz-formats { margin-top: 6px; color: var(--text-mute); font-family: ui-monospace, monospace; font-size: 11px; }

.feature-pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 24px; }
.feature-pills .pill {
    padding: 6px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px;
    font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-dim);
}

.manifesto {
    margin: 24px auto 0;
    max-width: 700px;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}
.manifesto a { color: var(--accent); text-decoration: none; }
.manifesto a:hover { text-decoration: underline; }

/* ===== workspace toolbar ===== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    align-items: center;
}
.toolbar-group {
    display: flex;
    gap: 4px;
    padding: 0 6px;
    border-right: 1px solid var(--bg-3);
}
.toolbar-group:last-child { border-right: 0; }
.toolbar-group.toolbar-right { margin-left: auto; }
.tb-btn {
    appearance: none;
    background: var(--bg-3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 12px;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
}
.tb-btn:hover:not(:disabled) { background: var(--border); }
.tb-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tb-btn.primary {
    background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 800;
    letter-spacing: 0.04em;
}
.tb-btn.primary:hover:not(:disabled) { background: var(--accent-hov); border-color: var(--accent-hov); }
.tb-btn.danger { color: #fecaca; border-color: rgba(239,68,68,0.4); }
.tb-btn.danger:hover:not(:disabled) { background: rgba(239,68,68,0.12); }
.tb-btn.small { padding: 4px 8px; font-size: 11px; }

/* ===== work grid ===== */
.work-grid { display: grid; grid-template-columns: 1fr 320px; gap: 12px; align-items: start; }
.work-grid:has(.sidebar.hidden) { grid-template-columns: 1fr; }
.grid-wrap {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    min-height: 400px;
    max-height: 70vh;
    overflow-y: auto;
}
.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.page-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    position: relative;
    cursor: pointer;
    transition: all 0.12s;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.page-card:hover { border-color: var(--text-mute); }
.page-card.selected {
    border-color: var(--accent);
    background: var(--select);
    box-shadow: 0 0 0 1px var(--accent);
}
.page-card.dragging { opacity: 0.35; }
.page-card.drop-before { box-shadow: -3px 0 0 var(--accent); }
.page-card.drop-after  { box-shadow:  3px 0 0 var(--accent); }
.page-card .thumb {
    width: 100%;
    aspect-ratio: 8.5 / 11;
    background: #fff;
    border-radius: 4px;
    display: grid; place-items: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}
.page-card .thumb canvas, .page-card .thumb img {
    max-width: 100%; max-height: 100%;
    display: block;
}
.page-card .thumb .ph {
    color: var(--text-mute);
    font-family: ui-monospace, monospace;
    font-size: 11px;
    text-align: center;
}
.page-card .meta { display: flex; align-items: center; justify-content: space-between; font-family: ui-monospace, monospace; font-size: 10px; color: var(--text-mute); }
.page-card .badge {
    background: var(--bg-3);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text-dim);
}
.page-card.has-signature::after {
    content: '✍';
    position: absolute;
    top: 6px; right: 6px;
    background: var(--accent);
    color: var(--bg);
    width: 18px; height: 18px;
    border-radius: 999px;
    display: grid; place-items: center;
    font-size: 11px;
}

/* ===== sidebar ===== */
.sidebar {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    max-height: 70vh;
    overflow-y: auto;
}
.side-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
    font-family: ui-monospace, monospace;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    color: var(--text-mute);
}

/* ===== vitals ===== */
.vitals {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: ui-monospace, monospace;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.04em;
}

/* ===== modal ===== */
.modal {
    position: fixed; inset: 0;
    background: rgba(10, 13, 16, 0.86);
    backdrop-filter: blur(6px);
    display: grid;
    place-items: center;
    z-index: 100;
    padding: 20px;
}
.modal-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    max-width: 560px;
    width: 100%;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
    font-family: ui-monospace, monospace;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 12px;
    color: var(--text-dim);
}

/* ===== overlay (processing) ===== */
.overlay {
    position: fixed; inset: 0;
    background: rgba(10, 13, 16, 0.86);
    backdrop-filter: blur(6px);
    display: grid; place-items: center;
    z-index: 200;
    padding: 20px;
}
.overlay-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 32px;
    text-align: center;
    max-width: 360px;
}
.overlay-eyebrow { font-family: ui-monospace, monospace; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 8px; }
.overlay-card h2 { margin: 0 0 8px; font-family: ui-monospace, monospace; font-size: 18px; color: var(--accent); }
.hint { color: var(--text-mute); font-family: ui-monospace, monospace; font-size: 11px; margin: 0; }

/* ===== modal: signature pad ===== */
.sig-pad {
    width: 100%;
    aspect-ratio: 2 / 1;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 10px;
    touch-action: none;
    cursor: crosshair;
}
.sig-row {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* ===== modal: metadata ===== */
.meta-form { display: flex; flex-direction: column; gap: 8px; }
.meta-form label { display: block; font-family: ui-monospace, monospace; font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.meta-form input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 8px 10px;
}
.meta-form input:focus { outline: none; border-color: var(--accent); }
.meta-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 12px; }

/* ===== toast ===== */
.toast {
    position: fixed;
    z-index: 300;
    bottom: 24px; left: 50%;
    transform: translateX(-50%);
    background: var(--bg-2);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 10px 16px;
    border-radius: 999px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    animation: toastIn 0.25s ease-out;
    max-width: 80vw;
    text-align: center;
}
.toast.warn { border-color: var(--warning); color: var(--warning); }
.toast.err  { border-color: var(--danger);  color: #fecaca; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== responsive ===== */
@media (max-width: 900px) {
    .work-grid { grid-template-columns: 1fr; }
    .grid-wrap { max-height: 50vh; }
    .toolbar-group.toolbar-right { margin-left: 0; }
}

/* ===== foot ===== */
.foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    color: var(--text-mute);
    font-family: ui-monospace, monospace;
    font-size: 11px;
    letter-spacing: 0.04em;
}
.foot-note { display: inline-flex; align-items: center; gap: 6px; }
.bmc-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-mute); text-decoration: none; transition: color 0.15s; }
.bmc-link:hover { color: #FFDD00; }
