/* OS-2045 Wave-B: Files Explorer Polish
 * Adds: keyboard nav focus styles, hidden/symlink markers, sort indicators,
 *       Properties + Diff modals.
 * Scoped to body[data-theme-mode="os2045"] to keep Win3.11 untouched.
 */

/* ===== Symlink + hidden visual differentiation ============================ */
body[data-theme-mode="os2045"] #filesBrowser tr.fx-symlink-item td.icon::after,
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item.fx-symlink-item .icon::after {
    content: ' ↗';
    color: var(--a-cyan);
    font-size: 0.85em;
    margin-left: 2px;
}
body[data-theme-mode="os2045"] #filesBrowser tr.fx-symlink-item,
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item.fx-symlink-item {
    font-style: italic;
}
body[data-theme-mode="os2045"] #filesBrowser tr.fx-symlink-item .symlink,
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item.fx-symlink-item .name {
    color: var(--a-cyan);
}

body[data-theme-mode="os2045"] #filesBrowser tr.fx-hidden-item,
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item.fx-hidden-item {
    opacity: 0.55;
}

/* ===== Sort indicators on table headers =================================== */
body[data-theme-mode="os2045"] #filesBrowser .fx-th-sortable {
    user-select: none;
    position: relative;
}
body[data-theme-mode="os2045"] #filesBrowser .fx-th-sortable:hover {
    background: rgba(255,255,255,0.04);
}
body[data-theme-mode="os2045"] #filesBrowser .fx-th-sortable.fx-sort-asc::after {
    content: ' ▲';
    color: var(--theme-accent, #7c8cff);
    font-size: 0.7em;
    margin-left: 4px;
}
body[data-theme-mode="os2045"] #filesBrowser .fx-th-sortable.fx-sort-desc::after {
    content: ' ▼';
    color: var(--theme-accent, #7c8cff);
    font-size: 0.7em;
    margin-left: 4px;
}

/* ===== Hidden-files toggle button state ==================================== */
body[data-theme-mode="os2045"] #filesBrowser .fx-action.active,
body[data-theme-mode="os2045"] #filesBrowser #filesHiddenBtn.active {
    background: rgba(124,140,255,0.18);
    color: var(--theme-accent, #7c8cff);
    border-color: var(--theme-accent, #7c8cff);
}

/* ===== Modal overlay (Properties + Diff) ================================== */
.fx-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.62);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fxModalFade 0.18s ease-out;
}
@keyframes fxModalFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.fx-modal {
    background: #14171f;
    color: #eef2ff;
    min-width: 420px;
    max-width: 90vw;
    max-height: 85vh;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
}
.fx-modal-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.03);
}
.fx-modal-head b {
    flex: 1 1 auto;
    font-weight: 600;
    font-size: 14px;
}
.fx-modal-x {
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255,255,255,0.6);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.fx-modal-x:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.fx-modal-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 14px;
    font-size: 13px;
}
.fx-modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.02);
}
.fx-modal-btn {
    background: rgba(124,140,255,0.18);
    color: #eef2ff;
    border: 1px solid rgba(124,140,255,0.45);
    border-radius: 6px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 12px;
}
.fx-modal-btn:hover {
    background: rgba(124,140,255,0.32);
}

.fx-props-loading,
.fx-props-error,
.fx-diff-empty {
    padding: 20px;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    text-align: center;
}
.fx-props-error {
    color: var(--a-err);
}

/* ===== Properties table =================================================== */
.fx-props-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.fx-props-table th,
.fx-props-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-align: left;
    vertical-align: top;
}
.fx-props-table th {
    color: rgba(255,255,255,0.6);
    font-weight: 500;
    width: 35%;
    white-space: nowrap;
}
.fx-props-table td code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    word-break: break-all;
}
.fx-props-table .fx-broken {
    color: var(--a-err);
    font-weight: 600;
}

/* ===== Diff modal ========================================================= */
.fx-diff-modal {
    width: min(1100px, 96vw);
    max-width: 96vw;
    height: min(720px, 88vh);
    max-height: 88vh;
}
.fx-diff-stats {
    font-size: 12px;
    margin-right: 12px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.fx-diff-stats .add { color: var(--a-ok); margin-right: 6px; }
.fx-diff-stats .del { color: var(--a-err); }
.fx-diff-paths {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 11px;
}
.fx-diff-path {
    display: flex;
    gap: 8px;
    align-items: center;
    overflow: hidden;
}
.fx-diff-path span {
    background: rgba(124,140,255,0.22);
    color: var(--theme-accent, #7c8cff);
    border-radius: 3px;
    padding: 1px 6px;
    font-weight: 600;
}
.fx-diff-path code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    color: rgba(255,255,255,0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fx-diff-body {
    padding: 0;
}
.fx-diff-mode {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    margin-right: auto;
}
.fx-diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.5;
}
.fx-diff-table td {
    padding: 1px 6px;
    vertical-align: top;
    white-space: pre-wrap;
    word-break: break-all;
}
.fx-diff-table .lno,
.fx-diff-table .rno {
    width: 50px;
    text-align: right;
    color: rgba(255,255,255,0.35);
    user-select: none;
    background: rgba(255,255,255,0.02);
    border-right: 1px solid rgba(255,255,255,0.06);
}
.fx-diff-table .sign {
    width: 16px;
    text-align: center;
    user-select: none;
    color: rgba(255,255,255,0.5);
}
.fx-diff-table.sbs .lcell,
.fx-diff-table.sbs .rcell {
    width: 50%;
    border-left: 1px solid rgba(255,255,255,0.04);
}
.fx-diff-table .row-add,
.fx-diff-table .row-add .rcell {
    background: rgba(61,220,132,0.10);
}
.fx-diff-table .row-add .sign {
    color: var(--a-ok);
}
.fx-diff-table .row-del,
.fx-diff-table .row-del .lcell {
    background: rgba(255,122,138,0.10);
}
.fx-diff-table .row-del .sign {
    color: var(--a-err);
}
.fx-diff-table.sbs .row-mod .lcell {
    background: rgba(255,122,138,0.10);
}
.fx-diff-table.sbs .row-mod .rcell {
    background: rgba(61,220,132,0.10);
}
.fx-diff-table .row-info td {
    background: rgba(255,213,79,0.08);
    color: var(--a-warn);
    font-style: italic;
}

/* ===== Selection focus outline (a11y) ===================================== */
body[data-theme-mode="os2045"] #filesBrowser tr.selected,
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item.selected {
    outline: 1px solid var(--theme-accent, #7c8cff);
    outline-offset: -1px;
}

/* ===== Grid-item layout fix (v3 — extreme specificity) ==================== */
/* Kontextabhängig: Grid für icons-large/icons-small, Flex-Row für list/details.
   Wir hängen die View-Klasse an den Selektor an damit die List-View die
   inline-Styles aus filesRenderFiles nicht aushebelt. */
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-large"] #filesBrowser .fx-grid-item,
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-small"] #filesBrowser .fx-grid-item {
    display: grid !important;
    grid-template-rows: auto 1fr auto !important;
    grid-template-columns: 1fr !important;
    justify-items: center !important;
    align-items: start !important;
    row-gap: 6px !important;
    padding: 10px 6px !important;
    text-align: center !important;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-large"] #filesBrowser .fx-grid-item > .icon,
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-small"] #filesBrowser .fx-grid-item > .icon {
    grid-row: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 40px !important;
    line-height: 1 !important;
    font-size: 32px !important;
    color: var(--ink, #eef2ff) !important;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-small"] #filesBrowser .fx-grid-item > .icon {
    height: 28px !important;
    font-size: 22px !important;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-large"] #filesBrowser .fx-grid-item > .name,
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-small"] #filesBrowser .fx-grid-item > .name {
    grid-row: 2 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: break-word !important;
    line-height: 1.25 !important;
    font-size: 12px !important;
    width: 100% !important;
    text-align: center !important;
    color: var(--ink, #eef2ff) !important;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-large"] #filesBrowser .fx-grid-item > .meta,
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-small"] #filesBrowser .fx-grid-item > .meta {
    grid-row: 3 !important;
    font-size: 10px !important;
    color: var(--ink-3, rgba(255,255,255,0.55)) !important;
    width: 100% !important;
    text-align: center !important;
}
/* List-View: Icon | Name | Meta horizontal. Icon links 24px,
   Name nimmt rest, Meta rechts. KEIN width:100% auf .icon. */
body[data-theme-mode="os2045"] .os-window-body[data-files-view="list"] #filesBrowser .fx-grid-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    column-gap: 10px !important;
    padding: 4px 8px !important;
    text-align: left !important;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="list"] #filesBrowser .fx-grid-item > .icon {
    flex: 0 0 24px !important;
    width: 24px !important;
    height: 24px !important;
    font-size: 18px !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--ink, #eef2ff) !important;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="list"] #filesBrowser .fx-grid-item > .name {
    flex: 1 1 auto !important;
    color: var(--ink, #eef2ff) !important;
    font-size: 13px !important;
    text-align: left !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="list"] #filesBrowser .fx-grid-item > .meta {
    flex: 0 0 auto !important;
    color: var(--ink-3, rgba(255,255,255,0.55)) !important;
    font-size: 11px !important;
    text-align: right !important;
}

/* ===== Grid-item layout fix (v2 — old) ==================================== */
/* Frühere Versuche mit margin + min-height haben unter bestimmten
 * Window-Breiten + Emoji-Fonts Icons über den Filename geschoben. Wir lösen
 * das jetzt mit einem festen 3-Zeilen-Grid: ICON-Zeile (auto), NAME-Zeile
 * (1fr), META-Zeile (auto). So ist der Filename garantiert in seiner eigenen
 * Zeile drunter — keine Überlappung mehr möglich, egal wie breit das Emoji
 * tatsächlich rendert.
 * !important schlägt theme-os2045.css ~4480 (`flex` + `align-items: center`),
 * dessen Selektor-Specifity mit unserer ID-Auswahl gleichauf liegt aber zuerst
 * geladen wird und im Test trotzdem als Cascade-Sieger blieb.
 */
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item {
    display: grid !important;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr;
    justify-items: center;
    row-gap: 6px !important;
    padding: 10px 6px !important;
}
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item > .icon {
    grid-row: 1;
    display: flex !important;
    align-items: center; justify-content: center;
    width: 100%;
    height: 40px;
    line-height: 1;
    font-size: 32px !important;
    overflow: hidden;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="icons-small"] #filesBrowser .fx-grid-item > .icon {
    height: 28px;
    font-size: 22px !important;
}
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item > .name {
    grid-row: 2;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    line-height: 1.25;
    font-size: 12px;
    width: 100%;
    text-align: center;
    color: var(--ink, #eef2ff);
}
body[data-theme-mode="os2045"] #filesBrowser .fx-grid-item > .meta {
    grid-row: 3;
    font-size: 10px;
    color: var(--ink-3, rgba(255,255,255,0.55));
    width: 100%;
    text-align: center;
}
/* List-Ansicht: alle drei Zellen nebeneinander statt drei Grid-Zeilen. */
body[data-theme-mode="os2045"] .os-window-body[data-files-view="list"] #filesBrowser .fx-grid-item {
    display: flex !important;
    grid-template-rows: none;
    flex-direction: row;
    align-items: center;
    justify-items: stretch;
    column-gap: 10px;
    padding: 4px 8px !important;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="list"] #filesBrowser .fx-grid-item > .icon {
    width: 24px; height: 24px;
    font-size: 18px !important;
    flex: 0 0 auto;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="list"] #filesBrowser .fx-grid-item > .name {
    flex: 1;
    text-align: left;
    -webkit-line-clamp: 1;
    line-clamp: 1;
}
body[data-theme-mode="os2045"] .os-window-body[data-files-view="list"] #filesBrowser .fx-grid-item > .meta {
    flex: 0 0 auto;
    text-align: right;
}
