/* =========================================================
 * CATEGORÍAS — picker, modal categoría, icon picker, cabecera
 * ========================================================= */

/* ── PICKER DE CATEGORÍAS ── */
.category-picker-modal {
    max-width: 520px;
}
.category-picker-body {
    margin-top: 0.75rem;
}
.category-picker-loading {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
}
.category-picker-empty {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.category-picker-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    max-height: 360px;
    overflow-y: auto;
    padding: 0.25rem;
}
.category-picker-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    font-size: 0.9375rem;
    color: var(--text-color);
}
.category-picker-item:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary-color);
}
.category-picker-item:disabled {
    opacity: 0.5;
    cursor: wait;
}
.category-picker-item .category-picker-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}
.category-picker-item .category-picker-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.category-picker-item .category-picker-check {
    opacity: 0;
    color: var(--primary-color);
    font-weight: 700;
    transition: opacity 0.15s;
}
.category-picker-item.is-active {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}
.category-picker-item.is-active .category-picker-check {
    opacity: 1;
}

/* ── MODAL DE CATEGORÍA + ICON PICKER ── */

.modal-categoria {
    max-width: 720px;
    width: 95%;
}

.icon-picker-row {
    display: grid;
    grid-template-columns: auto 90px 1fr;
    gap: 0.625rem;
    align-items: center;
}
.icon-picker-current {
    width: 56px;
    height: 56px;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: #f9fafb;
    font-size: 2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-picker-input {
    width: 100%;
    padding: 0.75rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    text-align: center;
    font-size: 1.25rem;
    background: var(--surface-color);
}
.icon-picker-input:focus,
.icon-picker-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(247, 89, 0, 0.1);
}
.icon-picker-search {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    background: var(--surface-color);
}

.icon-grid-wrap {
    margin-top: 0.875rem;
    padding: 0.75rem;
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 0.625rem;
    max-height: 360px;
    overflow-y: auto;
}

.icon-grid-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.625rem 0.25rem 0.375rem;
    position: sticky;
    top: -0.75rem;
    background: linear-gradient(#f9fafb 60%, transparent);
    z-index: 1;
}
.icon-grid-header:first-child { padding-top: 0; }

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}
.icon-grid-item {
    width: 100%;
    aspect-ratio: 1;
    background: var(--surface-color);
    border: 1px solid transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1.375rem;
    transition: background 0.1s, border-color 0.1s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.icon-grid-item:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    transform: scale(1.15);
}
.icon-grid-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
}

/* ── VISTA DE CATEGORÍA ── */

.cat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    justify-content: space-between;
}
.cat-header-icon {
    font-size: 2.25rem;
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    border: 1px solid #ffd5bc;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
/* El título se reserva 180px antes de ceder sitio. Con «flex: 1» a secas su base era 0: los
   botones (que no encogen) se quedaban en la misma línea y el título se aplastaba hasta una
   letra por línea (portada de Gestión de Tallas a 650px). Así, si no caben, los botones bajan
   a la línea de abajo. 180px + el icono caben también en una pantalla de 300px. */
.cat-header-info { flex: 1 1 180px; min-width: 0; }
.cat-header-info h1 { margin: 0; font-size: 1.625rem; overflow-wrap: break-word; }
.cat-header-info p { color: var(--text-muted); margin-top: 0.25rem; font-size: 0.9rem; }
.cat-header-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; flex-shrink: 0; max-width: 100%; }

/* =========================================================
 * RESPONSIVE — categorías
 * ========================================================= */

@media (max-width: 600px) {
    .icon-picker-row {
        grid-template-columns: auto 80px;
        grid-template-rows: auto auto;
    }
    .icon-picker-search {
        grid-column: 1 / -1;
    }
    .icon-grid-wrap { max-height: 300px; }
}

@media (max-width: 480px) {
    .cat-header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
}

@media (max-width: 400px) {
    .modal-categoria {
        width: 96%;
    }
}
