/* css/tp-generator.css — Генератор на технически предложения (ТП).
   Page-scoped — зарежда се само от tp-generator.html (както uca.css).
   BEM-lite: tp-steps / tp-panel / tp-dropzone / tp-phase / tp-stats / tp-preview.
   Всички цветове — само през дизайн токените (base.css). */

/* ============ Steps indicator ============ */
.tp-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tp-steps__item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
.tp-steps__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: var(--radius-full);
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
}
.tp-steps__item--active {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-card);
}
.tp-steps__item--active .tp-steps__num {
    background: var(--primary);
    color: var(--text-inverse);
}
.tp-steps__item--done {
    color: var(--success);
}
.tp-steps__item--done .tp-steps__num {
    background: var(--success-light);
    color: var(--success);
}

/* ============ Panels (wizard steps) ============ */
.tp-panel { display: none; }
.tp-panel--active { display: block; }

/* ============ Form ============ */
.tp-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.tp-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1rem;
}
.tp-field > span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.tp-field input,
.tp-field textarea {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
}
.tp-field input:focus,
.tp-field textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    border-color: var(--primary);
}
.tp-field small {
    color: var(--text-muted);
    font-size: 0.78rem;
}
.tp-req { color: var(--danger); font-style: normal; }
.tp-optional { color: var(--text-muted); font-weight: 400; font-size: 0.85em; }

.tp-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.tp-actions--end { justify-content: flex-end; }
.tp-actions--between { justify-content: space-between; }

/* ============ Dropzone ============ */
.tp-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.tp-dropzone:hover,
.tp-dropzone:focus-visible,
.tp-dropzone--dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.tp-dropzone__icon { font-size: 1.8rem; }
.tp-dropzone__text {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.tp-fileinfo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-size: 0.9rem;
}
.tp-fileinfo__name { font-weight: 600; color: var(--text); word-break: break-all; }
.tp-fileinfo__size { color: var(--text-muted); font-size: 0.82rem; white-space: nowrap; }
.tp-fileinfo__remove {
    margin-left: auto;
    border: none;
    background: none;
    color: var(--danger);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}
.tp-fileinfo__remove:hover { background: var(--danger-light); }

/* ============ Progress ============ */
.tp-progress-track {
    height: 0.6rem;
    background: var(--surface-alt);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 0.75rem 0;
}
.tp-progress-fill {
    height: 100%;
    background: var(--gradient-brand);
    border-radius: var(--radius-full);
    transition: width var(--t-slow) var(--ease);
}
.tp-progress-text {
    text-align: center;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    min-height: 1.4em;
}
.tp-progress-note { margin-top: 1rem; }

.tp-phases {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.tp-phase {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-muted);
}
.tp-phase--active {
    background: var(--primary-light);
    color: var(--text);
    font-weight: 500;
}
.tp-phase--done { color: var(--text-secondary); }
.tp-phase--error {
    background: var(--danger-light);
    color: var(--danger);
}
.tp-phase__icon {
    width: 1.4rem;
    text-align: center;
    flex-shrink: 0;
}

.tp-spinner {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: tp-spin 0.8s linear infinite;
    vertical-align: middle;
}
@keyframes tp-spin { to { transform: rotate(360deg); } }

/* ============ Result stats ============ */
.tp-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.tp-stats__card {
    flex: 1;
    min-width: 130px;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    text-align: center;
    background: var(--surface-alt);
}
.tp-stats__card--pages       { background: var(--primary-light); }
.tp-stats__card--sections    { background: var(--success-light); }
.tp-stats__card--placeholders{ background: var(--warning-light); }
.tp-stats__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}
.tp-stats__card--pages .tp-stats__value    { color: var(--primary); }
.tp-stats__card--sections .tp-stats__value { color: var(--success); }
.tp-stats__card--placeholders .tp-stats__value { color: var(--warning); }
.tp-stats__label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ============ Preview ============ */
.tp-preview {
    max-height: 60vh;
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-size: 0.9rem;
    line-height: 1.6;
}
.tp-preview h1, .tp-preview h2, .tp-preview h3 {
    margin: 1em 0 0.4em;
    color: var(--text);
}
.tp-preview .tp-preview__placeholder {
    background: var(--warning-light);
    color: var(--warning);
    padding: 0 0.25em;
    border-radius: 3px;
    font-weight: 600;
}

/* ============ История — Моите документи ============ */
.tp-history {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.tp-history__empty {
    color: var(--text-muted);
    font-size: 0.88rem;
}
.tp-history__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.88rem;
}
.tp-history__row--completed  { border-left: 3px solid var(--success); }
.tp-history__row--processing { border-left: 3px solid var(--primary); }
.tp-history__row--error      { border-left: 3px solid var(--danger); }
.tp-history__info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.tp-history__date {
    color: var(--text-secondary);
    font-weight: 600;
}
.tp-history__status {
    color: var(--text-muted);
    font-size: 0.8rem;
}
.tp-history__actions { flex-shrink: 0; }

/* ============ Cost line (issue #135 — кредити) ============ */
.tp-cost-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.tp-cost-line__item strong { color: var(--primary); font-weight: 700; }
.tp-cost-line--insufficient {
    background: color-mix(in srgb, var(--danger) 8%, var(--surface));
    border-color: var(--danger);
}
.tp-cost-line--insufficient .tp-cost-line__item strong { color: var(--danger); }

/* ============ Gate ============ */
.tp-gate { text-align: center; padding: 2.5rem 1.5rem; }
.tp-gate p { color: var(--text-secondary); max-width: 46rem; margin: 0.6rem auto; }
.tp-gate .account-btn { margin-top: 1rem; }

/* ============ Mobile ============ */
@media (max-width: 640px) {
    .tp-form-row { grid-template-columns: 1fr; gap: 0; }
    .tp-steps { flex-wrap: wrap; }
    .tp-steps__item { min-width: calc(50% - 0.25rem); flex: none; }
    .tp-steps__label { font-size: 0.78rem; }
    .tp-stats__card { min-width: calc(50% - 0.5rem); }
}
