/* DIGFM suite UI kit — floating labels, tooltips, tag pills, modal,
   file dropzones, sortable tables, icon buttons.
   Behavior lives in /digfm/js/ui.js; both are included on every page. */

/* ── Floating "inline" labels (Facebook/Material filled style) ─────────── */
.float-group { position: relative; }
.float-group > label {
    position: absolute;
    left: 11px;
    top: 11px;
    margin: 0;
    color: #888;
    font-size: 1em;
    line-height: 1.2;
    pointer-events: none;
    transform-origin: left top;
    transition: transform 0.18s ease, color 0.18s ease, top 0.18s ease;
    z-index: 2;
    max-width: calc(100% - 48px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.float-group > input:not([type="checkbox"]),
.float-group > select,
.float-group > textarea {
    padding: 17px 30px 5px 10px !important;
    height: auto;
}
.float-group.has-value > label,
.float-group.always-float > label,
.float-group:focus-within > label {
    top: 4px;
    transform: scale(0.72);
    color: #7ec97e;
}
.float-group input::placeholder { opacity: 0; transition: opacity 0.18s; }
.float-group:focus-within input::placeholder { opacity: 0.45; }
/* keep select text from hiding under the un-floated label */
.float-group > select { color: transparent; }
.float-group.has-value > select,
.float-group.always-float > select,
.float-group:focus-within > select { color: inherit; }

/* ── Field help: (?) bubble + floating tooltip ─────────────────────────── */
.field-help {
    position: absolute;
    right: 9px;
    top: 10px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #333;
    border: 1px solid #4a4a4a;
    color: #aaa;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    z-index: 3;
    user-select: none;
}
select ~ .field-help { right: 30px; } /* clear the native select arrow */
.field-help::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    right: -8px;
    background: #0d0d0d;
    border: 1px solid #444;
    color: #ddd;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    padding: 8px 11px;
    border-radius: 7px;
    width: max-content;
    max-width: 250px;
    white-space: normal;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    z-index: 60;
    pointer-events: none;
}
.field-help::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    right: 0;
    border: 5px solid transparent;
    border-top-color: #444;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    z-index: 60;
}
.field-help:hover::after, .field-help:hover::before { opacity: 1; visibility: visible; }

/* ── Tag capsules ──────────────────────────────────────────────────────── */
.tag-pill {
    display: inline-block;
    padding: 2px 10px;
    margin: 2px 4px 2px 0;
    border-radius: 999px;
    background: rgba(126, 201, 126, 0.12);
    border: 1px solid rgba(126, 201, 126, 0.35);
    color: #9fd89f;
    font-size: 0.8em;
    white-space: nowrap;
}

/* ── File dropzones (dotted drag-and-drop for plain file inputs) ───────── */
.file-drop {
    border: 2px dashed rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    padding: 14px 12px;
    text-align: center;
    color: #999;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    background: rgba(255, 255, 255, 0.02);
}
.file-drop:hover, .file-drop.drag-over {
    border-color: #7ec97e;
    background: rgba(126, 201, 126, 0.06);
    color: #ccc;
}
.file-drop .fd-icon { font-size: 1.5em; display: block; margin-bottom: 6px; }
.file-drop .fd-file { color: #9fd89f; font-weight: 500; }
.file-drop input[type="file"] { display: none; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}
.modal {
    background: #181818;
    border: 1px solid #333;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    width: 100%;
    max-width: 860px;
    padding: 18px 20px;
    position: relative;
}
.modal h2 { margin-top: 0; }
.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
}
.modal-close:hover { color: #fff; }

/* ── Sortable tables ───────────────────────────────────────────────────── */
table[data-sort-table] th[data-sortable] { cursor: pointer; user-select: none; }
table[data-sort-table] th[data-sortable]:hover { color: #ccc; }
table[data-sort-table] th[data-sortable]::after {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    content: '\f0dc'; /* fa-sort */
    margin-left: 6px;
    opacity: 0.35;
    font-size: 0.9em;
}
table[data-sort-table] th[data-sortable][data-dir="asc"]::after { content: '\f0de'; opacity: 1; color: #7ec97e; }  /* fa-sort-up */
table[data-sort-table] th[data-sortable][data-dir="desc"]::after { content: '\f0dd'; opacity: 1; color: #7ec97e; } /* fa-sort-down */

/* ── Icon action buttons ───────────────────────────────────────────────── */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: #bbb;
    text-decoration: none !important;
    font-size: 13px;
    cursor: pointer;
    margin-right: 4px;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
    vertical-align: middle;
}
.icon-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.icon-btn.danger:hover { color: #ff8a8a; border-color: rgba(224, 82, 82, 0.5); background: rgba(224, 82, 82, 0.12); }
.icon-btn.dl { color: #9fd89f; }
.icon-btn.dl:hover { border-color: rgba(126, 201, 126, 0.5); background: rgba(126, 201, 126, 0.1); }

/* ── Show list extras ──────────────────────────────────────────────────── */
.show-thumb {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.show-thumb-empty { color: #555; font-size: 15px; }
.show-name { color: #eee; font-weight: 500; }
.show-host { color: #888; font-size: 0.8em; margin-top: 1px; }

.filter-group {
    display: inline-flex;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    overflow: hidden;
}
.filter-btn {
    background: none;
    border: none;
    color: #999;
    padding: 5px 11px;
    cursor: pointer;
    font: inherit;
    font-size: 0.85em;
    transition: color 0.15s, background-color 0.15s;
}
.filter-btn + .filter-btn { border-left: 1px solid rgba(255, 255, 255, 0.15); }
.filter-btn:hover { color: #fff; }
.filter-btn.active { background: rgba(126, 201, 126, 0.15); color: #9fd89f; }

/* ── Step headings (processor flow) ───────────────────────────────────── */
.step-head {
    display: flex;
    align-items: center;
    gap: 12px;
}
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(126, 201, 126, 0.15);
    border: 1px solid rgba(126, 201, 126, 0.45);
    color: #9fd89f;
    font-size: 0.75em;
    font-weight: 600;
    flex: none;
}

/* ── Tooltip bubble for [data-tooltip] (built by ui.js, appended to body) ── */
.ui-tooltip {
    position: fixed;
    z-index: 9999;
    display: none;
    background: #0d0d0d;
    border: 1px solid #555;
    color: #eee;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    padding: 6px 10px;
    border-radius: 7px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    white-space: nowrap;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.08s ease;
}
.ui-tooltip.show { opacity: 1; }
[data-tooltip] { cursor: default; }
a[data-tooltip], button[data-tooltip] { cursor: pointer; }

/* ── Compact data tables (episode history etc.) ───────────────────────── */
.nowrap { white-space: nowrap; }
.col-icon { text-align: center; }
.admin-table .cell-title { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-table .icon-btn { margin: 0 2px; }
.status-icon { font-size: 15px; color: #888; display: inline-block; }
.status-icon.status-ready  { color: #4caf50; }
.status-icon.status-sent   { color: #4ea3ff; }
.status-icon.status-failed { color: #e05252; }
.status-icon.status-queued { color: #999; }
.status-icon.status-analyzing, .status-icon.status-encoding { color: #e0a11a; }

/* ── Switch toggles ────────────────────────────────────────────────────── */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 0.9em; color: #bbb; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none; }
.switch-track { position: relative; flex: none; width: 34px; height: 18px; border-radius: 999px; background: #3f3f3f; transition: background 0.18s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #8d8d8d; transition: transform 0.18s, background 0.18s; }
.switch input:checked + .switch-track { background: #1a6fd4; }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 2px rgba(47, 127, 224, 0.5); }
.switch input:disabled + .switch-track { opacity: 0.4; }
.switch input:disabled ~ .switch-text { opacity: 0.5; }
.switch:hover .switch-track { background: #4a4a4a; }
.switch:hover input:checked + .switch-track { background: #2f7fe0; }
.toggle-row { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 12px; }

/* ── Submit form footer ────────────────────────────────────────────────── */
.form-actions-inline { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.form-actions-inline .btn-primary { margin: 0; display: inline-flex; }
.sm-progress { color: #aaa; font-size: 0.9em; }
.sm-progress.error { color: #ff8a8a; }

/* ── Episode history: review + publish cells ───────────────────────────── */
.review-icon { font-size: 15px; display: inline-block; margin-right: 4px; }
.review-icon.review-pending  { color: #999; }
.review-icon.review-approved { color: #4caf50; }
.review-icon.review-returned { color: #e0a11a; }
button.icon-btn { padding: 0; font-family: inherit; }
.icon-btn.ok { color: #9fd89f; }
.icon-btn.ok:hover { border-color: rgba(126, 201, 126, 0.5); background: rgba(126, 201, 126, 0.1); }
.icon-btn.done { color: #4caf50; border-color: rgba(76, 175, 80, 0.4); cursor: default; }
.icon-btn.done:hover { background: rgba(255, 255, 255, 0.04); }
.icon-btn.warn { color: #ff8a8a; border-color: rgba(224, 82, 82, 0.5); }
.icon-btn.busy { color: #e0a11a; cursor: default; }
.icon-btn[aria-disabled="true"] { opacity: 0.3; cursor: not-allowed; }
.icon-btn[aria-disabled="true"]:hover { background: rgba(255, 255, 255, 0.04); color: #bbb; }
.admin-table tr.row-selected td { background: rgba(78, 163, 255, 0.08); }
.inline-form { display: inline; }
.modal-ep { color: #9fd89f; font-family: monospace; font-size: 0.9em; word-break: break-all; margin: 0 0 12px; }
.modal textarea { width: 100%; min-height: 90px; padding: 8px 10px; border: 1px solid #444; border-radius: 6px; background: #2a2a2a; color: #e0e0e0; font: inherit; font-size: 14px; resize: vertical; }
.modal p.muted { color: #888; font-size: 0.9em; margin: 0 0 8px; }
