/*
 * catalog.css — shared catalog/list/form UI styles.
 *
 * Shared by BOTH shells:
 *   - templates/base.html          (FOP module)
 *   - kcdocs/templates/kcdocs/base.html  (KC module)
 *
 * The KC shell already defines :root variables, base typography, .btn-primary,
 * .form-control, .table, .doc-type-*, .mono, .pagination and TomSelect rules.
 * This file adds:
 *   (a) The full cat-* family that the KC catalog pages reference.
 *   (b) The small primitives that are in the FOP shell but absent from the KC
 *       shell: .label, .btn-sm, .table-hover.
 *
 * FOP shell keeps its own inline <style> unchanged (harmless duplication is
 * safer than risking a visual regression on the working FOP module).
 */

/* === Missing primitives (present in FOP shell, absent from KC shell) === */

.label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* .btn-sm — small variant, e.g. filter bar search button */
.btn-sm { height: 30px; padding: 5px 12px; font-size: 12.5px; }

/* .table-hover row highlight */
.table-hover > tbody > tr:hover > * { background-color: var(--surface-subtle); }


/* === CATALOG: shared list + form pages (products, clients, sellers) === */

/* List page header: title left, primary action right */
.cat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}
.cat-header h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }

/* Form page header: breadcrumb + title */
.cat-form-header { margin-bottom: 20px; }
.cat-form-header h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.cat-breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 10px;
}
.cat-breadcrumb:hover { color: var(--text); text-decoration: none; }

/* Filter bar */
.cat-filter {
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.cat-search { display: flex; gap: 8px; flex: 1; min-width: 240px; max-width: 420px; }
.cat-search .form-control { flex: 1; }

/* Segmented switcher (Active / Archive) */
.cat-seg {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-subtle);
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
}
.cat-seg-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--r-pill);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    line-height: 1.3;
    transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.cat-seg-btn:hover { color: var(--text); text-decoration: none; }
.cat-seg-btn.active {
    background: #FFFFFF;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Table wrapper */
.cat-table {
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    overflow: hidden;
    background: var(--surface);
}
.cat-table .table > thead > tr > th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
}
.cat-table .table > tbody > tr > td {
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}
.cat-table .table > tbody > tr:last-child > td { border-bottom: none; }

.cat-muted   { color: var(--text-muted); }
.cat-strong  { font-weight: 500; }
.cat-sub     { font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.cat-amount  { text-align: right; }
.cat-amount .currency { color: var(--text-muted); margin-left: 4px; font-size: 12px; }
.cat-actions  { white-space: nowrap; text-align: right; }
.cat-archived { color: var(--text-muted); }

/* Icon action buttons */
.cat-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--r-input);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 13px;
    margin-left: 4px;
    transition: all 0.15s;
    text-decoration: none;
    cursor: pointer;
}
.cat-btn-icon:hover {
    background: var(--surface-subtle);
    color: var(--text);
    border-color: var(--border-strong);
    text-decoration: none;
}
.cat-btn-icon.danger:hover  { background: #FEF2F2; color: #DC2626; border-color: #FECACA; }
.cat-btn-icon.restore:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--border-strong); }
.cat-inline-form { display: inline; }

/* Empty state */
.cat-empty { text-align: center; padding: 48px 20px; }
.cat-empty .bi { font-size: 28px; color: var(--text-muted); margin-bottom: 10px; display: block; }
.cat-empty-text { color: var(--text-muted); font-size: 14px; margin-bottom: 14px; }

/* Form card + grid */
.cat-card {
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: 20px;
    background: var(--surface);
    max-width: 720px;
}
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.cat-grid .full { grid-column: 1 / -1; }

/* Form sections (divider between logical groups) */
.cat-section + .cat-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.cat-section .section-title { margin: 0 0 14px; }

/* Collapsible form section (<details>) */
.form-section-details summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    transition: color 0.15s;
}
.form-section-details summary::-webkit-details-marker { display: none; }
.form-section-details summary::before {
    content: '▸';
    font-size: 10px;
    color: var(--text-subtle);
    display: inline-block;
    transition: transform 0.15s;
}
.form-section-details[open] summary::before { transform: rotate(90deg); }
.form-section-details[open] summary { margin-bottom: 14px; }
.form-section-details summary:hover { color: var(--primary); }

.cat-field .form-label { display: block; }
.cat-errors { color: #991B1B; font-size: 12px; margin-top: 6px; }
.cat-errors ul { list-style: none; padding: 0; margin: 0; }
.cat-help { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* Sticky form actions */
.cat-form-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 14px 0;
    margin-top: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    max-width: 720px;
}

/* Inline formset: bank accounts */
.cat-bank-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cat-add-btn {
    background: transparent;
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-input);
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}
.cat-add-btn:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.cat-bank-table { border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.cat-bank-header,
.cat-bank-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1.4fr 0.8fr 80px 40px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
}
.cat-bank-header { background: var(--surface-subtle); border-bottom: 1px solid var(--border); }
.cat-bank-header > div { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
.cat-bank-header .center,
.cat-bank-row   .center { text-align: center; justify-self: center; }
.cat-bank-row { border-bottom: 1px solid var(--border); background: var(--surface); }
#banks-container > .cat-bank-row:last-child { border-bottom: none; }
.cat-bank-row .form-control { height: 32px; padding: 4px 8px; font-size: 13px; }
.cat-bank-empty { padding: 16px 12px; color: var(--text-muted); font-size: 13px; text-align: center; }

/* Signature upload + preview */
.cat-file { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.cat-file .form-control { max-width: 360px; }
.cat-signature-preview {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-subtle);
    padding: 4px;
}

@media (max-width: 600px) {
    .cat-grid { grid-template-columns: 1fr; }
    .cat-form-actions { flex-direction: column-reverse; }
    .cat-form-actions > * { width: 100%; }
    .cat-bank-header { display: none; }
    .cat-bank-row { grid-template-columns: 1fr 1fr; }
}
