/* ===== <x-file-info> — standard "file loaded" card =====
   Owns the visual shell. Data is filled progressively by tool-file-info.js.
   Works in dark (default) and light themes via CSS variables from app.css. */

.tool-file-info {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px 16px;
    align-items: center;
    padding: 14px 18px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 14px;
    position: relative;
    transition: border-color .18s, background .18s;
}
.tool-file-info[hidden] { display: none; }
.tool-file-info.tfi-drag-over { border-color: var(--accent); background: rgba(56,189,248,.06); }

.tfi-icons {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
    color: var(--accent);
}
.tfi-icons svg { width: 28px; height: 28px; opacity: .9; }
.tfi-icons:empty { display: none; }

.tfi-main {
    min-width: 0;   /* lets flex children truncate */
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tfi-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}

.tfi-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    line-height: 1.35;
}
.tfi-meta-primary .tfi-chip { color: var(--text-secondary); }
.tfi-meta-secondary .tfi-chip { color: var(--text-muted); font-size: 13px; }

.tfi-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: relative;
}
.tfi-chip[hidden] { display: none; }
.tfi-chip + .tfi-chip::before {
    content: '·';
    margin-inline-end: 8px;
    opacity: .5;
    color: var(--text-muted);
}
/* Separator belongs between two VISIBLE chips. When the immediate predecessor
   is [hidden] (duration/fps/codec not yet probed), the next visible chip would
   otherwise show a leading "· " — drop it. */
.tfi-chip[hidden] + .tfi-chip::before { content: none; }

.tfi-warn {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    color: var(--warning, #f59e0b);
    font-size: 13px;
}
/* display:flex above outranked the HTML hidden attribute — explicitly re-hide */
.tfi-warn[hidden] { display: none; }
.tfi-chip[hidden] { display: none; }

.tfi-remove {
    align-self: center;
    background: var(--glass-hover, rgba(0, 0, 0, .04));
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color .15s, background .15s, border-color .15s, transform .12s;
}
.tfi-remove:hover {
    color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, .1);
    border-color: rgba(239, 68, 68, .35);
    transform: rotate(90deg);
}
.tfi-remove:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.tfi-remove svg { width: 18px; height: 18px; stroke-width: 2.2; }

.tfi-drop-hint {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(56, 189, 248, .10);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border-radius: var(--radius-lg);
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    pointer-events: none;
    z-index: 2;
}
.tool-file-info.tfi-drag-over .tfi-drop-hint { display: flex; }

/* Narrow mobile — stack icon+text and push remove button to the top-right corner */
@media (max-width: 520px) {
    .tool-file-info {
        grid-template-columns: auto 1fr;
        gap: 10px 12px;
    }
    .tfi-remove {
        position: absolute;
        top: 6px;
        inset-inline-end: 6px;
    }
    .tfi-name { padding-inline-end: 36px; }
    .tfi-meta { font-size: 13px; }
    .tfi-meta-secondary { font-size: 12px; }
}

[data-theme=light] .tool-file-info { background: rgba(0,0,0,.02); }
[data-theme=light] .tool-file-info.tfi-drag-over { background: rgba(56,189,248,.08); }


/* ===== <x-tool-uploader> auto-rendered content (when tool doesn't pass a slot) =====
   Lives here rather than in a per-tool stylesheet so every upload zone looks the
   same regardless of which tool embeds the component. Tools that pass a slot
   keep their own CSS. */

.tool-uploader .tu-icons {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    color: var(--text-muted);
}
.tool-uploader .tu-icon {
    width: 36px;
    height: 36px;
    transition: color .2s;
}
.tool-uploader:hover .tu-icon,
.tool-uploader.dragover .tu-icon {
    color: var(--accent);
}

.tool-uploader .tu-title {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.35;
}

.tool-uploader .tu-formats {
    font-size: 13px;
    color: var(--text-muted);
    opacity: .75;
}

/* Inline rejection banner — visible inside the zone instead of a
   disconnected toast, so the error stays with the thing the user was
   just interacting with. */
.tool-uploader .tu-reject {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--danger, #ef4444) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger, #ef4444) 25%, transparent);
    border-radius: var(--radius-sm, 6px);
    color: var(--danger, #ef4444);
    font-size: 13px;
    line-height: 1.4;
    text-align: start;
}
.tool-uploader .tu-reject[hidden] { display: none; }
.tool-uploader .tu-reject-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* Shake animation — runs once on reject, reduced-motion users get no
   motion but still see the banner. */
@keyframes tu-shake {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-6px); }
    30%, 60%, 90% { transform: translateX(6px); }
}
.tool-uploader.tu-shaking { animation: tu-shake .4s ease-in-out; }
@media (prefers-reduced-motion: reduce) {
    .tool-uploader.tu-shaking { animation: none; }
}

.tool-uploader .tu-announce,
.tool-uploader .visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
