/* css/uca.css — Модул „Анализи на единични цени" (UCA), страница unit-analyses.html.
   BEM-lite. Зарежда се само от unit-analyses.html (page-scoped, не е в _layout). */

/* ---- Pro gate ---- */
.uca-progate { text-align: center; padding: 3rem 2rem; }
.uca-progate h2 { margin-bottom: 0.75rem; }
.uca-progate p { max-width: 560px; margin: 0 auto 1.5rem; color: var(--text-secondary); }

/* ---- Ъплоуд ---- */
.uca-upload-row {
    display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
}
.uca-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.uca-file-label {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 1rem; border: 1.5px dashed var(--border);
    border-radius: 8px; cursor: pointer; color: var(--text-secondary);
    transition: border-color 0.15s, color 0.15s;
    max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.uca-file-label:hover { border-color: var(--primary); color: var(--primary); }
.uca-name-input {
    flex: 1; min-width: 180px; padding: 0.55rem 0.75rem;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text);
}

/* ---- Списък проекти ---- */
.uca-projects-list { display: flex; flex-direction: column; gap: 0.5rem; }
.uca-project-row {
    display: grid; grid-template-columns: 1fr auto auto auto;
    gap: 0.75rem; align-items: center; width: 100%;
    padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg); color: var(--text); cursor: pointer; text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.uca-project-row:hover { border-color: var(--primary); box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.08)); }
.uca-project-row__name { font-weight: 600; }
.uca-project-row__file, .uca-project-row__date {
    font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap;
}
.uca-empty { color: var(--text-secondary); padding: 0.5rem 0; }

/* ---- Статус бадж ---- */
.uca-status-badge {
    display: inline-block; padding: 0.18rem 0.6rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
    background: var(--bg-secondary, #f1f5f9); color: var(--text-secondary);
}
.uca-status-badge--done { background: rgba(22, 163, 74, 0.12); color: var(--success, #16a34a); }
.uca-status-badge--failed { background: rgba(220, 38, 38, 0.12); color: #dc2626; }
.uca-status-badge--working { background: rgba(37, 99, 235, 0.10); color: var(--primary); }
.uca-status-badge--parsed { background: rgba(217, 119, 6, 0.12); color: #d97706; }

/* ---- Детайл ---- */
.uca-detail-top { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.uca-back { color: var(--text-secondary); text-decoration: none; white-space: nowrap; }
.uca-back:hover { color: var(--primary); }
.uca-detail-title { margin: 0; flex: 1; font-size: 1.3rem; }

/* ---- Показатели ---- */
.uca-ind-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem; margin: 0.75rem 0;
}
.uca-ind-field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; }
.uca-ind-field small { color: var(--text-secondary); font-weight: 400; }
.uca-ind-field input, .uca-ind-field select {
    padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text); font-size: 0.95rem;
}
.uca-ind-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }
.uca-ind-actions input {
    padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text);
}

/* ---- Таблици ---- */
.uca-table-wrap { overflow-x: auto; margin-top: 0.75rem; }
.uca-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.uca-table th, .uca-table td {
    padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left;
}
.uca-table th { font-size: 0.78rem; text-transform: uppercase; color: var(--text-secondary); }
.uca-table__num { text-align: right !important; font-variant-numeric: tabular-nums; }
.uca-table__chk { width: 2rem; }
.uca-table__desc { max-width: 480px; }
.uca-table__section td {
    background: var(--bg-secondary, #f1f5f9); font-weight: 600; font-size: 0.8rem;
    color: var(--text-secondary);
}
.uca-table__row--noprice td { opacity: 0.55; }
.uca-table__row--clickable { cursor: pointer; }
.uca-table__row--clickable:hover td { background: var(--primary-light, rgba(37, 99, 235, 0.06)); }
.uca-error-note { color: #dc2626; }
.uca-positions-head, .uca-results-head {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.uca-positions-head-actions, .uca-results-actions { display: flex; gap: 0.5rem; }
.uca-generate-bar {
    display: flex; justify-content: flex-end; align-items: center; gap: 1rem;
    margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.uca-generate-bar span { color: var(--text-secondary); font-size: 0.88rem; }

/* ---- Прогрес ---- */
.uca-progress-card { text-align: center; padding: 2.5rem 2rem; }
.uca-progress-track {
    height: 10px; border-radius: 999px; background: var(--bg-secondary, #f1f5f9);
    overflow: hidden; margin: 1.25rem auto; max-width: 480px;
}
.uca-progress-fill {
    height: 100%; border-radius: 999px; background: var(--primary);
    transition: width 0.4s ease;
}
.uca-progress-fill--indeterminate {
    animation: uca-indeterminate 1.4s ease-in-out infinite;
    transform-origin: left;
}
@keyframes uca-indeterminate {
    0% { transform: scaleX(0.05); }
    50% { transform: scaleX(0.85); }
    100% { transform: scaleX(0.05); }
}
.uca-progress-text { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Панел за редакция ---- */
.uca-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15, 23, 42, 0.55);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
/* КРИТИЧНО: display:flex по-горе бие UA правилото за [hidden] — връщаме го явно */
.uca-overlay[hidden] { display: none; }
.uca-panel {
    background: var(--bg); border-radius: 14px; width: min(880px, 100%);
    max-height: 92vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.uca-panel-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 1.1rem 1.4rem 0.8rem; border-bottom: 1px solid var(--border);
}
.uca-panel-head h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.uca-panel-sub { margin: 0; color: var(--text-secondary); font-size: 0.85rem; }
.uca-panel-close {
    border: none; background: none; font-size: 1.6rem; line-height: 1;
    color: var(--text-secondary); cursor: pointer; padding: 0.2rem 0.5rem;
}
.uca-panel-close:hover { color: var(--text); }
.uca-panel-body { overflow-y: auto; padding: 0.8rem 1.4rem; flex: 1; }
.uca-panel-kind {
    margin: 1rem 0 0.3rem; font-size: 0.78rem; text-transform: uppercase;
    color: var(--text-secondary); letter-spacing: 0.04em;
}
.uca-table--edit input.uca-edit {
    width: 100%; padding: 0.3rem 0.45rem; border: 1px solid transparent;
    border-radius: 6px; background: transparent; color: var(--text); font-size: 0.88rem;
}
.uca-table--edit input.uca-edit:hover { border-color: var(--border); }
.uca-table--edit input.uca-edit:focus { border-color: var(--primary); outline: none; background: var(--bg); }
.uca-edit--num { max-width: 90px; text-align: right; }
.uca-edit--unit { max-width: 70px; }
.uca-fixed-price { display: inline-block; padding: 0.3rem 0.45rem; color: var(--text-secondary); }
.uca-row-del {
    border: none; background: none; color: var(--text-secondary);
    font-size: 1.1rem; cursor: pointer; padding: 0 0.3rem;
}
.uca-row-del:hover { color: #dc2626; }
.uca-table__empty-row td { color: var(--text-secondary); font-style: italic; }
.uca-panel-foot {
    border-top: 1px solid var(--border); padding: 0.9rem 1.4rem;
    display: flex; flex-direction: column; gap: 0.7rem;
}
.uca-panel-totals-grid {
    display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-size: 0.85rem;
    color: var(--text-secondary);
}
.uca-panel-totals-final { color: var(--text); font-size: 0.95rem; }
.uca-panel-totals--warn .uca-panel-totals-final b { color: #dc2626; }
.uca-panel-foot-actions {
    display: flex; justify-content: flex-end; gap: 0.6rem; align-items: center;
}

/* ---- Mobile ---- */
@media (max-width: 640px) {
    .uca-project-row { grid-template-columns: 1fr auto; }
    .uca-project-row__file { display: none; }
    .uca-upload-row { flex-direction: column; align-items: stretch; }
    .uca-detail-title { font-size: 1.1rem; }
    .uca-panel { max-height: 96vh; }
    .uca-table__desc { max-width: 220px; }
}
