/* ecomtorials Advertorial Engine — Board UI */
:root {
    --bg: #0f0f13;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --glass: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text: #e4e4e7;
    --text-muted: #71717a;
    --accent: #818cf8;
    --accent-glow: rgba(129, 140, 248, 0.3);
    --green: #4ade80;
    --red: #f87171;
    --yellow: #fbbf24;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
}

h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.1rem; font-weight: 500; margin-bottom: 16px; color: var(--text-muted); }
.accent { color: var(--accent); }

.status-bar { display: flex; gap: 8px; }

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--glass);
    border: 1px solid var(--glass-border);
}
.badge.secondary { color: var(--text-muted); }
.badge.running { background: var(--accent-glow); color: var(--accent); }
.badge.completed { background: rgba(74, 222, 128, 0.15); color: var(--green); }
.badge.error { background: rgba(248, 113, 113, 0.15); color: var(--red); }

/* Panels */
.panel {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(12px);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Live Status */
.live-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 10px 16px;
    background: var(--surface);
    border-radius: 8px;
    font-size: 0.9rem;
}

.status-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-icon.spinning {
    background: transparent;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

.status-icon.done { background: var(--green); }
.status-icon.error { background: var(--red); }

@keyframes spin { to { transform: rotate(360deg); } }

/* Progress Bar */
.progress-bar-container {
    height: 4px;
    background: var(--surface);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 2px;
    width: 0%;
    transition: width 0.5s ease;
}

/* Activity Log */
.activity-log {
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 8px;
    background: var(--surface);
    border-radius: 8px;
}

.activity-log .log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.activity-log .log-entry .log-time { color: var(--text-muted); margin-right: 8px; }
.activity-log .log-entry .log-node { color: var(--accent); font-weight: 500; }

/* Pipeline */
.pipeline {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0;
}

.pipe-node {
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.3s;
    cursor: default;
    position: relative;
}

.pipe-node[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2e;
    color: var(--text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 400;
    white-space: normal;
    width: max-content;
    max-width: 220px;
    z-index: 10;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.pipe-node.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    animation: pulse-node 1.5s ease-in-out infinite;
}

@keyframes pulse-node {
    0%, 100% { box-shadow: 0 0 10px var(--accent-glow); }
    50% { box-shadow: 0 0 25px var(--accent-glow); }
}

.pipe-node.done {
    background: rgba(74, 222, 128, 0.1);
    border-color: var(--green);
    color: var(--green);
}

.pipe-node.failed {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--red);
    color: var(--red);
}

.pipe-node.team {
    border-style: dashed;
    border-width: 2px;
}

.pipe-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pipe-arrow { color: var(--text-muted); font-size: 1.2rem; }

/* Score Table */
#score-table {
    margin-top: 16px;
    font-size: 0.85rem;
}

#score-table table {
    width: 100%;
    border-collapse: collapse;
}

#score-table th, #score-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

#score-table th { color: var(--text-muted); font-weight: 500; }

.score-pass { color: var(--green); }
.score-fail { color: var(--red); }
.score-warn { color: var(--yellow); }

/* Draft Compare */
.draft-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.draft-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.draft-col select {
    width: 100%;
}

.draft-col textarea {
    font-family: var(--mono);
    font-size: 0.78rem;
    height: 420px;
    resize: vertical;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.5;
    overflow-y: auto;
}

/* Outline Panel */
.outline-text {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 16px;
    white-space: pre-wrap;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

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

.controls select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
}

/* Cost Panel */
.cost-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--surface);
    border-radius: 6px;
    color: var(--text-muted);
}

.cost-row span:last-child {
    font-family: var(--mono);
    color: var(--text);
}

.cost-total {
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-weight: 600;
}

.cost-total span:last-child {
    color: var(--accent);
}

.cost-tokens {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* Forms */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-style: italic;
}

textarea, input[type="number"] {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px;
    font-family: var(--mono);
    font-size: 0.85rem;
    resize: vertical;
}

textarea:focus, input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Buttons */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-approve {
    background: var(--green);
    color: #000;
}

.btn-reject {
    background: var(--red);
    color: #fff;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

.draft-preview {
    max-height: 300px;
    overflow-y: auto;
    padding: 16px;
    background: var(--surface);
    border-radius: 8px;
    font-size: 0.85rem;
    margin: 16px 0;
    white-space: pre-wrap;
}

/* Final Output */
.advertorial-output {
    padding: 20px;
    background: var(--surface);
    border-radius: 8px;
    font-size: 0.9rem;
    white-space: pre-wrap;
    max-height: 600px;
    overflow-y: auto;
}

#headlines {
    margin-bottom: 16px;
}

#headlines h3 {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 8px;
}

#headlines li {
    padding: 4px 0;
    font-size: 0.85rem;
    list-style: decimal inside;
}

/* Form steps */
.form-step {
    margin: 16px 0;
    padding: 16px;
    background: var(--surface);
    border-radius: 8px;
    border-left: 3px solid var(--accent, #6366f1);
}
.form-step .step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.form-step .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent, #6366f1);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
}
.form-step h3 {
    margin: 0;
    font-size: 1.05rem;
}
.form-step textarea,
#start-panel textarea {
    width: 100%;
    min-height: 120px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 12px;
    color: inherit;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}
.form-step input[type="number"] {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 6px 10px;
    color: inherit;
}
.form-step label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.8;
    margin-bottom: 4px;
}
.form-step input[type="file"] {
    color: inherit;
    font-size: 0.85rem;
}
.file-status {
    display: none;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
}
.file-status.file-ok {
    color: var(--green);
    background: rgba(74, 222, 128, 0.08);
}
.file-status.file-err {
    color: var(--red);
    background: rgba(248, 113, 113, 0.08);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    transition: 0.3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-glow);
    border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: var(--accent);
}

/* Auto-mode disabled inspiration */
#manual-inspiration.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
}

/* Inspiration link list */
.inspiration-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}
.inspiration-link {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}
.inspiration-link:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}
.inspiration-link.active {
    background: rgba(129, 140, 248, 0.12);
    border-color: var(--accent);
}
.inspiration-link-title {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.inspiration-link-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(129, 140, 248, 0.15);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}
.inspiration-link-preview {
    flex-basis: 100%;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* glass-bg/border vars for inline styles */
:root {
    --glass-bg: rgba(255, 255, 255, 0.04);
}

/* Type Selector */
.type-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.type-btn {
    flex: 1 1 0;
    min-width: 120px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    backdrop-filter: blur(8px);
}
.type-btn small {
    display: block;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.type-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.type-btn.active {
    background: rgba(129, 140, 248, 0.12);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 16px rgba(129, 140, 248, 0.15);
}
.type-btn.active small {
    color: var(--accent);
    opacity: 0.8;
}

/* Inspiration link word count */
.inspiration-link-words {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--mono);
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .pipeline { flex-wrap: wrap; }
}
