/* =========================================================
   EXPORT PANEL  (shared)
   assets/css/components/export-panel.css
   =========================================================
   Styles the shared Export tab UI (export-panel.js): the
   "Export Format" dropdown card + a theme-aware code card
   (header: filename / filename-dropdown + type badge + Copy /
   Download; body: line-numbered, syntax-highlighted code).

   Reuses the website design system tokens (variables.css) and is
   theme-aware via [data-theme] — no new theme. Used by every
   tool's Export tab and later by Studio / Hero.
   ========================================================= */

.export-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    /* Size container so the panel adapts to ITS width (covers the device-toggle
       "Mobile" mode, which narrows the panel without changing the viewport). */
    container-type: inline-size;
}


/* ── Format dropdown card ──────────────────────────────────── */

.export-format-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: fit-content;
    max-width: 100%;
    margin: var(--space-5) auto 0;   /* breathing room from the tabs; no outer border */
    padding: 0;
}

.export-format-label {
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    white-space: nowrap;
}

.export-format-select-wrap {
    position: relative;
    display: inline-flex;
    min-width: 200px;
}

.export-format-select {
    width: 100%;
    padding: 0.5rem 2.2rem 0.5rem 0.85rem;
    border: 1px solid var(--border-primary);
    border-radius: 0.6rem;
    background: var(--surface-secondary);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.export-format-select:hover { border-color: var(--color-primary); }
.export-format-select:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.export-format-chevron {
    position: absolute;
    top: 50%;
    right: 0.7rem;
    transform: translateY(-50%);
    display: inline-flex;
    color: var(--text-muted);
    pointer-events: none;
}

/* "Include component tokens" toggle — shown only for tools with component overrides. */
.export-components-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.export-components-toggle input {
    width: 15px;
    height: 15px;
    accent-color: var(--color-primary);
    cursor: pointer;
}


/* ── Code card ─────────────────────────────────────────────── */

.export-code-card {
    border: 1px solid var(--border-primary);
    border-radius: 0.85rem;
    overflow: hidden;
    background: var(--surface-primary);
    box-shadow: var(--shadow-sm);
}

.export-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border-primary);
}

/* Left — filename or filename dropdown */
.export-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;   /* let the filename / hint truncate rather than push the actions */
}

.export-file-icon {
    display: inline-flex;
    color: var(--text-muted);
    flex: 0 0 auto;
}

.export-filename {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: var(--text-sm);
    font-weight: var(--font-semi-bold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.export-filename-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.export-filename-select {
    width: 11rem;            /* compact — don't auto-size to the longest option */
    max-width: 100%;
    padding: 0.2rem 1.4rem 0.2rem 0.3rem;
    border: 1px solid transparent;
    border-radius: 0.4rem;
    background: transparent;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: var(--text-sm);
    font-weight: var(--font-semi-bold);
    color: var(--text-primary);
    text-overflow: ellipsis;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.export-filename-select:hover { background: var(--surface-hover); border-color: var(--border-primary); }
.export-filename-select:focus-visible { outline: none; border-color: var(--color-primary); }

.export-filename-chevron {
    position: absolute;
    right: 0.35rem;
    display: inline-flex;
    color: var(--text-muted);
    pointer-events: none;
}

/* Agent-rules filename: icon + dropdown on one line, muted note below. */
.export-file--stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.export-file-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    max-width: 100%;
}

.export-filename-hint {
    font-size: 0.68rem;
    font-style: italic;
    color: var(--text-muted);
    max-width: 100%;
    white-space: normal;     /* wrap — never clip the note (esp. on mobile) */
    line-height: 1.3;
}

/* Right — badge + actions */
.export-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
}

.export-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 0.7rem;
    font-weight: var(--font-semi-bold);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: transparent;
    font-family: var(--font-primary);
    font-size: var(--text-xs);
    font-weight: var(--font-semi-bold);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.export-btn:hover {
    background: var(--surface-hover);
    color: var(--color-primary);
}

.export-btn--done { color: var(--color-primary); }

.export-btn-icon { display: inline-flex; }


/* ── Code body — line numbers + highlighted code ───────────── */

.export-code-body {
    display: flex;
    /* Vertically: show all content (no max-height, no vertical scrollbar).
       Horizontally: scroll on every display; scrollbar hidden on tablet/desktop
       (still scrollable via trackpad/shift-wheel), shown on mobile (see @media). */
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--space-4) 0;
    background: var(--surface-primary);
    font-family: var(--font-mono, "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace);
    font-size: 0.8125rem;
    line-height: 1.7;
    scrollbar-width: none;            /* hidden by default (mobile/tablet); shown on desktop below */
}

.export-code-body::-webkit-scrollbar { display: none; }

/* Desktop: show the horizontal scrollbar. (Scrolling itself works on every size.) */
@media (min-width: 1024px) {
    .export-code-body { scrollbar-width: thin; scrollbar-color: var(--border-primary) transparent; }
    .export-code-body::-webkit-scrollbar { display: block; height: 10px; }
    .export-code-body::-webkit-scrollbar-thumb { background: var(--border-primary); border-radius: 5px; }
    .export-code-body::-webkit-scrollbar-track { background: transparent; }
}

.export-gutter {
    position: sticky;
    left: 0;
    z-index: 1;
    flex: 0 0 auto;
    padding: 0 0.9rem 0 1.1rem;
    text-align: right;
    color: var(--text-muted);
    background: var(--surface-primary);
    border-right: 1px solid var(--border-primary);
    user-select: none;
}

.export-gutter span {
    display: block;
    opacity: 0.7;
}

.export-viewer {
    /* Size to content (don't shrink) so long lines widen the scroll container
       and the body actually scrolls horizontally. */
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
    padding: 0 1.25rem;
    background: transparent;
    white-space: pre;
}

.export-code {
    color: var(--text-primary);
    tab-size: 2;
}


/* ── Syntax highlighting (theme-aware) ─────────────────────── */

.export-code .tok-comment  { color: #64748b; font-style: italic; }
.export-code .tok-heading  { color: #0f766e; font-weight: 700; }
.export-code .tok-prop     { color: #15803d; }
.export-code .tok-val      { color: #dc2626; }
.export-code .tok-selector { color: #7c3aed; }
.export-code .tok-key      { color: #2563eb; }
.export-code .tok-code {
    padding: 0.05em 0.25em;
    border-radius: 0.3rem;
    background: rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] .export-code .tok-comment  { color: #94a3b8; }
[data-theme="dark"] .export-code .tok-heading  { color: #2dd4bf; }
[data-theme="dark"] .export-code .tok-prop     { color: #4ade80; }
[data-theme="dark"] .export-code .tok-val      { color: #fca5a5; }
[data-theme="dark"] .export-code .tok-selector { color: #c4b5fd; }
[data-theme="dark"] .export-code .tok-key      { color: #93c5fd; }
[data-theme="dark"] .export-code .tok-code { background: rgba(255, 255, 255, 0.08); }


/* ── Mobile — icon-only action buttons, tighter layout ─────── */

@media (max-width: 640px) {
    .export-panel { padding: 0 var(--space-3); }   /* keep off the preview-area edges */
}

/* Container-based: narrow PANEL (real mobile OR device-toggle "Mobile" mode). */
@container (max-width: 560px) {
    .export-format-card { width: 100%; }
    .export-format-select-wrap { flex: 1 1 auto; min-width: 0; }

    .export-btn-label { display: none; }     /* icon-only */
    .export-btn { padding: 0.45rem; }
}
