/* Catalogs: the register (/catalogs) and its Add/Edit form (/catalogs/create, /catalogs/edit/...).
   Same frame as the Price List pages: the form starts under the single-row .top-btns-container at
   7rem, shares its left/right edges, and scrolls as one column of cards above the Save bar. */

/* ---- register ---- */

.cd-register {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.cd-register th,
.cd-register td {
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid #eef0f3;
    background: #ffffff;
}

.cd-register thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #6b7280;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cd-register tr.active td {
    background: #eef6ff;
}

.cd-register .cd-check {
    width: 36px;
}

.cd-register .cd-title {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cd-num {
    text-align: right !important;
}

.cd-register .cd-action {
    position: sticky;
    right: 0;
    width: 140px;
    text-align: center;
}

.cd-register .edit-icon,
.cd-register .share-icon,
.cd-register .delete-icon,
.cd-items .delete-icon {
    cursor: pointer;
    fill: #808080;
    vertical-align: middle;
}

.cd-register .edit-icon:hover,
.cd-register .share-icon:hover {
    fill: #3399ff;
}

.cd-register .delete-icon:hover,
.cd-items .delete-icon:hover {
    fill: #e53935;
}

.cd-empty {
    padding: 24px;
    text-align: center;
    color: #6b7280;
}

/* ---- form ---- */

.cd-page {
    position: fixed;
    top: 7rem;
    bottom: 0;
    left: 14.5rem;
    right: 1rem;
    padding-bottom: 5rem;
    overflow-y: auto;
    transition: left 0.2s ease;
    font-size: 13px;
    color: #1f2937;
}

.cd-page.sidebar-collapsed {
    left: 5.5rem;
}

.cd-card {
    background: #ffffff;
    border: 1px solid #e5e9f0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.05);
    padding: 12px 16px;
    margin-bottom: 10px;
}

.cd-card-title {
    font-size: 10px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

.cd-card-title.cd-inline {
    margin: 0;
}

.cd-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.cd-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 1 260px;
    min-width: 180px;
}

.cd-field-narrow {
    flex-basis: 160px;
    min-width: 140px;
}

.cd-field-wide {
    flex: 1 1 320px;
}

.cd-field-full {
    flex: 1 1 100%;
}

.cd-field label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
}

.cd-page select,
.cd-page input[type=text],
.cd-page input[type=date],
.cd-page input[type=number],
.cd-page textarea {
    height: 34px;
    width: 100%;
    padding: 0 8px;
    border: 1px solid #e5e9f0;
    border-radius: 6px;
    background: #ffffff;
    color: #1f2937;
    font: inherit;
    box-sizing: border-box;
}

.cd-page textarea {
    height: auto;
    min-height: 52px;
    padding: 6px 8px;
    resize: vertical;
}

.cd-page select:focus,
.cd-page input:focus,
.cd-page textarea:focus {
    outline: none;
    border-color: #3399ff;
    box-shadow: 0 0 0 2px #cce5ff;
}

.cd-hint {
    font-size: 12px;
    color: #6b7280;
    padding: 6px 0;
}

.cd-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.cd-spacer {
    flex: 1 1 auto;
}

.cd-picker-product {
    flex: 0 1 320px;
}

/* app.css gives .btn-primary / .btn-secondary width: 100% and a tall padding, for footer bars. */
.cd-toolbar .cd-small-btn {
    width: auto;
    flex: 0 0 auto;
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
}

/* Image tiles of the picked product: click to tick, ticked ones go in with Add Selected. */
.cd-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    max-height: 46vh;
    overflow-y: auto;
    padding: 2px;
}

.cd-tile {
    position: relative;
    border: 2px solid #e5e9f0;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: #f8fafc;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cd-tile:hover {
    border-color: #99ccff;
}

.cd-tile.picked {
    border-color: #3399ff;
    box-shadow: 0 0 0 2px #cce5ff;
}

.cd-tile.added {
    cursor: default;
    opacity: 0.55;
}

.cd-tile img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #ffffff;
}

.cd-tile-label {
    padding: 5px 8px;
    font-size: 11px;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-top: 1px solid #eef0f3;
}

.cd-tile-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    background: #dcfce7;
    color: #166534;
}

.cd-tile-badge-pick {
    background: #3399ff;
    color: #ffffff;
}

/* Items in this catalog */
.cd-items-scroll {
    overflow-x: auto;
}

.cd-items {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.cd-items th,
.cd-items td {
    padding: 6px 10px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid #eef0f3;
    background: #ffffff;
    vertical-align: middle;
}

.cd-items thead th {
    color: #6b7280;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cd-items .cd-action {
    width: 110px;
    text-align: center;
}

.cd-thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border: 1px solid #eef0f3;
    border-radius: 6px;
    background: #ffffff;
}

.cd-missing {
    font-size: 11px;
    color: #b91c1c;
}

.cd-page input.cd-rate {
    width: 110px;
    text-align: right;
}

.cd-icon-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #e5e9f0;
    border-radius: 5px;
    background: #ffffff;
    color: #6b7280;
    font-size: 9px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}

.cd-icon-btn:hover:not(:disabled) {
    border-color: #3399ff;
    color: #3399ff;
}

.cd-icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

@media (max-width: 768px) {
    .cd-page,
    .cd-page.sidebar-collapsed {
        left: 1rem;
    }

    .cd-tiles {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}
