/*
 * chat-attachments.css — paperclip, pending tray, dropzone overlay and the
 * chips that a sent turn's files leave behind. Shared by father_agent.html,
 * character_chat.html and character_public_chat.html.
 *
 * Every colour goes through a theme token WITH a fallback: the light theme
 * ([data-theme="light"]) redefines the tokens, and tests/test_css_tokens.py
 * refuses a no-fallback var().
 */

/* ── the paperclip ──────────────────────────────────────────────────────── */

.ca-attach-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 1px solid var(--border, #2a2a3a);
    border-radius: 10px;
    background: var(--bg-card, rgba(255, 255, 255, 0.04));
    color: var(--text-muted, #8a8a99);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s;
}

.ca-attach-btn:hover {
    color: var(--text-primary, #fff);
    border-color: var(--primary, #2563eb);
    background: var(--bg-card-hover, rgba(37, 99, 235, 0.12));
}

.ca-attach-btn:active { transform: scale(0.94); }

.ca-attach-btn:focus-visible {
    outline: 2px solid var(--primary, #2563eb);
    outline-offset: 2px;
}

/* The paperclip's input. It carries `hidden`, and this keeps it out of the
   layout even if that attribute is ever lost in an edit. */
.ca-file-input { display: none !important; }

/* ── the pending tray ───────────────────────────────────────────────────── */

.ca-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto 8px;
    padding: 0;
}

.ca-tray[hidden] { display: none; }

.ca-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
    max-width: 280px;
    padding: 6px 8px;
    border: 1px solid var(--border, #2a2a3a);
    border-radius: 10px;
    background: var(--bg-card, rgba(255, 255, 255, 0.04));
}

.ca-item[data-status="error"] {
    border-color: rgba(239, 68, 68, 0.55);
    background: rgba(239, 68, 68, 0.08);
}

.ca-item-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary, rgba(255, 255, 255, 0.06));
    font-size: 1.05rem;
    line-height: 1;
}

.ca-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ca-item-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.ca-item-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ca-item-sub {
    font-size: 0.7rem;
    color: var(--text-muted, #8a8a99);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ca-item[data-status="error"] .ca-item-sub { color: #ef4444; }

.ca-item-bar {
    height: 3px;
    border-radius: 2px;
    overflow: hidden;
    background: var(--bg-secondary, rgba(255, 255, 255, 0.1));
}

.ca-item-bar > i {
    display: block;
    height: 100%;
    background: var(--primary, #2563eb);
    transition: width 0.15s linear;
}

.ca-item-btn {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-muted, #8a8a99);
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
}

.ca-item-btn:hover {
    color: var(--text-primary, #fff);
    background: var(--bg-card-hover, rgba(255, 255, 255, 0.08));
}

/* ── the dropzone overlay ───────────────────────────────────────────────── */

.ca-drop-host { position: relative; }

.ca-dropzone {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 40;
    align-items: center;
    justify-content: center;
    padding: 16px;
    /* The pane stays faintly legible underneath — this is a hint, not a modal.
       The translucency lives in the BACKGROUND, not in an `opacity` on the
       whole layer: a group opacity fades the panel and its label too, and on
       the light theme that let the page heading read straight across "Drop
       files to attach". */
    background: var(--bg-primary, #0b0b12);
    background: color-mix(in srgb, var(--bg-primary, #0b0b12) 94%, transparent);
}

.ca-drop-host.ca-dragging .ca-dropzone { display: flex; }

.ca-dropzone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 40px;
    border: 2px dashed var(--primary, #2563eb);
    border-radius: 16px;
    /* An OPAQUE surface — a tint let the transcript underneath read through
       the label. ``--bg-card`` is translucent on the dark theme, so it is
       painted OVER an opaque ground rather than used alone. The accent halo is
       what gives the panel its edge against a near-white light theme. */
    background-color: var(--bg-primary, #0b0b12);
    background-image: linear-gradient(var(--bg-card, #14141f),
                                      var(--bg-card, #14141f));
    box-shadow: 0 0 0 7px var(--accent-glow, rgba(37, 99, 235, 0.18)),
                var(--shadow, 0 4px 24px rgba(0, 0, 0, 0.4));
    color: var(--text-primary, #fff);
    font-weight: 600;
    text-align: center;
}

.ca-dropzone-icon { font-size: 1.8rem; line-height: 1; }
.ca-dropzone-text { font-size: 0.95rem; }

/* ── chips on a sent turn ───────────────────────────────────────────────── */

.ca-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.ca-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 240px;
    padding: 6px 10px;
    border: 1px solid var(--border, #2a2a3a);
    border-radius: 10px;
    background: var(--bg-card, rgba(255, 255, 255, 0.04));
    color: var(--text-primary, #fff);
    text-decoration: none;
}

.ca-chip:hover { border-color: var(--primary, #2563eb); }

.ca-chip-icon { font-size: 1rem; line-height: 1; }

.ca-chip-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ca-chip-name {
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ca-chip-size {
    font-size: 0.68rem;
    color: var(--text-muted, #8a8a99);
}

.ca-chip-image {
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
}

/* A fixed tile, not the image's own size: a small image (an icon, a cropped
   screenshot) would otherwise render as a few unreadable pixels of chip. */
.ca-chip-img {
    display: block;
    width: 160px;
    height: 120px;
    object-fit: cover;
    background: var(--bg-secondary, rgba(255, 255, 255, 0.06));
}

@media (max-width: 640px) {
    .ca-item { min-width: 0; max-width: 100%; flex: 1 1 100%; }
    .ca-chip-img { width: 120px; height: 90px; }
}

@media (prefers-reduced-motion: reduce) {
    .ca-attach-btn,
    .ca-item-bar > i { transition: none; }
}
