/* ==========================================================================
   Content Pages — Templates, Files, Data Slots
   DS-106 tokens only; no hardcoded hex/rgb values.
   ========================================================================== */

/* ── Editorial Page Header ──────────────────────────────────────────────── */

.av-ph {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
}

.av-ph-body {
    flex: 1;
    min-width: 0;
}

.av-ph-eyebrow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

/* Editorial section numbering (01, 02, …) is visual flair, not a navigation
   aid — hide it across all workspace pages without touching templates. */
.av-ph-eyebrow .av-num {
    display: none;
}

/* Workspace H1: keep the editorial typeface but at workspace-appropriate
   size so the first row of actual content stays above the fold. */
.av-ph .display-1,
.av-ph .display-2 {
    font-size: clamp(28px, 2.6vw, 40px);
    line-height: 1.1;
    margin-top: 4px;
}

.av-ph .lede {
    margin-top: 6px;
    font-size: 15px;
    line-height: 1.45;
}

.av-ph-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

/* ── Panel wrapper (hairline + r-lg + soft shadow) ──────────────────────── */

.av-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: 0 1px 3px oklch(0.18 0.012 255 / 0.05);
    overflow: hidden;
}

.av-panel + .av-panel {
    margin-top: var(--space-lg);
}

/* ── Tab navigation — underline-on-active ───────────────────────────────── */

.av-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: var(--space-xl);
    overflow-x: auto;
    scrollbar-width: none;
}

.av-tab-bar::-webkit-scrollbar { display: none; }

.av-tab-btn {
    padding: 12px 18px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 1.5px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
    font-family: var(--font-text);
}

.av-tab-btn:hover { color: var(--ink); }

.av-tab-btn[aria-selected="true"],
.av-tab-btn.is-active {
    color: var(--ink);
    border-bottom-color: var(--ink);
}

/* ── ls-table — editorial table with per-column filter row ─────────────── */

.ls-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.ls-table th {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    background: var(--bg-warm);
    white-space: nowrap;
}

.ls-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
    color: var(--ink-2);
}

.ls-table tbody tr:last-child td {
    border-bottom: 0;
}

.ls-table tbody tr:hover td {
    background: var(--bg-warm);
}

/* Per-column filter row */
.ls-table tr.filter-row-th th {
    padding: 6px 8px;
    background: oklch(0.975 0.004 85);
    border-top: 1px solid var(--line-2);
    border-bottom: 1px solid var(--line);
}

.th-filter-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.th-filter-wrap svg {
    position: absolute;
    left: 8px;
    color: var(--muted);
    pointer-events: none;
    flex-shrink: 0;
}

.th-filter {
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    color: var(--ink);
    font-family: var(--font-text);
    font-size: 12px;
    padding: 5px 8px 5px 26px;
    outline: none;
    transition: border-color var(--dur-fast);
}

select.th-filter {
    padding-left: 8px;
    appearance: auto;
}

.th-filter:focus {
    border-color: var(--accent);
}

.th-filter::placeholder { color: var(--muted); }

/* name-cell and meta-cell helpers */
.name-cell {
    font-weight: 500;
    color: var(--ink);
    font-size: 13.5px;
}

.meta-cell {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}

/* key-id mono prefix pill */
.key-id {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-warm);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 3px 7px;
    color: var(--ink-2);
}

/* ── Beautiful empty state ───────────────────────────────────────────────── */

.av-empty-premium {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-4xl) var(--space-lg);
    text-align: center;
}

.av-empty-premium-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    background: var(--bg-warm);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    color: var(--muted);
    margin-bottom: var(--space-lg);
    font-size: 28px;
}

.av-empty-premium-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin: 0 0 var(--space-sm);
}

.av-empty-premium-desc {
    font-size: 14px;
    color: var(--muted);
    max-width: 44ch;
    line-height: 1.6;
    margin-bottom: var(--space-lg);
}

/* ── Drop zone — polished hairline dashed ───────────────────────────────── */

.av-drop-zone-premium {
    border: 1.5px dashed var(--line);
    border-radius: var(--r-lg);
    background: var(--bg-warm);
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    cursor: pointer;
    transition:
        border-color var(--dur-fast) var(--ease),
        background var(--dur-fast) var(--ease);
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.av-drop-zone-premium:hover,
.av-drop-zone-premium:focus-visible,
.av-drop-zone-premium.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    outline: none;
}

.av-drop-zone-premium:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.av-drop-zone-premium-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--muted);
    transition: color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
    margin-bottom: var(--space-xs);
}

.av-drop-zone-premium:hover .av-drop-zone-premium-icon,
.av-drop-zone-premium.is-active .av-drop-zone-premium-icon {
    color: var(--accent);
    border-color: oklch(0.48 0.14 265 / 0.35);
}

.av-drop-zone-premium-label {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.av-drop-zone-premium-hint {
    font-size: 12px;
    color: var(--muted);
}

/* ── File card — editorial with bezel + mono filename ───────────────────── */

.av-file-card {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    align-items: center;
    gap: var(--space-md);
    padding: 14px var(--space-md);
    border-bottom: 1px solid var(--line-2);
    transition: background var(--dur-fast) var(--ease);
}

.av-file-card:last-child {
    border-bottom: 0;
}

.av-file-card:hover {
    background: var(--bg-warm);
}

.av-file-card-bezel {
    width: 48px;
    height: 48px;
    border-radius: var(--r-md);
    background: var(--bg-warm);
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
}

.av-file-card-bezel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.av-file-card-name {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 32ch;
}

.av-file-card-sub {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.av-file-card-actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* ── Template card — editorial premium ───────────────────────────────────── */

.av-template-card-premium {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease);
}

.av-template-card-premium:hover {
    border-color: var(--ink-2);
    box-shadow: 0 4px 16px oklch(0.18 0.012 255 / 0.08);
    transform: translateY(-1px);
}

.av-template-preview-bezel {
    aspect-ratio: 16/9;
    background: var(--bg-warm);
    border-bottom: 1px solid var(--line);
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
}

.av-template-preview-bezel iframe {
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
}

.av-template-preview-bezel .av-template-preview-fallback {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.av-template-card-body {
    padding: 16px;
    flex: 1;
}

.av-template-card-title-premium {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.012em;
    color: var(--ink);
    margin: 0 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.av-template-card-source-premium {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    margin: 0 0 var(--space-sm);
}

.av-template-card-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--line-2);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
    row-gap: 6px;
}

.av-template-card-footer .av-btn--send {
    margin-left: auto;
}

/* ── Template share modal ──────────────────────────────────────────
   Originally lived in admin.css; the share-modal opens from the
   dashboard (/templates) so the styles needed to follow the modal. */
.av-template-share-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.av-template-share-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--panel-2, var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    font-size: var(--font-sm);
    color: var(--ink);
}

.av-template-share-add {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    margin-top: var(--space-xs);
}

.av-template-share-add .av-select {
    min-height: 38px;
}

@media (prefers-reduced-motion: reduce) {
    .av-template-card-premium,
    .av-drop-zone-premium,
    .av-drop-zone-premium-icon {
        transition: none;
    }
}

/* ── Empty States ─────────────────────────────────────────────────────────── */

.av-content-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl) var(--space-lg);
    text-align: center;
    min-height: 240px;
}

.av-content-empty-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
    color: var(--text-muted);
    line-height: 1;
}

.av-content-empty-title {
    font-size: var(--font-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.av-content-empty-desc {
    font-size: var(--font-sm);
    color: var(--text-muted);
    max-width: 380px;
    line-height: var(--line-height-relaxed);
    margin-bottom: var(--space-lg);
}

/* ── Templates Grid ───────────────────────────────────────────────────────── */

.av-templates-page {
    container-type: inline-size;
}

.av-content-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
}

/* Tags row inside a template card */
.av-template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}

.av-template-tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-xs);
    font-size: var(--font-2xs);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    white-space: nowrap;
}

/* Last-updated line */
.av-template-card-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* Inline send button positioning in footer */
.av-card-footer {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--border-light);
}

.av-card-footer .av-btn--send {
    margin-left: auto;
}

/* ── Files Drop Zone ──────────────────────────────────────────────────────── */

/* Primary state: drop zone is the dominant element when no files exist */
.av-drop-zone--primary {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    cursor: pointer;
    transition:
        border-color var(--motion-fast, 150ms) ease,
        background var(--motion-fast, 150ms) ease;
    /* Minimum tap target height covers DS-106 44 px touch-target contract. */
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.av-drop-zone--primary:hover,
.av-drop-zone--primary:focus-visible,
.av-drop-zone--primary.is-active {
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
    outline: none;
}

.av-drop-zone--primary:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.av-drop-zone-icon {
    color: var(--text-muted);
    transition: color var(--motion-fast, 150ms) ease;
}

.av-drop-zone--primary:hover .av-drop-zone-icon,
.av-drop-zone--primary.is-active .av-drop-zone-icon {
    color: var(--accent-primary);
}

.av-drop-zone-label {
    font-size: var(--font-base);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

.av-drop-zone-hint {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* Mobile: drop zone becomes a full-width tappable button */
@media (max-width: 767px) {
    .av-drop-zone--primary {
        min-height: 80px;
        padding: var(--space-lg);
        border-radius: var(--radius-md);
    }
}

/* ── File Filter Chips ────────────────────────────────────────────────────── */

.av-content-filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.av-content-filter-chips {
    display: flex;
    gap: var(--space-xs);
}

.av-content-search {
    flex: 1;
    min-width: 180px;
    max-width: 360px;
}

/* ── File List ────────────────────────────────────────────────────────────── */

/* Usage badge — hidden by default; visible when usedByCount > 0 */
.av-file-used-badge {
    display: none;
    font-size: var(--font-xs);
    padding: 2px var(--space-xs);
    border-radius: var(--radius-full);
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    white-space: nowrap;
}

.av-file-used-badge[data-count]:not([data-count="0"]) {
    display: inline-flex;
}

.av-files-empty-row td {
    color: var(--muted);
    padding: var(--space-xl) var(--space-md);
    text-align: center;
}

.av-files-empty-title {
    color: var(--ink);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

/* Card layout for mobile (below 768 px) — mirrors DS-106 §7 contract */
@media (max-width: 767px) {
    .av-content-card-grid {
        grid-template-columns: 1fr;
    }

    /* Table rows collapse to cards using existing mobile-overrides.css pattern */
    .av-table tbody tr {
        display: flex;
        flex-direction: column;
        padding: var(--space-sm);
        border-bottom: 1px solid var(--border-light);
    }

    .av-table tbody tr td::before {
        content: attr(data-label);
        font-weight: var(--font-weight-medium);
        color: var(--text-muted);
        font-size: var(--font-xs);
        display: block;
        margin-bottom: 2px;
    }
}

/* ── Data Slot List ───────────────────────────────────────────────────────── */

.av-slot-list-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.av-slot-list-name {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.av-slot-list-slug {
    font-family: var(--font-mono);
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.av-slot-list-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    white-space: nowrap;
}

