/* ===========================================================================
   Workspace dashboard — "Workbench" layout
   Loaded after app.css on every non-editor page, scoped to .workspace so it
   cannot reach the Bin, Drive or Ideas pages.

   What it changes:
     1. the hero headline becomes a one-line greeting with live counts
     2. tabs (Recent / Shared / Starred / Templates) + a sort affordance
     3. one "pick up where you left off" card beside a compact setup card
     4. Recent files as a table, with a list/grid toggle
     5. the four starter cards become a quiet chip row at the bottom
   Colour, type and radii come from the tokens already in app.css.
   ========================================================================= */

.workspace {
    --ws-line: var(--line, #e8e5ed);
    --ws-ink: var(--ink, #24212a);
    --ws-muted: var(--muted, #726e7b);
    --ws-primary: var(--primary, #6750e8);
    --ws-surface: #fff;
    --ws-radius: 12px;
}

/* --- 1. action row instead of a hero ------------------------------------ */

.workspace .ws-actionbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 18px;
}

.workspace .ws-greeting { display: grid; gap: 3px; margin-right: auto; min-width: 0; }
.workspace .ws-greeting b {
    font-family: var(--brand-heading, Manrope), system-ui, sans-serif;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -.02em;
}
.workspace .ws-greeting small { font-size: 12.5px; color: var(--ws-muted); }

.workspace .ws-search {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 240px;
    max-width: 320px;
    flex: 1 1 260px;
    padding: 0 13px;
    height: 40px;
    border: 1px solid var(--ws-line);
    border-radius: 10px;
    background: var(--ws-surface);
    color: #9a95a6;
}
.workspace .ws-search .ui-icon { width: 16px; height: 16px; flex: 0 0 16px; }
.workspace .ws-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font-size: 13px;
    color: var(--ws-ink);
}
.workspace .ws-search input::placeholder { color: #9a95a6; }
.workspace .ws-search input:focus { outline: none; }
.workspace .ws-search:focus-within { border-color: var(--ws-primary); }

.workspace .ws-autoux,
.workspace .ws-create {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 40px;
    padding: 0 17px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.workspace .ws-autoux {
    border: 1px solid var(--ws-line);
    background: var(--ws-surface);
    color: var(--ws-ink);
}
.workspace .ws-autoux span { color: var(--ws-primary); }
.workspace .ws-autoux:hover { border-color: #cbc2f3; color: var(--ws-primary); }

.workspace .ws-create {
    border: 0;
    background: #14121c;
    color: #fff;
    cursor: pointer;
}
.workspace .ws-create:hover { background: #221f2e; }
.workspace .ws-create i {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, .22);
}
.workspace .ws-create-caret { font-size: 11px; opacity: .85; }

/* --- 2. tabs ------------------------------------------------------------- */

.workspace .ws-tabs {
    display: flex;
    align-items: center;
    gap: 26px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--ws-line);
}
.workspace .ws-tabs button,
.workspace .ws-tabs a {
    padding: 0 0 11px;
    border: 0;
    background: transparent;
    border-bottom: 2px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ws-muted);
    cursor: pointer;
}
.workspace .ws-tabs button:hover,
.workspace .ws-tabs a:hover { color: var(--ws-ink); }
.workspace .ws-tabs button.active {
    color: var(--ws-ink);
    font-weight: 700;
    border-bottom-color: var(--ws-primary);
}
.workspace .ws-sort {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
    padding-bottom: 11px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ws-muted);
}
.workspace .ws-sort .ui-icon { width: 15px; height: 15px; }

/* --- 3. resume + setup --------------------------------------------------- */

.workspace .ws-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    margin-bottom: 26px;
}

.workspace .ws-resume {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--ws-line);
    border-radius: var(--ws-radius);
    background: var(--ws-surface);
}
.workspace .ws-resume-thumb {
    display: block;
    width: 138px;
    height: 88px;
    flex: 0 0 138px;
    border: 1px solid #eeecf4;
    border-radius: 9px;
    background: #f5f4fa;
    overflow: hidden;
}
.workspace .ws-resume-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.workspace .ws-resume-thumb .preview-art {
    display: grid;
    grid-template-columns: 34% 1fr;
    grid-template-rows: 14px 1fr;
    gap: 6px;
    width: 100%;
    height: 100%;
    padding: 10px;
}
.workspace .ws-resume-thumb .preview-art i {
    display: block;
    border-radius: 4px;
    background: #e4e1f2;
}
.workspace .ws-resume-thumb .preview-art i:first-child { grid-column: 1 / 3; }

.workspace .ws-resume-copy { display: grid; gap: 4px; flex: 1; min-width: 0; }
.workspace .ws-resume-copy .eyebrow { margin: 0 0 2px; font-size: 10px; letter-spacing: .13em; }
.workspace .ws-resume-copy b {
    font-family: var(--brand-heading, Manrope), system-ui, sans-serif;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -.015em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workspace .ws-resume-copy small { font-size: 12px; color: var(--ws-muted); }

.workspace .ws-resume-open {
    padding: 11px 22px;
    border-radius: 10px;
    background: #14121c;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.workspace .ws-resume-open:hover { background: #221f2e; color: #fff; }

.workspace .ws-setup {
    display: grid;
    align-content: start;
    gap: 11px;
    padding: 15px;
    border: 1px solid var(--ws-line);
    border-radius: var(--ws-radius);
    background: var(--ws-surface);
}
.workspace .ws-setup-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.workspace .ws-setup-head b { font-size: 13.5px; font-weight: 700; }
.workspace .ws-setup-head span { font-size: 12px; font-weight: 700; color: var(--ws-primary); }
.workspace .ws-setup-bar { height: 5px; border-radius: 3px; background: #f0eef8; overflow: hidden; }
.workspace .ws-setup-bar i { display: block; height: 100%; border-radius: 3px; background: var(--ws-primary); }

.workspace .ws-setup-next {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-radius: 9px;
    background: #f7f6fc;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ws-ink);
}
.workspace .ws-setup-next:hover { background: #f0eefa; color: var(--ws-ink); }
.workspace .ws-setup-next b { flex: 1; font-weight: 600; }
.workspace .ws-setup-dot {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border: 2px solid var(--ws-primary);
    border-radius: 50%;
}
.workspace .ws-setup-next i { color: var(--ws-primary); font-style: normal; font-weight: 700; }

/* --- 4. files: one markup, two views ------------------------------------ */

.workspace .ws-files-heading { align-items: center; gap: 12px; }
.workspace .ws-files-heading span { margin-right: auto; }

.workspace .ws-view-toggle {
    display: flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--ws-line);
    border-radius: 9px;
    background: var(--ws-surface);
}
.workspace .ws-view-toggle button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 26px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ws-muted);
    cursor: pointer;
}
.workspace .ws-view-toggle button .ui-icon { width: 15px; height: 15px; }
.workspace .ws-view-toggle button:hover { background: #f4f2fa; }
.workspace .ws-view-toggle button.active { background: #14121c; color: #fff; }

/* Column header only exists in list view. Six columns: thumb, name, project,
   edited, size, actions. Every child is placed explicitly on row 1 — without
   that, display:contents children auto-place onto new rows and the row stacks. */
.workspace .ws-files[data-view="list"] {
    --ws-cols: 42px minmax(0, 2fr) minmax(0, 1.2fr) 110px 110px 44px;
}

.workspace .ws-file-head { display: none; }
.workspace .ws-files[data-view="list"] .ws-file-head {
    display: grid;
    grid-template-columns: var(--ws-cols);
    gap: 14px;
    align-items: center;
    padding: 11px 18px;
    border: 1px solid var(--ws-line);
    border-bottom: 0;
    border-radius: var(--ws-radius) var(--ws-radius) 0 0;
    background: var(--ws-surface);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .1em;
    color: #9a95a6;
}
.workspace .ws-files[data-view="list"] .ws-file-head span:first-child { grid-column: 2; }
.workspace .ws-files[data-view="list"] .ws-file-head span:nth-child(2) { grid-column: 3; }
.workspace .ws-files[data-view="list"] .ws-file-head span:nth-child(3) { grid-column: 4; }
.workspace .ws-files[data-view="list"] .ws-file-head span:nth-child(4) { grid-column: 5; }

/* LIST VIEW — the same .file-card markup, laid out as table rows. */
.workspace .ws-files[data-view="list"] .file-grid {
    display: block;
    border: 1px solid var(--ws-line);
    border-radius: 0 0 var(--ws-radius) var(--ws-radius);
    background: var(--ws-surface);
    overflow: hidden;
}
.workspace .ws-files[data-view="list"] .file-card {
    display: grid;
    grid-template-columns: var(--ws-cols);
    grid-template-rows: auto;
    gap: 14px;
    align-items: center;
    padding: 9px 18px;
    min-height: 58px;
    border: 0;
    border-top: 1px solid #f2f0f7;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    transform: none;
    position: relative;
}
.workspace .ws-files[data-view="list"] .file-card:first-child { border-top: 0; }
.workspace .ws-files[data-view="list"] .file-card:hover { background: #faf9fd; transform: none; box-shadow: none; }

.workspace .ws-files[data-view="list"] .file-card-link {
    grid-column: 1;
    grid-row: 1;
    display: block;
    width: 42px;
    height: 30px;
}
.workspace .ws-files[data-view="list"] .file-preview {
    width: 42px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid #eeecf4;
    background: #f4f3fa;
    overflow: hidden;
    aspect-ratio: auto;
}
.workspace .ws-files[data-view="list"] .file-preview img { width: 100%; height: 100%; object-fit: cover; }
.workspace .ws-files[data-view="list"] .file-preview .preview-art,
.workspace .ws-files[data-view="list"] .file-open,
.workspace .ws-files[data-view="list"] .favorite-mark { display: none; }

/* file-meta is flattened so its parts can take their own columns. */
.workspace .ws-files[data-view="list"] .file-meta,
.workspace .ws-files[data-view="list"] .file-meta > div,
.workspace .ws-files[data-view="list"] .file-meta small { display: contents; }

.workspace .ws-files[data-view="list"] .file-card-name {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    font-size: 13.5px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workspace .ws-files[data-view="list"] .file-project {
    grid-column: 3;
    grid-row: 1;
    font-size: 12.5px;
    color: var(--ws-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workspace .ws-files[data-view="list"] .file-meta time {
    grid-column: 4;
    grid-row: 1;
    font-size: 12.5px;
    color: var(--ws-muted);
}
.workspace .ws-files[data-view="list"] .file-size {
    grid-column: 5;
    grid-row: 1;
    font-size: 12.5px;
    color: var(--ws-muted);
}
.workspace .ws-files[data-view="list"] .file-sep { display: none; }

.workspace .ws-files[data-view="list"] .file-card-menu-button {
    grid-column: 6;
    grid-row: 1;
    position: static;
    justify-self: end;
    opacity: 1;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    color: #b7b2c4;
    background: transparent;
}
.workspace .ws-files[data-view="list"] .file-card-menu-button:hover { background: #f1eff8; color: var(--ws-ink); }

/* The whole row opens the file, not just the thumbnail. */
.workspace .ws-files[data-view="list"] .file-card-link:after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
}
.workspace .ws-files[data-view="list"] .file-card-menu-button { z-index: 1; }
.workspace .ws-files[data-view="list"] .file-card-name { position: relative; z-index: 1; }

/* GRID VIEW keeps the original card layout untouched. */
.workspace .ws-files[data-view="grid"] .ws-file-head { display: none; }

/* --- 5. starters as a chip row ------------------------------------------ */

.workspace .ws-newfrom {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 22px;
}
.workspace .ws-newfrom-label {
    margin-right: 4px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    color: #9a95a6;
}
.workspace .ws-newfrom button,
.workspace .ws-newfrom .ws-newfrom-all {
    padding: 9px 16px;
    border: 1px solid var(--ws-line);
    border-radius: 999px;
    background: var(--ws-surface);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ws-ink);
    cursor: pointer;
}
.workspace .ws-newfrom button:hover,
.workspace .ws-newfrom .ws-newfrom-all:hover { border-color: #cbc2f3; color: var(--ws-primary); }
.workspace .ws-newfrom .ws-newfrom-all { color: var(--ws-muted); }

/* --- filtered / empty states -------------------------------------------- */

.workspace .file-card[hidden] { display: none !important; }
.workspace .ws-no-match {
    padding: 34px 18px;
    border: 1px solid var(--ws-line);
    border-radius: var(--ws-radius);
    background: var(--ws-surface);
    text-align: center;
    font-size: 13px;
    color: var(--ws-muted);
}

/* --- narrow screens ------------------------------------------------------ */

@media (max-width: 1180px) {
    .workspace .ws-row { grid-template-columns: minmax(0, 1fr); }
    .workspace .ws-search { max-width: none; }
}

@media (max-width: 900px) {
    .workspace .ws-actionbar { flex-wrap: wrap; }
    .workspace .ws-greeting { flex: 1 0 100%; margin-right: 0; }
    .workspace .ws-files[data-view="list"] .ws-file-head,
    .workspace .ws-files[data-view="list"] .file-card { grid-template-columns: minmax(0, 1fr) 92px 44px; }
    .workspace .ws-files[data-view="list"] .file-project,
    .workspace .ws-files[data-view="list"] .ws-file-head span:nth-child(2),
    .workspace .ws-files[data-view="list"] .ws-file-head span:nth-child(4),
    .workspace .ws-files[data-view="list"] .file-size { display: none; }
    .workspace .ws-files[data-view="list"] .file-meta time,
    .workspace .ws-files[data-view="list"] .ws-file-head span:nth-child(3) { grid-column: 2; }
    .workspace .ws-files[data-view="list"] .file-card-menu-button,
    .workspace .ws-files[data-view="list"] .ws-file-head span:nth-child(5) { grid-column: 3; }
}

/* --- dark theme ---------------------------------------------------------- */

html[data-theme="dark"] .workspace {
    --ws-surface: #191722;
    --ws-line: #2e2b3a;
    --ws-ink: #ece9f4;
    --ws-muted: #9b95ab;
}
html[data-theme="dark"] .workspace .ws-create,
html[data-theme="dark"] .workspace .ws-resume-open { background: var(--ws-primary); }
html[data-theme="dark"] .workspace .ws-view-toggle button.active { background: var(--ws-primary); }
html[data-theme="dark"] .workspace .ws-setup-next { background: #221f2e; }
html[data-theme="dark"] .workspace .ws-files[data-view="list"] .file-card { border-top-color: #262232; }
html[data-theme="dark"] .workspace .ws-files[data-view="list"] .file-card:hover { background: #201d2b; }

/* ===========================================================================
   Legacy thumbnails: crop the black mat
   Thumbnails saved before the generator fix carry a 22px #11181b mat (5.5% of
   the image height). object-fit: cover crops the sides but keeps the top and
   bottom bands, which is the heavy black frame on every card.

   The stored images cannot be re-rendered server-side, so the preview zooms
   slightly and clips the mat away. New thumbnails only have an 8px margin, so
   this trims ~5% of their edges — invisible at thumbnail size, and it means old
   and new files look the same during the changeover.

   Once every file has been re-saved, this block can be deleted.
   ========================================================================= */

.workspace .file-preview img {
    transform: scale(1.16);
    transform-origin: center;
}
.workspace .ws-resume-thumb img {
    transform: scale(1.16);
    transform-origin: center;
}

/* ===========================================================================
   Grid view: four per row, medium cards
   The base grid was three columns with a 180px preview, and later rules made
   the preview taller still, so three tall cards filled the viewport. Four
   medium cards show the whole set without scrolling.
   ========================================================================= */

.workspace .ws-files[data-view="grid"] .file-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 16px !important;
}

.workspace .ws-files[data-view="grid"] .file-card { border-radius: 12px; }
.workspace .ws-files[data-view="grid"] .file-preview { height: 148px !important; }
.workspace .ws-files[data-view="grid"] .file-meta { padding: 11px 13px 13px !important; gap: 10px; }
.workspace .ws-files[data-view="grid"] .file-card-name { font-size: 13.5px; }
.workspace .ws-files[data-view="grid"] .file-meta small,
.workspace .ws-files[data-view="grid"] .file-meta time { font-size: 11px; }
.workspace .ws-files[data-view="grid"] .file-card-menu-button {
    width: 28px;
    height: 28px;
    right: 8px;
    top: 8px;
}
.workspace .ws-files[data-view="grid"] .favorite-mark {
    width: 24px;
    height: 24px;
    top: 8px;
    left: 8px;
    border-radius: 7px;
    font-size: 12px;
}

/* Step down rather than letting cards go narrower than they read at. */
@media (max-width: 1500px) {
    .workspace .ws-files[data-view="grid"] .file-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 1120px) {
    .workspace .ws-files[data-view="grid"] .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 720px) {
    .workspace .ws-files[data-view="grid"] .file-grid { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ===========================================================================
   Clean URLs toggle (Settings, platform administrators only)
   ========================================================================= */

/* Match the other single-section cards on this page: .settings-card itself has
   no padding, so each card supplies its own (27px 30px). Without it the badge
   sat outside the border and the content ran edge to edge. */
.settings-page .clean-url-card {
    padding: 27px 30px;
    gap: 18px;
    overflow: visible;
}

.settings-page .clean-url-card code {
    padding: 1px 5px;
    border-radius: 4px;
    background: #f1f0f8;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .92em;
}

.settings-page .clean-url-row {
    display: flex;
    background: var(--soft, #f7f5fb);
    align-items: center;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--line, #e8e5ed);
    border-radius: 12px;
}
.settings-page .clean-url-state { display: flex; align-items: center; gap: 13px; flex: 1; min-width: 0; }
.settings-page .clean-url-state div { display: grid; gap: 3px; }
.settings-page .clean-url-state b { font-size: 13.5px; font-weight: 700; }
.settings-page .clean-url-state small { font-size: 12px; color: var(--muted, #726e7b); }

.settings-page .clean-url-pill {
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
}
.settings-page .clean-url-pill.on { background: #e7f6ee; color: #1c7a52; }
.settings-page .clean-url-pill.off { background: #f1f0f4; color: #6f6a78; }

.settings-page .clean-url-note { margin: 0; font-size: 12px; line-height: 1.55; max-width: 74ch; }

html[data-theme="dark"] .settings-page .clean-url-card code { background: #262232; }
html[data-theme="dark"] .settings-page .clean-url-pill.off { background: #262232; color: #9b95ab; }

/* Clean URLs: environment checks and the manual escape hatch */
.settings-page .clean-url-checks {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
}
.settings-page .clean-url-checks li {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12.5px;
    color: var(--muted, #726e7b);
}
.settings-page .clean-url-checks li:before {
    content: "";
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: currentColor;
}
.settings-page .clean-url-checks li.yes { color: #1c7a52; }
.settings-page .clean-url-checks li.no { color: #b0384a; }
.settings-page .clean-url-checks li.maybe { color: #8a6d1f; }

.settings-page .clean-url-escape {
    display: grid;
    gap: 6px;
    justify-items: start;
    margin: 0;
    padding-top: 16px;
    border-top: 1px solid var(--line, #e8e5ed);
}
.settings-page .clean-url-escape small { font-size: 11.5px; color: var(--muted, #726e7b); line-height: 1.5; max-width: 74ch; }

.settings-page .clean-url-manual { margin: 0; }
.settings-page .clean-url-manual summary {
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--primary, #6750e8);
}
.settings-page .clean-url-manual p { font-size: 12px; color: var(--muted, #726e7b); margin: 9px 0 6px; }
.settings-page .clean-url-manual pre {
    margin: 0;
    padding: 12px;
    border-radius: 10px;
    background: #14121c;
    color: #e6e2f2;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    line-height: 1.55;
    overflow-x: auto;
    white-space: pre;
}
